peranha Posted September 14, 2008 Share Posted September 14, 2008 yeah, you have to delete the 2 echo statements out of the script I gave you. Link to comment https://forums.phpfreaks.com/topic/124135-change-email-help-please/page/2/#findComment-640948 Share on other sites More sharing options...
porko2004 Posted September 14, 2008 Author Share Posted September 14, 2008 ty very much Link to comment https://forums.phpfreaks.com/topic/124135-change-email-help-please/page/2/#findComment-640949 Share on other sites More sharing options...
peranha Posted September 14, 2008 Share Posted September 14, 2008 Yeah, mark the topic as solved if it is finished. Link to comment https://forums.phpfreaks.com/topic/124135-change-email-help-please/page/2/#findComment-640950 Share on other sites More sharing options...
porko2004 Posted September 14, 2008 Author Share Posted September 14, 2008 still an error if u incorrect data to AccoutnId, identification, answer, secretquestion, old email, new email, re-type new email no errors appears and if u leave it all blank it says email changed Link to comment https://forums.phpfreaks.com/topic/124135-change-email-help-please/page/2/#findComment-640955 Share on other sites More sharing options...
peranha Posted September 14, 2008 Share Posted September 14, 2008 Here is the code that will work to make sure every field is filled in. <?php error_reporting(E_ALL); $connection=mysql_connect("localhost","root","simles"); $db=mysql_select_db("coproj",$connection); $result = mysql_query("select Email from Accounts where AccountID='$_POST[username]'") or die(mysql_error()); if(!$result) { echo "AccountID does not exist."; echo '<a href="email.php">Return to password page</a>'; } $row = mysql_fetch_row($result); $accemail = $row[0]; echo "b" . $accemail; echo "c" . $_POST['oldemail']; if (trim($_POST['username']) == '') { die('You did not fill the Account ID field <a href="email.php">Return to change password page</a>'); } if (trim($_POST['identification']) == '') { die('You did not fill the Identification No field <a href="email.php">Return to change password page</a>'); } if (trim($_POST['answer']) == '') { die('You did not fill the Answer field  <a href="email.php">Return to change password page</a>'); } if (trim($_POST['question']) == '') { die('You did not fill the Secret Question field <a href="email.php">Return to change password page</a>'); } if (trim($_POST['oldemail']) == '') { die('You did not fill the Old Email field <a href="email.php">Return to change password page</a>'); } if (trim($_POST['newemail']) == '') { die('You did not fill the New Email field <a href="email.php">Return to change password page</a>'); } if (trim($_POST['newemail2']) == '') { die('You did not fill the Re-type New Email field <a href="email.php">Return to change password page</a>'); } else if ($_POST['oldemail'] != $accemail) { echo "email invalid."; echo '<a href="email.php">Return to email page</a>'; die(); } else if($_POST['newemail'] != $_POST['newemail2']) { echo "Your emails don't match."; echo '<a href="email.php">Return to change password page</a>'; die(); } $sql=mysql_query("UPDATE Accounts SET email='$_POST[newemail]' where Identification='$_POST[identification]' AND Answer='$_POST[answer]' AND SecretQuestion='$_POST[question]' AND username='$_POST[username]'") or die(mysql_error()); if($sql) { echo "You have successfully changed your email."; echo '<a href="index.php">Return to main page</a>'; } ?> Link to comment https://forums.phpfreaks.com/topic/124135-change-email-help-please/page/2/#findComment-641228 Share on other sites More sharing options...
porko2004 Posted September 14, 2008 Author Share Posted September 14, 2008 Almost done only 1 more error. when u enter data if u enter right accountId and email it says "You have successfully changed your email.Return to main page" no mater if the rest is incorrect. Link to comment https://forums.phpfreaks.com/topic/124135-change-email-help-please/page/2/#findComment-641579 Share on other sites More sharing options...
peranha Posted September 14, 2008 Share Posted September 14, 2008 thats because you are not checking the database to make sure that the info matches it. you will have to do something similar to this for all fields else if ($_POST['oldemail'] != $accemail) { echo "email invalid."; echo '<a href="email.php">Return to email page</a>'; die(); } Link to comment https://forums.phpfreaks.com/topic/124135-change-email-help-please/page/2/#findComment-641583 Share on other sites More sharing options...
porko2004 Posted September 14, 2008 Author Share Posted September 14, 2008 do it leave it the same format for this $accemail = $row[0]; Link to comment https://forums.phpfreaks.com/topic/124135-change-email-help-please/page/2/#findComment-641584 Share on other sites More sharing options...
peranha Posted September 14, 2008 Share Posted September 14, 2008 yes you would $accemail = $row[0]; $accname = $row[1]; etc. row[1], may not be the name, not sure how your database is set up. Link to comment https://forums.phpfreaks.com/topic/124135-change-email-help-please/page/2/#findComment-641586 Share on other sites More sharing options...
peranha Posted September 14, 2008 Share Posted September 14, 2008 Also you need to change you query to $result = mysql_query("select Email, user, etc... from Accounts where AccountID='$_POST[username]'") or die(mysql_error()); from $result = mysql_query("select Email from Accounts where AccountID='$_POST[username]'") or die(mysql_error()); Link to comment https://forums.phpfreaks.com/topic/124135-change-email-help-please/page/2/#findComment-641587 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.