Jump to content

Change Email Help Please


porko2004

Recommended Posts

i have been working on a change email page in php but i cant get it working correctly can someone please help me. I need it to check MYSQL and look at 5 fields and if all data its correct as on db then email will change can anyone help me. The script it below.

 

 

<?php

$connection=mysql_connect("localhost","root","simles");

$db=mysql_select_db("coproj",$connection);

$result = mysql_query("select Email from Accounts where AccountID='$_POST[username]'");

if(!$result)

{

echo "AccountID does not exist.";

echo '<br><br><a href="email.php">Return to password page</a>';

}

 

 

else

if (!$_POST['username'] )

{

die('You did not fill the Account ID field <br><br> <a href="email.php">Return to change password page</a>');

}

else

if (!$_POST['identification'] )

{

die('You did not fill the Identification No field <br><br> <a href="email.php">Return to change password page</a>');

}

else

if (!$_POST['answer'] )

{

die('You did not fill the Answer field  <br><br> <a href="email.php">Return to change password page</a>');

}

else

if (!$_POST['question'] )

{

die('You did not fill the Secret Question field  <br><br> <a href="email.php">Return to change password page</a>');

}

else

if (!$_POST['oldemail'] )

{

die('You did not fill the Old Email field  <br><br> <a href="email.php">Return to change password page</a>');

}

else

if (!$_POST['newemail'] )

{

die('You did not fill the New Email field <br><br> <a href="email.php">Return to change password page</a>');

}

else

if (!$_POST['newemail2'] )

{

die('You did not fill the Re-type New Email field <br><br> <a href="email.php">Return to change password page</a>');

}

 

else

if (!$_POST['oldemail']!= mysql_result($result, 0))

{

echo "email invalid.";

echo '<br><br><a href="email.php">Return to email page</a>';

}

else if($_POST['newemail']!=$_POST['newemail2'])

{

echo "Your emails don't match.";

echo '<br><br><a href="email.php">Return to change password page</a>';

}

else

 

$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]'");

if($sql)

{

echo "You have successfully changed your email.";

echo '<br><br><a href="index.php">Return to main page</a>';

}

?>

Link to comment
Share on other sites

$result = mysql_query("select Email from Accounts where AccountID='$_POST[username]'") or die (mysql_error());

 

$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());

 

 

Link to comment
Share on other sites

Try this and see what you get I found another thing that i missed. you are not actually fetching the info from the database.

 

<?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>';
}

$accemail = mysql_fetch_row($result);

else
if (!isset($_POST['username']))
{
die('You did not fill the Account ID field <a href="email.php">Return to change password page</a>');
}
else
if (!isset($_POST['identification']))
{
die('You did not fill the Identification No field <a href="email.php">Return to change password page</a>');
}
else
if (!isset($_POST['answer']))
{
die('You did not fill the Answer field  <a href="email.php">Return to change password page</a>');
}
else
if (!isset($_POST['question']))
{
die('You did not fill the Secret Question field <a href="email.php">Return to change password page</a>');
}
else
if (!isset($_POST['oldemail']))
{
die('You did not fill the Old Email field <a href="email.php">Return to change password page</a>');
}
else
if (!isset($_POST['newemail']))
{
die('You did not fill the New Email field <a href="email.php">Return to change password page</a>');
}
else
if (!isset($_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>';
}
else if($_POST['newemail'] != $_POST['newemail2'])
{
echo "Your emails don't match.";
echo '<a href="email.php">Return to change password page</a>';
}
else

$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

<div class="style4">Change Email</div>

<div class="center_content">

<div class="news_post">

<center><br />

<br />

<table cellspacing="1" cellpadding="5">

                             

<form action="go_to_email2.php" method="POST">

<td class="list" align="right" width="242" height="1">Account

                                                              ID: 

                                </td>

<td class="list" width="252" height="1">

<input type="text" name="username" maxlength="30" />

                                </td>

 

<tr>

<td class="list" align="right" width="242" height="1">identification No. :

                                </td>

<td class="list" width="252" height="1">

<input type="text" name="identification" maxlength="30" />

                                </td>

</tr> 

<tr>

<td class="list" align="right" width="242" height="1">Secret Question:

                                </td>

<td class="list" width="252" height="1">

<input type="text" name="question" maxlength="30" />

                                </td>

</tr>       

<tr>

<td class="list" align="right" width="242" height="1">Answer:

                                </td>

<td class="list" width="252" height="1">

<input type="text" name="answer" maxlength="30" />

                                </td>

</tr>       

<tr>

<td class="list" align="right" width="242" height="1">Old Email:

                                </td>

<td class="list" width="252" height="1">

<input type="email" name="oldemail" maxlength="30" />

                                </td>

</tr>

<tr>

<td class="list" align="right" width="242" height="1">New Email:

                                </td>

<td class="list" width="252" height="1">

<input type="email" name="newemail" maxlength="30" />

                                </td>

</tr> 

<tr>

<td class="list" align="right" width="242" height="1">Re-type New Email:

                                </td>

<td class="list" width="252" height="1">

<input type="text" name="newemail2" maxlength="30" />

                                </td>

</tr>                     

 

                        <tr>

<td class="listtitle" align="center" colspan="2" height="23">

 

 

<label><button type="submit" name="submit" value="Register" >Submit</button></label>

 

</form>

 

                          </td>

                        </tr>

<tr>

 

 

</tr>

</form>

</table>

<br />

 

<a href="index.php">Return to main page</a> </center>

<p>

 </p>

</div>

</div>

</div>

 

Link to comment
Share on other sites

that page is fine, this is what I have for the 2nd page, and it works fine on my server

 

<?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 (!isset($_POST['username']))
{
die('You did not fill the Account ID field <a href="email.php">Return to change password page</a>');
}

if (!isset($_POST['identification']))
{
die('You did not fill the Identification No field <a href="email.php">Return to change password page</a>');
}

if (!isset($_POST['answer']))
{
die('You did not fill the Answer field  <a href="email.php">Return to change password page</a>');
}

if (!isset($_POST['question']))
{
die('You did not fill the Secret Question field <a href="email.php">Return to change password page</a>');
}

if (!isset($_POST['oldemail']))
{
die('You did not fill the Old Email field <a href="email.php">Return to change password page</a>');
}

if (!isset($_POST['newemail']))
{
die('You did not fill the New Email field <a href="email.php">Return to change password page</a>');
}

if (!isset($_POST['newemail2']))
{
die('You did not fill the Re-type New Email field <a href="email.php">Return to change password page</a>');
}

if ($_POST['oldemail'] != $accemail)
{
echo "email invalid.";
echo '<a href="email.php">Return to email page</a>';
die();
}

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>';
}
?>

 

you can delete the 2 echo lines once you are done with it, I just used them for testing, and it worked.

Link to comment
Share on other sites

$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());

 

this where you error is coming from.  You dont have a column username in you database.

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.