techiefreak05 Posted August 14, 2006 Share Posted August 14, 2006 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] Link to comment https://forums.phpfreaks.com/topic/17473-update-mysql-information-code-problem-solved/ Share on other sites More sharing options...
tomfmason Posted August 14, 2006 Share Posted August 14, 2006 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] Link to comment https://forums.phpfreaks.com/topic/17473-update-mysql-information-code-problem-solved/#findComment-74347 Share on other sites More sharing options...
techiefreak05 Posted August 14, 2006 Author Share Posted August 14, 2006 THANKS !!! IT WORKED!! YES! thanks a lot!! you saved me hours of frustration.. lol as simple a code as that was.. I understand MySQL, just dont completely get the coding. THANKS again! Link to comment https://forums.phpfreaks.com/topic/17473-update-mysql-information-code-problem-solved/#findComment-74349 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.