when i click on the update link, it goes to the update page,and the form fields are supposed to have the members information side of them so that you can change the information. the fields do not do that, and i'm not sure why. the only field that shows information is the member id field.
if anyone could help me out in getting this update page to work, then that would be appreciated. here's the code i'm using below.
Code: Select all
session_start();
do_html_header('Administration');
error_reporting(E_ALL ^ E_NOTICE);
$tblname = "members";
$host="localhost";
$dbuser="mwooten1";
$dbpass="****";
$database="higgins";
mysql_connect($host,$dbuser,$dbpass);
mysql_select_db($database) or die ("Unable to select database");
$user_name = "";
$user_email = "";
$staddress = "";
$city = "";
if (isset($_POST['memberid'])){
$user_name = (isset($_POST["user_name"]) ? $_POST["user_name"] : "");
$user_email = (isset($_POST["user_email"]) ? $_POST["user_email"] : "");
$staddress = (isset($_POST["staddress"]) ? $_POST["staddress"] : "");
$city = (isset($_POST["city"]) ? $_POST["city"] : "");
if (!get_magic_quotes_gpc()) {
$user_name=addslashes($user_name);
$user_email = addslashes($user_email);
$staddress = addslashes($staddress);
$city = addslashes($city);
}
}
else
{
$memberid=(isset($_GET['id']) ? intval($_GET['id']) : "");
if ($memberid) {
$query="SELECT * FROM $tblname WHERE memberid='".$memberid."'";
$result=mysql_query($query);
$row=mysql_fetch_array($result);
if ($row) {
$user_name=$row['$user_name'];
$user_email = $row['$user_email'];
$staddress = $row['$staddress'];
$city = $row['$city'];
}
else {
$memberid="";
echo "<h3>Invalid ID</h3><a href=\"showmembers.php\">Return to Show Members</a>";
}
}
}
if (isset($_POST['submit'])) {
$sql = "UPDATE $tblname SET user_name='".$user_name."', user_email='".$user_email."', $staddress='".$staddress."', city='".$city."'";
$sql.=" WHERE memberid='".$memberid."'";
$result = mysql_query($sql) or die (mysql_error());
echo "<h3>Record Updated!!</h3><a href='showmembers.php'>Back to Show Members</a><br><br>";
}
else
{
echo "<h3>Information has not been submitted Yet!</h3><a href='showmembers.php'>Back to Show Members</a><br><br>";
}
if ($memberid) {
$table_output='<table border="0" cellspacing="2" cellpadding="2">';
$table_output.='<form action="edit2.php" method="post" enctype="multipart/form-data">';
$table_output.='<input type="hidden" name="memberid" value="'.$memberid.'">';
$table_output.='<tr>';
$table_output.='<td valign="top">ID:</td> <td><input type="text" name="memberid" disabled value="'.htmlspecialchars(stripslashes($memberid)).'">';
$table_output.='</td></tr><tr>';
$table_output.='<td valign="top">User Name:</td> <td><input type="text" name="user_name" value="'.htmlspecialchars(stripslashes($user_name)).'">';
$table_output.='</td></tr><tr>';
$table_output.='<td valign="top">User Email:</td> <td><input type="text" name="user_email" value="'.htmlspecialchars(stripslashes($user_email)).'">';
$table_output.='</td></tr><tr>';
$table_output.='<td valign="top">Street Address:</td><td><input type="text" name="staddress" value="'.htmlspecialchars(stripslashes($staddress)).'">';
$table_output.='</td></tr><tr>';
$table_output.='<td valign="top">City:</td><td><input type="text" name="city" value="'.htmlspecialchars(stripslashes($city)).'">';
$table_output.='</td></tr>
$table_output.='<tr>';
$table_output.='<td></td><td><input type="submit" name="submit" value="submit"><input type="reset" /></td>';
$table_output.='</tr>';
$table_output.='</form></table>';
echo $table_output;
}