Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8
  1. #1
    New to the CF scene
    Join Date
    Apr 2012
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Would need fast help for my php script

    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
    PHP Code:
    <b>Forgot Password</b> 
    <?php
    if (isset($_POST['submit'])){
    $user $_POST['user'];
    $email $_POST['email'];
    $name $_POST['name'];
    $code $_POST['code'];
    $pass $_GET['pass'];
    $sql "SELECT * FROM users WHERE email='$email' AND name='$name' AND code='$code' AND
    user='$user' AND pass='$pass'"
    ;
    if(!
    mysql_query($sql))
    {
    echo 
    "Något är fel! ".mysql_error();
    }
    else
    {
    echo 
    "Ditt 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="email" 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>
    This is the errors
    PHP Code:
    NoticeUndefined indexpass in C:xampphtdocspageslostpassword.php on line 8
    Your Password is 


  • #2
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,861
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Blog Entries
    1
    Notice: Undefined index: pass in C:xampphtdocspageslostpassword.php on line 8
    That's obvious from the line $pass = $_GET['pass']; , as ther won't be any such variable in $_GET
    Your Password is !
    I don't understand how the above script output the above string as there's only one line,
    PHP Code:
    echo "Ditt lösenord är ".$pass."!"
    in the else condition. Are you sure that you are debugging the right file?

    PS: You need to fetch the values from mysql result set, returned by mysql_query().
    Check http://php.net/mysql_query and http://php.net/mysql_fetch_assoc

    Edit: I've checked your site and you've an error in the query. Check the output of
    PHP Code:
    echo $sql "SELECT * FROM users WHERE email='$email' AND name='$name' AND code='$code' AND
    user='$user' AND pass='$pass'"

    You don't need AND pass='$pass' there as there's no way of getting it from user.
    Last edited by abduraooft; 04-28-2012 at 09:24 AM.
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #3
    New to the CF scene
    Join Date
    Apr 2012
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Hey

    Im noob in php and need my script done i was read that you post but don't understand that! but this i understand with pass and that im done so fair right now!

    PHP Code:
    <b>Forgot Password</b> 
    <?php
    if (isset($_POST['submit'])){
    $user $_POST['user'];
    $email $_POST['email'];
    $name $_POST['name'];
    $code $_POST['code'];
    $pass $_POST['pass'];
    $sql "SELECT * FROM users WHERE email='$email' AND name='$name' AND code='$code' AND
    user='$user'"
    ;
    if(!
    mysql_query($sql))
    {
    echo 
    "Något är fel! ".mysql_error();
    }
    else
    {
    echo 
    "Ditt 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="email" 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>
    Error
    PHP Code:
    NoticeUndefined indexpass in C:xampphtdocspageslostpassword.php on line 8
    Ditt lösenord är 


  • #4
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,861
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Blog Entries
    1
    Add an echo before $sql, like
    PHP Code:
    echo $sql "SELECT * FROM users WHERE email='$email' AND name='$name' AND code='$code' AND
    user='$user'"

    and post the output
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #5
    New to the CF scene
    Join Date
    Apr 2012
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Now i got this

    error
    Notice: Undefined index: pass in C:\xampp\htdocs\pages\lostpassword.php on line 8
    SELECT * FROM users WHERE email='' AND name='' AND code='' AND user=''Ditt lösenord är !

  • #6
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,861
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Blog Entries
    1
    PHP Code:
    if(!mysql_query($sql))
    {
    echo 
    "Något är fel! ".mysql_error();
    }
    else
    {
    echo 
    "Ditt lösenord är ".$pass."!";

    Chang the above to
    PHP Code:
    $result=mysql_query($sql);
    if(!
    $result)
    {
    echo 
    "Något är fel! ".mysql_error();
    }
    else
    {
     if(
    mysql_num_rows($result)){ 
      
    $row=mysql_fetch_assoc($result);
      echo  
    "Ditt lösenord är ".$row['pass'];
      }
      else{
      echo 
    "No matches found for the given input"
      
    }

    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #7
    Super Moderator
    Join Date
    May 2002
    Location
    Perth Australia
    Posts
    4,073
    Thanks
    11
    Thanked 96 Times in 94 Posts
    the error suggests simply that $_POST['pass'] does not exist e.g. the form sending to this page does not have a form field named 'pass' ..

    Code:
    <input type="text" name="pass" .... etc
    does it ? and what use is it to you in this page anyway ?
    resistance is...

    MVC is the current buzz in web application architectures. It comes from event-driven desktop application design and doesn't fit into web application design very well. But luckily nobody really knows what MVC means, so we can call our presentation layer separation mechanism MVC and move on. (Rasmus Lerdorf)

  • #8
    New to the CF scene
    Join Date
    Apr 2012
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts
    fixed thanks !


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •