Page 1 of 1

Member's Acount Update!!

Posted: Tue Jun 10, 2008 11:58 am
by Pavlos1316
Hi.. Note that I am quite new at this :)

What I try to do is to give the option to members to update/change their password or email.

How do I tell when nothing is entered in password field, lets say, not to POST anything.

The code below checks if username and password are filled but it always POST the new password even if you don't enter anything
plus I don't get the email in my db.

If I remove md5 from password fix the problem (doesn't post anything if empty) but I need the encryption.

Code: Select all

 
$E_Mail=$_POST['E_Mail'];
$Username=$_POST['Username'];
$Password=md5$_POST['Password']);
$New_Password=md5($_POST['New_Password']);
 
if (!($Username && $Password)) {include 'update account_members.php';
echo "<center><font color=#FF0000><font size=4><font weight=bold>Username & Password are REQUIRED!</font></font></font></center>";
 
}
 
$result = mysql_query("SELECT Password FROM Register WHERE Username='$Username'");
 
 if(!$result){
include 'update account_members.php';
echo "<center>Invalid Username</center>";
  }
  else
 
  if($Password!= mysql_result($result, 0)){
include 'update account_members.php';
echo "<center>Invalid Password</center>";
  }
 
if ($New_Password>0)
      $sql=mysql_query("UPDATE Register SET Password='$New_Password' WHERE Username='$Username'");
    if(sql)
 
if ($E_Mail>0)
  $sql=mysql_query("UPDATE Register SET E_Mail='$E_Mail' WHERE Username='$Username'");
    if(sql)
    {
      echo "<p>&nbsp;</p><p>&nbsp;</p><center><p>Update Successful!</p></center>";
}   
 
:banghead: Thank you.

Re: Member's Acount Update!!

Posted: Tue Jun 10, 2008 12:18 pm
by superdezign
The md5() of an empty string still results in a string. You have to check if the password is empty first.

Code: Select all

if (!empty($_POST['Password'])) {
  $Password=md5($_POST['Password']);
} else {
  $Password='';
}

Re: Member's Acount Update!!

Posted: Tue Jun 10, 2008 12:33 pm
by Pavlos1316
now I get this so I can't test it

syntax error, unexpected '}' in /home/sonophoe/public_html/Update Account_members/update account.php on line 77

Re: Member's Acount Update!!

Posted: Tue Jun 10, 2008 1:07 pm
by superdezign
Pavlos1316 wrote:syntax error, unexpected '}' in /home/sonophoe/public_html/Update Account_members/update account.php on line 77
... That means you have an extra '}' in your code. Match up your braces.