Would need fast help for my php script

Discussion in 'PHP' started by byllan, Apr 27, 2012.

  1. #1
    Hello i have been working for hours to make this script working. I want it check so the username, name, mail and code is true. If all is true it will show the password from the user and if not it will show a message like Something is wrong!

    That's the site with the script apelsinen.com/?p=lostpassword
    This is the script
    <b>Forgot Password</b> <?phpif (isset($_POST['submit'])){$user = $_POST['user'];$mail = $_POST['mail'];$name = $_POST['name'];$code = $_POST['code'];$sql = "SELECT * FROM users WHERE mail='$mail' AND name='$name' AND code='$code'user='$user' AND pass='$pass'";if(!mysql_query($sql)){echo "Något är fel! ".mysql_error();}else{echo "Ditt nya lösenord är ".$pass."!";}}?><html><body><tr><form action="?p=lostpassword" method="post">        <td><br>Username:<br></td>        <td><input type="text" input type="text" name="user" value=""></td></tr><tr>        <td><br>Mail:<br></td>        <td><input type="text" name="mail" value=""></td></tr><tr>        <td><br>Name:<br></td>        <td><input type="text" name="name" value=""></td></tr><tr>        <td><br>Secret Code:<br></td>        <td><input type="text" name="code" value=""></td></tr><tr>  <td> <tr> <br>  <input type="submit" name="submit" value="Get Password"> </td></tr> </table></form><br><br></html></body>
    PHP:
    This is the errors
    Notice: Undefined variable: pass in C:\xampp\htdocs\pages\lostpassword.php on line 9
    Något är fel! You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'user='' AND pass=''' at line 2
    PHP:

     
    byllan, Apr 27, 2012 IP
  2. Oli3L

    Oli3L Active Member

    Messages:
    207
    Likes Received:
    3
    Best Answers:
    1
    Trophy Points:
    70
    #2
    $sql = "SELECT * FROM users WHERE mail='$mail' AND name='$name' AND code='$code' user='$user' AND pass='$pass'";
    PHP:
    look here.
    you wrote pass='$pass' but you have never defined $pass.
     
    Oli3L, Apr 28, 2012 IP
  3. byllan

    byllan Peon

    Messages:
    23
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thanks i have fix it now!
     
    byllan, Apr 28, 2012 IP