Jump to content

PHP - MySQL Update ?


plodos

Recommended Posts

I have lost my record when I run the code below, all fields are empty...

 

<a href='edit.php?id={$info['person_id']}'><font color='#00AE0A'>Edit User</font> </a> 

 

$sql = "SELECT * FROM person WHERE person_id='{$_REQUEST['id']}' "; 

		$result = mysql_query($sql);
		if (!$result) {
		  echo("<p>Error performing query: " . mysql_error() . "</p>");
		  exit();
		} 

		if ($row = @mysql_fetch_array($result, MYSQL_ASSOC)) { 

		print "

		<form action='<?php echo $PHP_SELF;?>' method=\"post\">

		<table> 


		<tr>
		<td><strong>Name</strong></td> 
		<td><input type=\"text\" name=\"fname\" size=\"60\" value=\"$row[fname]\"></td> 
		</tr> 
		<tr> 
		<td><strong>Surname</strong></td> 
		<td><input type=\"text\" name=\"lname\" size=\"60\" value=\"$row[lname]\"></td> 
		</tr> 

		<tr> 
		<td><strong>Email</strong></td> 
		<td><input type=\"text\" name=\"email\" size=\"60\" value=\"$row[email]\"></td> 
		</tr> 

		<tr> 
		<td><strong>Committee</strong></td> 
		<td><input type=\"text\" name=\"committee_no\" size=\"60\" value=\"$row[committee_no]\"></td> 
		</tr> 

        <tr> 
		<td><INPUT type=\"submit\" value=\"Send\"> </td> 

		</tr> 





		</table></form>
		"; 

		} else { 
		    echo("There has been an error" . mysql_error()); 
		} 

		/* closes connection */ 




?>

<?php


   $control =  mysql_query(" UPDATE person SET fname='{$_REQUEST['fname']}' , lname='{$_REQUEST['lname']}' , email='{$_REQUEST['email']}', 
               committee_no='{$_REQUEST['committee_no']}'
               WHERE person_id='{$_REQUEST['id']}'");

	if($control)
	{
		header("Location:".$_SERVER["HTTP_REFERER"]."");
	}


?>

Link to comment
https://forums.phpfreaks.com/topic/253799-php-mysql-update/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.