Jump to content

Recommended Posts

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>

Link to comment
https://forums.phpfreaks.com/topic/198621-cant-update-mysql-help/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.