Member's Acount Update!!

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Pavlos1316
Forum Newbie
Posts: 6
Joined: Mon Jun 02, 2008 4:17 am

Member's Acount Update!!

Post 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.
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Re: Member's Acount Update!!

Post 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='';
}
Pavlos1316
Forum Newbie
Posts: 6
Joined: Mon Jun 02, 2008 4:17 am

Re: Member's Acount Update!!

Post 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
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Re: Member's Acount Update!!

Post 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.
Post Reply