Reply
can not update password in databse..???
Old 10-31-2009, 10:15 AM can not update password in databse..???
Novice Talker

Posts: 8
Name: Nur Syazwani
Trades: 0
why i cannot update password in the database...below is showing the my code for update password...please help me..

<?php
session_start();

if(!(isset($_SESSION['valid'])))
{

}
if(isset($_POST['submit']) && $_POST['pass1']==$_POST['pass2'])
{
$db=mysql_connect("localhost","root","");
mysql_select_db("jmti",$db);
$password=$_POST['password'];
$username=$_SESSION['username'];
$sql="update tbuser set password='$password'where username='$username'";
$result=mysql_query($sql);
echo "succesfully updated";
echo "</br>";
}
elseif($_POST['pass1']!=$_POST['pass2'])
{
echo "both password filled are not same";

?>
<html>
<body>
<form method="post">
<table>
<tr>
<td>Type new password</td>
<td><input type="password" name="pass1"></td>
</tr>
<tr>
<td>Retype new password</td>
<td><input type="password" name="pass2"></td>
</tr>
<tr>
<td><input type="submit" name="submit" value="submit"></td>
</tr>
<tr>
</form>
</body>
</html>
<?php
}

else
{
?>
<html>
<body>
<form method="post">
<table>
<tr>
<td>Type new password</td>
<td><input type="password" name="pass1"></td>
</tr>
<tr>
<td>Retype new password</td>
<td><input type="password" name="pass2"></td>
</tr>
<tr>
<td><input type="submit" name="submit" value="submit"></td>
</tr>
<tr>

</table>
</form>
</body>
</html>
<?php
}
?>
syaza is offline
Reply With Quote
View Public Profile
 
 
When You Register, These Ads Go Away!
Old 10-31-2009, 10:17 AM Re: can not update password in databse..???
chrishirst's Avatar
Super Moderator

Posts: 22,276
Location: Blackpool. UK
Trades: 0
And the error message is???
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
Growing old is mandatory - Growing up is optional
Code Samples | People Counting System | Bits & Bobs
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 10-31-2009, 11:46 AM Re: can not update password in databse..???
Novice Talker

Posts: 8
Name: Nur Syazwani
Trades: 0
the password can not update in the databse...
syaza is offline
Reply With Quote
View Public Profile
 
Old 10-31-2009, 12:02 PM Re: can not update password in databse..???
Super Talker

Posts: 109
Name: Not Telling
Trades: 0
Here ya go:

PHP Code:
<?php 
error_reporting
(E_ALL); 
$config "inc/config.php"
if(
file_exists($config)) 

    include(
$config); 

else 

    die(
"config dir incorrect<br />"); 


if (isset(
$_POST['chpass']))  

    
$newPass $_POST['newpass']; 
    
$veri $_POST['veri']; 
    
$strcmp strcmp($newPass$veri);
    if(
$strcmp == 0)
    {
        
$result mysql_query("SELECT * FROM `admin` WHERE id = '1'"); 
        if(
mysql_num_rows($result)!=0
        { 
            
$row mysql_fetch_array($result); 
            
$pass $row['password']; 
            if(
strcmp($_POST['oldpass'], $pass) == 0)  
            { 
                
$newPass strip_tags(mysql_real_escape_string($newPass)); 
                
mysql_query("UPDATE `admin` SET password = '$newPass' where id = '1'"); 
                echo 
"Your Password has been changed. Please out to verify the password change. <br> <hr>"
            } 
            else 
            { 
                echo 
"The old password is incorrect. Please try again. <br> <hr>";     
            } 
        } 
        else 
        { 
            echo 
"Could not find the member you are changing the password for. <br> <hr>";     
        } 
    }
    else
    {
        echo 
"Your new password's do not match. Please try again.<br> <hr>";
    }


?>
Code:
<form action="accounts-password.php" method="POST"> 
<input type="hidden" name="member" value="1" /> 

<span style="float: left;">
Your old Password:
</span>
<span style="float: right;">
<input size="40" type="password" name="oldpass">
</span>
<br><br>
<hr>

<span style="float: left;">
Your New Password:
</span>
<span style="float: right;">
<input size="40" type="password" name="newpass">
</span>
<br><br>

<span style="float: left;">
Re-Type Your New Password:
</span>
<span style="float: right;">
<input size="40" type="password" name="veri">
</span>



<br><br>
<hr>


<center>
<input name="chpass" id="submit" value="Change Password" type="submit">
</center>

</form>
I used it for my admin area I made.

---

It has verification and u have to type in the old one.

---

Also will it be for 1 user or for many?
sith717 is offline
Reply With Quote
View Public Profile
 
Old 10-31-2009, 02:44 PM Re: can not update password in databse..???
Novice Talker

Posts: 8
Name: Nur Syazwani
Trades: 0
where the mistake in my code for change password?
syaza is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to can not update password in databse..???
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 



Page generated in 0.14047 seconds with 13 queries