Problem Using Data From Forms

Problems with the Windows version of XAMPP, questions, comments, and anything related.

Problem Using Data From Forms

Postby pjl2 » 24. August 2012 16:49

First, I am a beginner and I apologize if I have posted this question to the wrong forum. I would appreciate any guidance on finding a more appropriate forum to post to. I also apologize for the length of this post.

I am trying to learn PHP. My goal is to create a site that allows users to enter data into forms so that I can insert that data into a MySql database. But for now I would settle for being able to accept the user data and return a message to the user with PHP.

-I have installed XAMPP for Windows version 1.8.0 using the installer. (But note that I had all the same problem discussed below with the prior version installed).
-The Control Panel Version of XAMPP is v.3.0.12
-The XAMPP control panel says that I am running with administrator rights. I have to hold down shift and control to make this happen when I open XAMPP
-I did not check the services boxes when I installed XAMPP.
-I have Windows 7, but I get the same results (which I describe below) on a Windows XP machine.
-I tried turning off Windows Firewall and my Security Program but it didn't make any difference.

Following is an example that illustrates my problem using a very simple HTML file and a very simple PHP file.

First, the HTML code:

<title=ID Form>
Please fill out the form below:
<!--I just want to enter some integers into the text box-->
<br />
<br />
<form action= "IdForm2.php" method="POST">
Id Number:
<input type="text" name="idvar"/>
<br />
<br />
<input type="submit" value="Submit Form"/>&nbsp;<input type="reset" value="Reset Form"/></p>

Next, the PHP code:


echo 'All work and no play makes Jack a dull boy';
echo '<br><br>';

//I just want to capture the input to the form and then print it out

$Z = $_POST["idvar"];
echo $Z;

echo "<br><br>Rinse and Repeat";


And here is the output that I get:

All work and no play makes Jack a dull boy

Notice: Undefined index: idvar in C:\xampp\htdocs\practice\IdForm2.php on line 8

Rinse and Repeat

I still get this result when I substitute REQUEST for POST in both files.

I did a Google search for prior instances of this problem. I tried a couple of the suggested solutions. One thing that I did was to insert the following code:

if (isset($_POST['idvar'])) {
echo $_POST['idvar'];
} else {
echo 'The variable idvar is not set';

The result is that I get the message stating that the idvar is not set.

I can understand the idea that I can't use a variable that is not set. But that doesn't really help, because my whole purpose for learning this stuff is, as I mentioned, to send user entered data to a database.

Please note that I've just given a simple example of my problem. I get the same undefined index error with other code using forms. So maybe I need to know how to set variables?

I sent this code to my instructor at Big State University, and it runs fine on his machine with an old version of XAMPP installed. By runs fine, I mean that in place of the undefined index error it returns the integer that was submitted in the form. He has no idea why I am having this problem. This is not a degree seeking program and I am free to seek outside help.

I thank you in advance for any guidance you might be able to provide.
Posts: 2
Joined: 24. August 2012 16:40
Operating System: Windows 7

Re: Problem Using Data From Forms

Postby JJ_Tagy » 25. August 2012 23:33

Sounds like your php error reporting is set to give NOTICEs. You could change your php.ini error reporting to "error_reporting = E_ALL & ~E_NOTICE & ~E_STRICT"
Posts: 671
Joined: 30. January 2012 13:44
Operating System: Windows 10 Pro x64

Re: Problem Using Data From Forms

Postby pjl2 » 26. August 2012 02:19

Thank you very much. That really cleared everything up.
Posts: 2
Joined: 24. August 2012 16:40
Operating System: Windows 7

Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 40 guests