Jump to content

Recommended Posts

Dont need to remove user + pass its included in config.php :)

 

<?php
include('config.php');

mysql_connect($dbhost, $dbuser, $dbpass);
mysql_select_db($dbname);

$success = true; 
$problemMessage = ""; 
if (isset($_POST['Submit'])) 
{ 
    $user = isset($_POST['user'])?$_POST['user']:false;
    $pass = isset($_POST['pass'])?$_POST['pass']:false;
    $pass2 = isset($_POST['newpass'])?$_POST['pass2']:false;
    $pass2 = isset($_POST['newpass2'])?$_POST['pass2']:false;
    
    if(!$user || !$pass ||!$newpass || !$newpass2);
    {
        $problemMessage = "Please fill in all required data";
        $success = false;
    }
    if($newpass != $newpass2)
        { 
            $problemMessage .= "Your passwords do not match <br />"; 
            $success = false; 
        } 
        if(strlen($newpass2) < 5) 
        { 
            $problemMessage .= "Your password must be more than 5 characters<br />"; 
            $success = false; 
        } 
        if(strlen($newpass2) > 20) 
        { 
            $problemMessage .= "Your password cannot be longer than 20 characters <br />"; 
            $success = false; 
        }  
        $result = mysql_query("SELECT * FROM `accounts` where login='$user' AND password='$pass'") or die(mysql_error());

        {
        if (empty($result)) return 'Invalid username or password';
        else {
                 $sql = "UPDATE accounts SET password = '$newpass' WHERE username = '$user' and password = '$pass';";
                 $result = mysql_query($sql);
        if (empty($result)) return mysql_error();
        }
?>
<html>
<head>
<title>Password Change</title>
</head>
<body
<form action="" method="post"
                    Username: 
          <input type="text" name="user">
          <br>  
          Password: 
          <input type="password" name="pass">
          <br>  
          New Password: 
          <input type="password" name="newpass">
          <br />
          Repeat New Password: 
          <input type="password" name="newpass2">
          <br />
          <input name="Submit" type="submit" value="submit"> 
          
          <imput name="reset" type="reset" value="reset"> 
</form>
</body>
</html>

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.