Jump to content

change password help?


mattm1712

Recommended Posts

 

can any1 help me this script just guves me a blank scrren i had it working then i add the bit where it tells the user there password has changed now it doesnt work  plz help

 

 

<?php

 

session_start();

 

$user = $_SESSION['user'];

 

If ($user)

 

if ($_POST['submit'])

{

 

$oldpassword = md5($_POST['oldpassword']);

$newpassword = md5($_POST['newpassword']);

$repeatnewpassword = md5($_POST['repeatnewpassword']);

 

echo "$oldpassword/$newpassword/$repeatnewpassword";

 

include 'connect.inc';

 

$queryget = mysql_query("SELECT pass FROM users WHERE name='$user'");

$row = mysql_fetch_assoc($queryget);

echo $oldpassworddb."<br>";

echo $oldpassword."<br>";

 

$oldpassworddb =$row['password'];

 

 

if ($oldpassword==$oldpassworddb)

{

if ($newpassword==$repeatnewpassword)

{

echo "pass changed";

}

else

die("pass dont  match!");

 

}

else

{

 

echo"

 

<form action='newpass.php' method='POST'>

Old password: <input type='text' name='oldpassword'><br>

New password: <input type='password' name='newpassword'><br>

Repeat password: <input type='password' name='repeatnewpassword'><br>

<input type='submit' name='submit' value='change password'>

</form>

";

}

}

?>

Link to comment
Share on other sites

<?php

session_start();

$user = $_SESSION['user'];

if ($user){

if ($_POST['submit']){

$oldpassword = md5($_POST['oldpassword']);
$newpassword = md5($_POST['newpassword']);
$repeatnewpassword = md5($_POST['repeatnewpassword']);

echo "$oldpassword/$newpassword/$repeatnewpassword";

include 'connect.inc';

$queryget = mysql_query("SELECT pass FROM users WHERE name='$user'");
$row = mysql_fetch_assoc($queryget);
echo $oldpassworddb."<br>";
echo $oldpassword."<br>";

$oldpassworddb =$row['password'];


if ($oldpassword==$oldpassworddb){

   if ($newpassword==$repeatnewpassword) {
   echo "pass changed";
   }else{
   die("pass dont  match!");
   }
   
}else{

echo "<form action='newpass.php' method='POST'>
   Old password: <input type='text' name='oldpassword'><br>
   New password: <input type='password' name='newpassword'><br>
   Repeat password: <input type='password' name='repeatnewpassword'><br>
   <input type='submit' name='submit' value='change password'>
</form>";
}
}
}
?>

Link to comment
Share on other sites

hi i try using this code but i get this error

 

Parse error: syntax error, unexpected $end in /home/sites/moseleyengineering.co.uk/public_html/matt/newpass.php  on line 45

 

normally when i get errors like this i have missed brackets out but your code looks fine

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.