Hiya,
I've made this script to when you go to the page you can add a new record then it comes up with a check details page this all works fine, but on the check records part the data comes up in a form so you can edit the fields when you have made any changes it creates a new record and does not update the existing one could some one tell me why please?
Code is below thanks
Peter
<?
$db = mysql_connect("localhost","root","password");
mysql_select_db("rentdb",$db);
if ($submit){
$rs = mysql_query("INSERT INTO app (name,company,address,suburb,state,post,areacode,phone,faxareacode,fax,email) VALUES ('$name','$company','$address','suburb','$state','$post','$areacode','$phone','$faxareacode','$fax','$email')");
if($name){
$rs = mysql_query("UPDATE app SET name='$name',company='$company',address='$address',suburb='$suburb',state='$state',post='$post',areacode='$areacode',phone='$phone',faxareacode='$faxareacode',fax='$fax',email='$email' WHERE name=$name");
}
$result = mysql_query($rs);
echo "<p><p>";
echo "<TABLE BORDER=0 WIDTH=800 >";
echo "<tr><td>";
?>
<table border="0" width="650" align="center">
<tr>
<td>
Please Check your information, and change any details that are not correct, then click update.<br>
if this information is correct <a href="thankyou.html">click here</a>.<p>
</td>
</tr>
</table>
<form name=check method="POST" action="">
<input type="hidden" name="name" value="<?=$name?>">
<?
echo "<TABLE BORDER=0 CELLPADDING=3 CELLSPACING=1 WIDTH=500 BGCOLOR=#990033 ALIGN=CENTER>\n";
echo "<tr BGCOLOR=#CCCCCC>\n";
echo "<td colspan=2 bgcolor=#006699><div align=center>\n";
echo "The information you entered is:\n";
echo "</div></td></tr>\n";
echo "<tr BGCOLOR=#CCCCCC>\n";
echo "<td bgcolor=#006699 width=122>\n";
echo "Your Name:</td>\n";
echo "<td><div align=center><input type=text name=name value='$name'></td></tr>\n";
echo "<tr BGCOLOR=#CCCCCC>\n";
echo "<td bgcolor=#006699 width=122>\n";
echo "Company:</td>\n";
echo "<td><div align=center><input type=text name=company value='$company'></td></tr>\n";
echo "<tr BGCOLOR=#CCCCCC>\n";
echo "<td bgcolor=#006699 width=122>\n";
echo "Address:</td>\n";
echo "<td><div align=center><input type=text name=address value='$address'></td></tr>\n";
echo "<tr BGCOLOR=#CCCCCC>\n";
echo "<td bgcolor=#006699 width=122>\n";
echo "Suburb:</td>\n";
echo "<td><div align=center><input type=text name=suburb value='$suburb'></td></tr>\n";
echo "<tr BGCOLOR=#CCCCCC>\n";
echo "<td bgcolor=#006699 width=122>\n";
echo "State:</td>\n";
echo "<td><div align=center><input type=text name=state value='$state'></td></tr>\n";
echo "<tr BGCOLOR=#CCCCCC>";
echo "<td bgcolor=#006699 width=122>";
echo "Post Code:</td>\n";
echo "<td><div align=center><input type=text name=post value='$post'></td></tr>\n\n";
echo "<tr BGCOLOR=#CCCCCC>\n";
echo "<td bgcolor=#006699 width=122>\n";
echo "Phone:</td>\n";
echo "<td><div align=center><input type=text name=areacode SIZE=2 MAXLENGTH=2 value='$areacode'><input type=text name=phone value='$phone'></td></tr>\n";
echo "<tr BGCOLOR=#CCCCCC>\n";
echo "<td bgcolor=#006699 width=122>\n";
echo "Fax:</td>\n";
echo "<td><div align=center><input type=text name=faxareacode SIZE=2 MAXLENGTH=2 value='$faxareacode'><input type=text name=fax value='$fax'></td></tr>\n";
echo "<tr BGCOLOR=#CCCCCC>\n";
echo "<td bgcolor=#006699 width=122>\n";
echo "Email Address:</td>\n";
echo "<td><div align=center><input type=text name=email value='$email'></td></tr>\n";
echo "<tr><td colspan=2 bgcolor=#CCCCCC><div align=center><input type=submit name=submit value=update></div></td>\n</tr>\n</table>\n</form><p>\n";
?>
* Please Include your area code with your phone & fax number.
<?
echo "</td></tr></table>\n";
} else {
?> <table width="800" border="0">
<tr>
<td height="485">
<form method="post" action="" name="app">
<!-- <input type="hidden" name="id" value="<?=$id?>"> -->
<blockquote>
<table width="700" border="0">
<tr>
<td width="64" height="2">Name:</td><td width="626" height="2">
<input type="text" name="name">
</td>
</tr>
<tr>
<td width="64" height="2">Company:</td>
<td width="626" height="2">
<input type="text" name="company">
</td>
</tr>
<tr> <td width="64" height="2"> Address: </td>
<td width="626" height="2">
<input type="text" name="address" size="35"> Suburb: <input type="text" name="suburb"><br> State:
<select name="state" size="1">
<option value="Canberra">ACT</option>
<option value="New South Wales">NSW</option>
<option value="Northern Territory">NT</option> <option value="Queensland">QLD</option>
<option value="South Australia">SA</option>
<option value="Tasmania">TAS</option>
<option value="Victoria">VIC</option>
<option value="Western Australia">WA</option>
</select>
Post Code: <input type="text" name="post" size="4"> </td></tr>
<tr><td width="64" height="2">Phone:</td>
<td width="626" height="2">
<SELECT NAME="areacode">
<OPTION VALUE="02">02</OPTION>
<OPTION VALUE="03">03</OPTION>
<OPTION VALUE="07">07</OPTION>
<OPTION VALUE="08">08</OPTION>
</SELECT>
<input type="text" name="phone" size="10" maxlength="9">
</td></tr> <tr> <td width="64" height="2">Fax:</td><td width="626" height="2">
<SELECT NAME="faxareacode">
<OPTION VALUE="02">02</OPTION>
<OPTION VALUE="03">03</OPTION>
<OPTION VALUE="07">07</OPTION>
<OPTION VALUE="08">08</OPTION>
</SELECT>
<input type="text" name="fax"> </td></tr>
<tr> <td width="64" height="2">Email:</td><td width="626" height="2">
<input type="text" name="email"> </td></tr> <tr>
<td width="64" height="2"> </td><td width="626" height="2">
<input type="submit" name="submit" value="Submit"> <input type="reset" name="submit2" value="Clear">
<p>
* Please Include your area code with your phone & fax number.
</td>
</tr>
</table>
</blockquote>
</form>
<?
}
?>