Jump to content

Change Email Help Please


porko2004

Recommended Posts

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&#160; <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
Share on other sites

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
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.