Hi there,
I am trying to update mySql table when form submited.
I fill data in the form, but nothing happens.
Can anybody help me please ?
Thank you,
My code:
<?php include("theader.php"); ?>
<?php
if (isset($_POST['submit'])){
$error = false;
$errormessage = "";
if (strlen($email) < 1) {
$error = true;
$errormessage .= "<li><b>Error. No email specified.</b><br>\n";
}
if ($error) {
$errormessage .= "<br>Please try again<br>\n";
$msg = $errormessage;
} else {
$query2 = "update contact set first='$_POST[first]',last='$_POST[last]', phone='$_POST[phone]',mobile='$_POST[mobile]',fax='$_POST[fax]',email='$_POST[email]',web='$_POST[web]' where id='$_GET[id]'";
$mysqlresult2 = mysql_query($query2);
$msg = "Data saved.\n";
}
}
?>
<TD align="left" valign="top" >
<table border="0" cellpadding="0" cellspacing="0" width="447">
<tr>
</tr>
<tr>
<td background="text/text_r2_c1.gif"> </td>
<td><span class="style1">
<?
if (logincheck($uid, $upwd)) {
$query = "Select * from contacts where id='$_GET[id]'";
$mysqlresult = mysql_query($query);
echo mysql_error();
echo "<span class=\"style1\">User settings</span>\n";
while($row = mysql_fetch_array($mysqlresult)){
echo "<form action=personal.php?id=$uid method=post > \n";
echo "<table width='428' border='0'> <tr><td>Ime: </td>\n";
echo "<td width='236'><input type='text' name='first' value='$row[first]'></td></tr> <tr>\n";
echo "<td>Prezime:</td><td><input type='text' name='last' value='$row[last]'></td></tr> <tr>\n";
echo "<td>Telefon:</td> <td><input type='text' name='phone' value='$row[phone]'></td> </tr><tr>\n";
echo "<td>Mobilni:</td><td><input type='text' name='mobile' value='$row[mobile]'></td></tr><tr>\n";
echo "<td>Fax:</td><td><input type='text' name='fax' value='$row[fax]'></td></tr><tr>\n";
echo "<td>Email:</td> <td><input type='text' name='email' value='$row[email]'></td></tr> <tr>\n";
echo "<td>Web:</td> <td><input type='text' name='web' value='$row[web]'></td></tr><tr><td></td>\n";
echo "<td><input type='submit' name='submit' value='Submit changes'></td></tr></table></form>\n";
}
} else {
printf("<font size=2 face='Arial, Helvetica, sans-serif'><br>You will need to login</font>");
}
?>
</span></td>
<td background="text/text_r2_c3.gif"> </td>
<td> </td>
</tr>
<tr>
<td background="text/text_r2_c1.gif"> </td>
<td><p><span class="style1"><?php printf($msg); ?></span>
</p> </td>
<td background="text/text_r2_c3.gif"> </td>
<td><img src="text/spacer.gif" width="1" height="61" border="0" alt=""></td>
</tr>
<tr>
<td><img name="text_r3_c1" src="text/text_r3_c1.gif" width="7" height="19" border="0" alt=""></td>
<td background="text/text_r3_c2.gif"> </td>
<td><img name="text_r3_c3" src="text/text_r3_c3.gif" width="6" height="19" border="0" alt=""></td>
<td><img src="text/spacer.gif" width="1" height="19" border="0" alt=""></td>
</tr>
</table>
<p> </p></TD>
<?php include("tfooter.php"); ?>