Topic: Basic Mysql update script?
I'm trying to create a myaccount.php file to let users (members in my heavily customized PunBB) update their personal information.
I don't know PHP and can't get this to work:
if (empty($_POST['cmdUpdate']))
{
$sql = "UPDATE members SET firstname='$txtfirstname', surname='$txtsurname' WHERE id = '.$pun_user['id']'";
$result = mysql_query($sql) or die("SQL Update failed");
}
$result = $db->query('SELECT * FROM members WHERE id = '.$pun_user['id']) or error('Unable to fetch user data', __FILE__, __LINE__, $db->error());
$row = $db->fetch_assoc($result);
?>
<form method="post" action="<?php echo $PHP_SELF;?>">
<p>First Name:<input type="text" name="txtfirstname" size="30" value="<? echo $row['firstname']; ?>" />
<p>Last name:<input type="text" name="txtsurname" size="30" value="<? echo $row['surname']; ?>" />
<p><input type="Submit" value="Update" name="cmdUpdate" />
</form>
I keep getting Syntax errors for this part: "if (empty ... Update failed");}". There's lots of regular punbb above this code and the rest works, so ignore those issues.
Any suggestions? If I can get some basic principles to work I should be able to figure out the rest.
And please don't tell me I should just use profile.php....