Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Closed Thread
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
View Public Profile
 
 
Register now for full access!
Old 10-31-2009, 10:17 AM Re: can not update password in databse..???
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,516
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
And the error message is???
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is online now
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
View Public Profile
 
Old 10-31-2009, 12:02 PM Re: can not update password in databse..???
Super Talker

Posts: 115
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
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
View Public Profile
 
Old 07-25-2011, 09:48 AM Re: can not update password in databse..???
lizciz's Avatar
Webmaster Talker

Posts: 744
Name: Mattias Nordahl
Location: Sweden
Trades: 0
Add a space between '$password' and where.

And lets all just hope that you're not planning on using this for any important data...
__________________
34343639363436653237373432303635373837303635363337 34323037343638363137343263323036343639363432303739 366637353366
lizciz is offline
View Public Profile Visit lizciz's homepage!
 
Old 07-25-2011, 09:58 AM Re: can not update password in databse..???
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,516
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
This was posted in 2009 Mattias.
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?

Last edited by chrishirst; 07-25-2011 at 09:59 AM..
chrishirst is online now
View Public Profile Visit chrishirst's homepage!
 
Closed Thread     « 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.67721 seconds with 12 queries