I have a members database that I need to allow the members to update thier information. I have a form that displays the members information pulled from the database based on the user logged in. If I make a change to any of the fields and click on the update it displays the new information but does not update the database.
<?php
session_start();
if (@$_SESSION['auth'] != "yes")
{
header("Location: Login.php");
exit();
}
?>
<html>
<head><title>Member information</title></head>
<body>
<?php
include("member.inc");
$labels = array( "firstName"=>"First Name:",
"lastName"=>"Last Name:",
"street"=>"Street Address:",
"city"=>"City:",
"state"=>"State:",
"zip"=>"Zipcode:",
"phone"=>"Phone:",
"email"=>"Email Address:");
$connection = mysql_connect($host,$user,$password)
or die ("Couldn't connect to server");
$db = mysql_select_db($database,$connection)
or die ("Couldn't connect to database");
$query = "SELECT * FROM Member
WHERE loginName='$logname'";
$result = mysql_query($query)
or die ("Couldn't execute query");
$row = mysql_fetch_array($result);
echo "<p align='center'>
<h1 align='center'>Welcome $logname</h1>\n";
echo "<br><p align='center'>
<font size='+1'><b>Please check the information below
and change any information that is incorrect.</b></font>
<hr>";
echo "<form action='Processmemberinfo.php' method='POST'>
<table width='95%' border='0' cellspacing='0'
cellpadding='2'>\n";
foreach($labels as $field=>$label)
{
echo "<tr>
<td align='right'> <B>{$labels[$field]} </br></td>
<td><input type='text' name='$field'
value='$row[$field]' size='65' maxlength='65'>
</td>
</tr>";
}
echo "</table>
<div align='center'><p><input type='submit'
value='Update Member Information'> </p></div>
</form>";
exit();
{
include("member.inc");
$connection = mysql_connect($host,$user,$password)
or die ("Couldn't connect to server");
$db = mysql_select_db($database,$connection)
or die ("Couldn't connect to database");
$query = "UPDATE Member SET firstName='$firstName', lastName='$lastName',
street='$street', city='$city', state='$state', zip='$zip',
phone='$phone', email='$email' WHERE loginName='$logname'";
$result = mysql_query($query)
or die ("Couldn't execute query.".mysql_error());
echo "Information has been updated.<br>";
}
?>
</body></html>