ronnie123 Posted April 15, 2010 Share Posted April 15, 2010 hi i am trying to update mysql database but no matter what i do it just wont update. really hope you can help here is my code: mysql_connect ("localhost", "xxxxxx","xxxxxx")or die (mysql_error()); mysql_select_db ("computer_customers")or die (mysql_error()); // ***** This part will process when you Click on "Submit" button ***** // Check, if you clicked "Submit" button if($_POST['Submit']){ // Get parameters from form. $Forename=$_POST['Forename']; $Surname=$_POST['Surname']; $Email=$_POST['Email']; $Username=$_POST['Username']; $Password=$_POST['Password']; // Do update statement. mysql_query("UPDATE members SET Forename='$Forename', Surname='$Surname', Email='$Email', Username='$Username', Password='$Password' where ID='$ID'"); // Re-direct this page to s2.php. header("location:s2.php"); exit; } // ************* End update part ************* // *** Select data to show on text fields in form. *** // Get id parameter (GET method) from select.php $ID=$_GET['ID']; // Get records in all columns from table where column id equal in $id and put it in $result. $result=mysql_query("select * from members where ID='$ID'"); // Split records in $result by table rows and put them in $row. $row=mysql_fetch_assoc($result); // Close database connection. mysql_close(); ?> <!-- END OF PHP CODES AND START HTML TAGS --> <html> <body> <!-- set this form to POST method and target this form to itself ($PHP_SELF;)--> <form id="form1" name="form1" method="post" action="<? echo $PHP_SELF; ?>"> <p>Forename : <!-- name of this text field is "name" --> <input name="Forename" type="text" id="Forename" value="<? echo $row['Forename']; ?>"/> <br /> Surname : <!-- name of this text field is "email" --> <input name="Surname" type="text" id="Surname" value="<? echo $row['Surname']; ?>"/> <br /> Email : <!-- name of this text field is "email" --> <input name="Email" type="text" id="Email" value="<? echo $row['Email']; ?>"/> <br /> Username : <!-- name of this text field is "email" --> <input name="Username" type="text" id="Username" value="<? echo $row['Username']; ?>"/> <br /> Password : <!-- name of this text field is "tel" --> <input name="Password" type="text" id="Password" value="<? echo $row['Password']; ?>"/> </p> <p> <input type="submit" name="Submit" value="Submit" /> </p> </form> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/198621-cant-update-mysql-help/ Share on other sites More sharing options...
Ken2k7 Posted April 15, 2010 Share Posted April 15, 2010 1. Please read #4 of Forum DOs in Forum DOs. It makes it easier for us to help you if you actually used those tags to post your code. Just for future reference if you expect people to read through your mess. 2. $ID is not defined in your UPDATE query. Quote Link to comment https://forums.phpfreaks.com/topic/198621-cant-update-mysql-help/#findComment-1042404 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.