Page 2 of 2

Re: Input from form is not going into mysql table

Posted: Mon Oct 11, 2010 3:44 pm
by lilpenguin
No worries. There's a lot of code in this one thread:)
Still getting index error when I made that change though:( All indexes are bad. Is there somewhere I need to be defining an index? In PHPmyAdmin there is but which field should I make my index? I actually tried to make the incrementing number (the one I'm using as primary key) as my index but it would not let me do both of them for that one value.

Re: Input from form is not going into mysql table

Posted: Mon Oct 11, 2010 5:45 pm
by califdon
lilpenguin wrote:No worries. There's a lot of code in this one thread:)
Still getting index error when I made that change though:( All indexes are bad. Is there somewhere I need to be defining an index? In PHPmyAdmin there is but which field should I make my index? I actually tried to make the incrementing number (the one I'm using as primary key) as my index but it would not let me do both of them for that one value.
No, you are misinterpreting "index". It is NOT referring to indexing fields in your table. The "index" the error message is referring to is the ARRAY INDEX of the $_POST array. What should be in the $_POST array when you submit the form should look like this: there should be 7 array elements, like $_POST['username'] (which should contain the value entered in the 'username' form element), etc. The 'username' part is called the array index.

If you added the value= statements in your <select> element and you are still getting that error, something else is wrong with your form, although I don't see what it might be. I would do this:

Create a debug script, you might call it formdebug.php, with only the following code:

Code: Select all

<?php
echo "Name = ".$_POST['name']<br>";
echo "UserName = ".$_POST['username']<br>";
echo "Email= ".$_POST['email']<br>";
?>
Save the formdebug.php file. Then, temporarily, change the action="register.php" in your <form> tag to action="formdebug.php". Open your form, enter values for those 3 fields, click the Submit button, and if the form values are not printed on the screen, you definitely have an error in your form.

What you have to isolate is whether the form is or is not properly creating the $_POST array for the handler script to read.