Jump to content

Recommended Posts

Hello All,

 

I tried searching for an answer, but to no avail.

 

Basically, my script works GREAT, except for one small part, the user can change the password to be blank. I have tried everything including the empty() and the if ='null' commands, but can't get anything to work.

 

So I need the script to make sure that the $newpassword or the $confirmnewpassword variables are not blank before processing the request. Thanks!!

 

 

<?
// Start a session
session_start();

// Sends the user to the login-page if not logged in
if(!session_is_registered('member_ID')) :



header('Location: index.php?msg=requires_login');
endif;

include("dbinfo.inc.php");
mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$user = $_SESSION["member_ID"];

$username = $_POST['$user'];
$password = $_POST['password'];
$newpassword = sha1($_POST['newpassword']);
$confirmnewpassword = sha1($_POST['confirmnewpassword']);

if($newpassword=$confirmnewpassword)
    $sql=mysql_query("UPDATE members SET user_password='$newpassword' where username='$user'"); 
    if($sql) 
    { 
    echo "Your Password Has Been Changed."; 
    }
else
{ 
echo "The Passwords You Entered Do Not Match, Or You Have Not Entered A Password. Please Try Again."; 
}  
?> 


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
</head>
<body>
<p><a href="members.shtml" title="Back">Back</a></p>
</body>
</html>

try sumfin like this..

 

<?
// Start a session
session_start();

// Sends the user to the login-page if not logged in
if (!session_is_registered('member_ID')) header('Location: index.php?msg=requires_login');
include("dbinfo.inc.php");
mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$user = $_SESSION["member_ID"];

$username = $_POST[$user];
$password = $_POST['password'];
$newpassword = sha1($_POST['newpassword']);
$confirmnewpassword = sha1($_POST['confirmnewpassword']);
if (($password) && ($_POST['newpassword']) && ($_POST['confirmnewpassword']) {
if($newpassword=$confirmnewpassword) $sql=mysql_query("UPDATE members SET user_password='$newpassword' where username='$user'"); 
if($sql) { 
	echo "Your Password Has Been Changed."; 
}
else { 
	echo "The Passwords You Entered Do Not Match, Or You Have Not Entered A Password. Please Try Again."; 
}  
} else {
echo "All forms must be filled in..";
}
?> 

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.