For some reason clients can view their details but can't update them. I get no error messages.
This is the relevant part of the edit.php:
<?
require("back.php");
$login_check = is_logged();
if (!$login_check) {
?>
(HTML error code)
<?
exit;
}
if (empty($firstname) || empty($lastname) || empty($email) || empty($company) || empty($position) || empty($address1) || empty($address2) || empty($suburb) || empty($state) || empty($postcode) || empty($country) || empty($phone) || empty($fax) || empty($ip)) {
list($firstname, $lastname, $email, $company, $position, $address1, $address2, $suburb, $state, $postcode, $country, $phone, $fax, $ip) = edit_retrieve($login_check[1]);
?>
<HEAD><TITLE>Commerce - Admin : Edit</TITLE></HEAD>
<BODY>
<form action=edit.php METHOD=POST>
<p align="center"><table width="45%" border="0" cellspacing="0" cellpadding="0" bgcolor="#3333FF">
<tr bgcolor="#FFFFFF"></p>
<p align="center"><font face="Arial, Helvetica, sans-serif" size="4" color="#HH66CC">Edit Details</font></p>
<td><font face="Arial, Helvetica, sans-serif" size="2">First Name : </font></td>
<td><font face="Arial, Helvetica, sans-serif" size="2">
<input type=text name=firstname value="<? echo $firstname; ?>">
</font></td>
</tr>
etc...
<input type=hidden name=ip value="<? echo $ip; ?>">
<tr bgcolor="#FFFFFF">
<td width="50%"><font face="Arial, Helvetica, sans-serif" size="2">Username
: </font></td>
<td><font face="Arial, Helvetica, sans-serif" size="2">
<?php echo $login_check[0]; ?>
</font></td>
</tr>
<td bgcolor="#FFFFFF"> </td><td bgcolor="#FFFFFF"><br><input type=submit value="Edit Your Details"></td></tr>
</table></form>
</BODY>
<?
exit;
}
$update = edit($login_check[1], $firstname, $lastname, $email, $company, $position, $address1, $address2, $suburb, $state, $postcode, $country, $phone, $fax, $ip);
if ($update == 2) {
header("Location: admin.php");
exit;
}
?>
(HTML Error Code
<div align="center">
<p><b><font face="Arial, Helvetica, sans-serif" size="4" color="#999933">Error
: <?php echo $update; ?></font></b></p>)
</div>
</body>
The required back.php relevant area looks like this:
function edit_retrieve ($id) {
global $server, $db_user, $db_pass, $database;
mysql_connect($server, $db_user, $db_pass);
mysql_select_db($database);
$query = mysql_query("select * from data where id = '$id'");
mysql_close();
list($id, $firstname, $lastname, $email, $company, $position, $address1, $address2, $suburb, $state, $postcode, $country, $phone, $fax, $ip) = mysql_fetch_row($query);
$retval = array($firstname, $lastname, $email, $company, $position, $address1, $address2, $suburb, $state, $postcode, $country, $phone, $fax, $ip);
return $retval;
}
function edit ($id, $firstname, $lastname, $email, $company, $position, $address1, $address2, $suburb, $state, $postcode, $country, $phone, $fax, $ip) {
global $server, $db_user, $db_pass, $database;
if (!eregi("^([a-z0-9]+)([._-]([a-z0-9]+))*[@]([a-z0-9]+)([._-]([a-z0-9]+))*[.]([a-z0-9]){2}([a-z0-9])?$", $email)) {
$error = "Email address format incorrect. Correct format must look like name@domain.ext or name@domain.ext.ct";
return $error;
}
if (!eregi("^[a-z ]+$", $firstname)) {
$error = "First Name contains a character besides (a-z).";
return $error;
}
mysql_connect($server, $db_user, $db_pass);
mysql_select_db($database);
$query = mysql_query("select login.id from login, data where data.email = '$email'");
$result = mysql_num_rows($query);
if ($result > 0) {
mysql_close();
list($userid) = mysql_fetch_row($query);
if ($userid != $id) {
$error = "A user with that email already exists";
return $error;
}
}
$query=mysql_query("update data set firstname = '$firstname', lastname = '$lastname', email = '$email', company = '$company', position = '$position', address1 = '$address1', address2 = '$address2', suburb = '$suburb', state = '$state', postcode = '$postcode', country = '$country', phone = '$phone', fax = '$fax', ip = '$ip' where id = '$id'");
mysql_close();
return 2;
}
I apologise for the length but I don't have enough knowledge to find out what is going wrong.
Any help would be appreciated.