|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stay one step ahead of the competition. Evaluate and give feedback
on some of the hottest web development tools on the market today.
Make your opinion heard! Click
Here
|
|
#1
|
|||
|
|||
|
it says undefined index name
hi pple! i need some help!
hmmm.. the prob is that i cannot store the user's input into the database. you see.. my first page is a form.html page. after the user key in their input and click on submit, it will display a display.php page! this page will just display what the user's input. if the user clicks on confirm button, this information will then be send to the database! it is working fine when i pass the values from the firstpage to the display.php, but then when i click on the confirm button, it gives me an error saying Undefined Index! nothing is store in the database.. can anyone tell me wats the problem? btw.. i am using php4.. thx.. |
|
#2
|
|||
|
|||
|
RE: it says undefined index name
Ok, your not sending the data to the 3rd page. what you need to do on the second page, is to create hidden fields, that store the data, then create a submit button, that passes on the data to the 3rd page
|
|
#3
|
|||
|
|||
|
RE: it says undefined index name
hmmmmm... there is no error msg but unable to store the user input ito database.
err.. let me show you the codes: first page coding: <html> <head> <title>First Page</title> </head> <body> <h1>Enter all the Information</h1> <form action="display.php" method="post"> <table border=0> <tr> <td>Name</td> <td><input type="text" name="name"><br></td> </tr> <tr> <td>Sex</td> <td><input type="text" name="sex"><br></td> </tr> <tr> <td>Age</td> <td><input type="text" name="age"><br></td> <tr> </tr> <tr> <td colspan=2><input type="submit" value="Register"></td> </tr> </table> </form> </body> </html> second page coding: <html> <head> <title>Results</title> </head> <body> <h2>Check Your Information. Once Confirm, Click on the Send, Else return back to Edit ur Info</h2> <form action="put.php" method="post"> <?php $name = $_POST['name']; $sex = $_POST['sex']; $age = $_POST['age']; print ("<p>Name: </b>n"); print ("$name"); print ("<br>Sex: </b>n"); print ("$sex"); print ("<br>Age: </b>n"); print ("$age"); ?> <table border=0> <tr> <td></td> <td><input type="hidden" name="name" value=<?php $name ?>><br></td> </tr> <tr> <td></td> <td><input type="hidden" name="sex" value=<?php $sex ?>><br></td> </tr> <tr> <td></td> <td><input type="hidden" name="age" value=<?php $age ?>><br></td> <tr> </tr> <tr> <td colspan=2><input type="submit" value="Register"></td> </tr> </table> <p> </body> </html> third page coding: <html> <head> <title>Results</title> </head> <body> <h1>Results</h1> <?php $link = @mysql_connect("localhost", "root", ""); if (!$link) { print("Error"); exit; } if (!@mysql_select_db("information")) { print("cannot find database"); exit; } $name = $_POST['name']; $sex = $_POST['sex']; $age = $_POST['age']; mysql_query("INSERT INTO info (name,sex,age) VALUES('$name','$sex','$age')"); print("Information Sent"); ?> </body> </html> thx... |
|
#4
|
|||
|
|||
|
RE: it says undefined index name
why don't u try to echo name, age and sex variables in last script to see if they are submited right..
or even beter, do a var_dump($_POST); and another thing. html code for hidden fields should look like this <input type="text" name="age" value="17"> and your code produces code like: <input type="text" name="age" value=17> note that the "" are missing. now, this MAY work sometimes, but u shouldn't relay on that... |
![]() |
| Viewing: Codewalkers Forums > PHP Related > PHP Coding > it says undefined index name |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|
|
|