silverglade Posted October 12, 2009 Share Posted October 12, 2009 hi, i need some advice on this simple table updating registration script, it wont update the table with the new data. any help GREATLY appreciated. i tried to make it as simple as i could and i still cant find the error. thanks. derek here is the code. <?php include("connections.php"); $full_name = $_POST['full_name']; $username = $_POST['username']; $password = $_POST['password']; $maiden = $_POST['maiden']; $color = $_POST['color']; if($full_name && $username && $password && $maiden && $color){ mysql_query("INSERT INTO registration_table (full_name,username,password,maiden,color)VALUES('$full_name','$username','$password','$maiden','$color')"); } /// query db and loop through rows example //selects everything from table and assigns to the variable $query $query = mysql_query("SELECT * FROM registration_table"); $table = "<table width=\"40%\" border=\"1\"> <tr> <td>Here is your new registration information</td> </tr>"; while($row = mysql_fetch_array($query)){ ////row now stands for the array fetched. $table .= " <tr> <td>".$row['full_name']."</td> <td>".$row['username']."</td> <td>".$row['password']."</td> <td>".$row['maiden']."</td> <td>".$row['color']."</td> </tr>"; } $table .= "</table>"; ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <body> Please register to our forum below <form id="form1" name="form1" method="post" action="registration.php"> <table width="31%" border="0"> <tr> <td>Full Name:</td> <td><input name="pull Name" type="text" id="full_name" /></td> </tr> <tr> <td>User Name:</td> <td><input name="pser Name" type="text" id="username" /></td> </tr> <tr> <td>Password:</td> <td><input name="password" type="text" id="password" /></td> </tr> <tr> <td>Mother's maiden name</td> <td><input name="maiden" type="text" id="maiden" /></td> </tr> <tr> <td>Your favorite color</td> <td><input name="color" type="text" id="color" /></td> </tr> <tr> <td> </td> <td><input type="submit" name="Submit" value="Submit" /></td> </tr> </table> </form> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/177415-solved-need-help-with-this-simple-registration-script-please/ Share on other sites More sharing options...
PFMaBiSmAd Posted October 12, 2009 Share Posted October 12, 2009 You might want to check if the name="...." attributes in your form are the same that your code is using in the $_POST variables. Also, are you learning php, developing php code, and debugging php code on a system with error_reporting set to E_ALL and display_errors set to ON in your master php.ini so that php would help you by displaying all the errors it finds? Stop and start your web server to get any change made to the master php.ini to take effect. You will save a ton of time if you get php to display all the errors if finds. Quote Link to comment https://forums.phpfreaks.com/topic/177415-solved-need-help-with-this-simple-registration-script-please/#findComment-935461 Share on other sites More sharing options...
silverglade Posted October 12, 2009 Author Share Posted October 12, 2009 thank you! whoa! i dont know how my text got messed up like that. here is the fixed code, but it still doesnt update the table called registration_table in my local database. any more advice greatly appreciated. <?php include("connections.php"); $full_name = $_POST['full_name']; $username = $_POST['username']; $password = $_POST['password']; $maiden = $_POST['maiden']; $color = $_POST['color']; if($full_name && $username && $password && $maiden && $color){ mysql_query("INSERT INTO registration_table (full_name,username,password,maiden,color)VALUES('$full_name','$username','$password','$maiden','$color')"); } /// query db and loop through rows example //selects everything from table and assigns to the variable $query $query = mysql_query("SELECT * FROM registration_table"); $table = "<table width=\"40%\" border=\"1\"> <tr> <td>Here is your new registration information</td> </tr>"; while($row = mysql_fetch_array($query)){ ////row now stands for the array fetched. $table .= " <tr> <td>".$row['full_name']."</td> <td>".$row['username']."</td> <td>".$row['password']."</td> <td>".$row['maiden']."</td> <td>".$row['color']."</td> </tr>"; } $table .= "</table>"; ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <body> Please register to our forum below <form id="form1" name="form1" method="post" action="registration.php"> <table width="31%" border="0"> <tr> <td>Full Name:</td> <td><input name="full_name" type="text" id="full_name" /></td> </tr> <tr> <td>User Name:</td> <td><input name="user_name" type="text" id="username" /></td> </tr> <tr> <td>Password:</td> <td><input name="password" type="text" id="password" /></td> </tr> <tr> <td>Mother's maiden name</td> <td><input name="maiden" type="text" id="maiden" /></td> </tr> <tr> <td>Your favorite color</td> <td><input name="color" type="text" id="color" /></td> </tr> <tr> <td> </td> <td><input type="submit" name="Submit" value="Submit" /></td> </tr> </table> </form> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/177415-solved-need-help-with-this-simple-registration-script-please/#findComment-935463 Share on other sites More sharing options...
PFMaBiSmAd Posted October 12, 2009 Share Posted October 12, 2009 user_name is not the same as username Also, are you learning php, developing php code, and debugging php code on a system with error_reporting set to E_ALL and display_errors set to ON in your master php.ini so that php would help you by displaying all the errors it finds? Stop and start your web server to get any change made to the master php.ini to take effect. You will save a ton of time if you get php to display all the errors if finds. Quote Link to comment https://forums.phpfreaks.com/topic/177415-solved-need-help-with-this-simple-registration-script-please/#findComment-935465 Share on other sites More sharing options...
silverglade Posted October 12, 2009 Author Share Posted October 12, 2009 AWESOME PFMaBiSmAd !!!!! i also forgot to echo my table. now it echos it but it displays everyone's registration information the way its set up now. LOL. oh well. thank you. derek Quote Link to comment https://forums.phpfreaks.com/topic/177415-solved-need-help-with-this-simple-registration-script-please/#findComment-935468 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.