473,486 Members | 2,243 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

changing password in php

6 New Member
i have a code in php that changes password. it runs smoothly no errors, but the question is it does not update the passoord on the database??

here is the form $s is the session ID

Expand|Select|Wrap|Line Numbers
  1. <?php echo"
  2. <form action = \"chpw.php?d='$s'\" method = 'POST'>
  3. NEW PASSWORD: <input type='text' name='pass'>
  4. <br/>
  5. <input type='submit' value='Submit Password'><br/>
  6. </form>"; ?>
  7.  

here is the script that updates

Expand|Select|Wrap|Line Numbers
  1. <?php
  2.  
  3. //$password = md5($_POST['pass']);
  4. //$s=$_GET['d'];
  5. //$s=$_POST['id'];
  6.  
  7. if(md5($_POST['pass'])== ''){
  8. echo ('invalid password');
  9. }else
  10. $sql="UPDATE account SET Password='".md5($_POST['pass'])."' WHERE StudId='".$_GET['d']."'";
  11. $result=mysql_query($sql);
  12.     if (!$result)
  13.         die('Error: ' . mysql_error());
  14.  
  15. echo "Password Changed Successfully!<br><br>\n";
  16. header('location: pwlogout.php');
  17. exit();
  18.  
  19. ?>
  20.  
  21.  
i have tried anything and still to no avail please help thank you
Apr 4 '10 #1
2 2208
chathura86
227 New Member
im not sure what you meant by

here is the form $s is the session ID
is it the PHP session id? if so you are using the php session id as the
StudId. so probably that is not right.

and it is not ok and (not useful) to echo something before the header()
so remove the header()
Expand|Select|Wrap|Line Numbers
  1. echo "Password Changed Successfully!<br><br>\n";
  2. header('location: pwlogout.php');
  3. exit();
  4.  
and your if condition is not properly written

do not check the md5 converted string is empty because it will never be.

and the else condition is not well planned. use { (curly braces) properly



anyway please edit you script in the following way

Expand|Select|Wrap|Line Numbers
  1. <?php
  2.  
  3. //$password = md5($_POST['pass']);
  4. //$s=$_GET['d'];
  5. //$s=$_POST['id'];
  6.  
  7. if($_POST['pass']== '')
  8. {
  9.     echo ('invalid password');
  10. }
  11. else
  12. {
  13.     $sql="UPDATE account SET Password='".md5($_POST['pass'])."' WHERE StudId='".$_GET['d']."'";
  14.  
  15.     echo $sql;
  16.  
  17.     $result=mysql_query($sql);
  18.     if (!$result)
  19.         die('Error: ' . mysql_error());
  20.  
  21.     echo "Password Changed Successfully!<br><br>\n";
  22.     //header('location: pwlogout.php');
  23.     exit();
  24. }
  25. ?>
  26.  
and check the sql which was generated, see if all the variables are
replaced properly and the way you wanted

paste the result here if you can so i can analyse it.

Regards
Chathura Bamunusinghe
Apr 4 '10 #2
tomex
6 New Member
Your right i should not use the session[member_if] thanks by the way you did a pretty good help. More power
Apr 6 '10 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

4
3833
by: ecPunk | last post by:
Hi, We have a web application where we want a user to be able to change his/her password if the password has expired but we are unable to do this with ASP (at the moment) because we can't log...
1
6202
by: patrickshroads | last post by:
I just started a new job and no one seems to know the SA password. Here's my plan to change it: 1. I've run a trace for a couple of days to verify that there are no jobs or processes that are...
1
4262
by: Mindy Geac | last post by:
Hello, I'm seaching for the possibility to change Domain/User passwords. And a check for users if the password has to change with the first logon or when the password is expired. thanx, ...
1
1974
by: black lee via DBMonster.com | last post by:
we would like to provide users with changing password feature in our application. I understand that db2 uses password of operating systems. does anyone know if there is sql commend or api we use in...
10
9834
by: Fabrizio | last post by:
(Sorry for the crosspost, but I really don't know which is the right newsgroup!) Hi all, I try to change the password to a user that as to change the password at first logon: try {
3
2153
by: Prabu Subroto | last post by:
Dear my friends... I am using SuSE 9.1 and postgres 7.2.x . Each time if I want to connect to postgres with postgres I do like this: " patrixlinux@patrix:~> su Password:...
2
1703
by: Greg Wickham | last post by:
Hi All, Earlier this year there was a discussion between Tom and Ezra regarding extending 'set session authorization' to facilitate changing the identity of a connection. A synopsis of the...
4
1750
by: muchexie | last post by:
I have developed a login system but its failing to allow the user to change password. Here is my code. <? require_once("system_fns.php"); session_start(); do_html_header("Changing...
4
4879
by: John Kotuby | last post by:
Hi all, I have a simple user-form which accepts contact and profile information for the user to edit and save. All the textboxes are working fine and displaying the expected data, both when the...
0
1412
by: =?Utf-8?B?RWQgT3R0bw==?= | last post by:
When changing a user's password in Active Directory Users... I get a strange error message (and the password change fails): Windows can not complete the password change for the user <insert user...
0
7123
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7175
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6842
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7319
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5430
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4864
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3070
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1378
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
262
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.