Jump to content

"UPDATE" MySQL information code problem[-SOLVED-]


techiefreak05

Recommended Posts

I have a change email form .. and its not working ... and yet i dont get an error, what wrong with this code??

[code]<?php
$db_host = "localhost";
$db_user = "zyco";
$db_pwd = "*******";
$db_name = "zyco_zycologin";
mysql_connect($db_host, $db_user, $db_pwd);
mysql_select_db($db_name);
?>
<center>
<?php
if($_POST['updateI']){
$sql = "UPDATE users WHERE username = '$_SESSION[username]' email = '$_POST[emailNew]' LIMIT 1";
$query = mysql_query($sql);
}
?>
<form action="" method="post">
      <table align="center" border="0" cellspacing="0" cellpadding="3">
<tr><td ><font color=black>E-mail:</font></td><td><input type="text" name="emailNew" maxlength="30"></td></tr>
<tr><td colspan="2" align="right"><input type="submit" name="updateI" value="Update"></td></tr>
</table>
    </form>
</center>
[/code]
Try it like this.

[code]
<?php
if($_POST['updateI']){
$username = $_SESSION['username'];
$new_email = mysql_real_escape_string(trim($_POST['emailNew']));

$sql = "UPDATE `users` SET `email` = '$new_email' WHERE `username` = '$username'";
$query = mysql_query($sql) or die(mysql_error());
}
?>
<form action="" method="post">
      <table align="center" border="0" cellspacing="0" cellpadding="3">
<tr><td ><font color=black>E-mail:</font></td><td><input type="text" name="emailNew" maxlength="30"></td></tr>
<tr><td colspan="2" align="right"><input type="submit" name="updateI" value="Update"></td></tr>
</table>
    </form>
</center>[/code]

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.