Advanced Search

Results 1 to 6 of 6

Thread: Forgot Login Script

  1. #1
    Join Date
    Oct 2009
    Posts
    9
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Forgot Login Script

    Okay, I've been working on this for a good solid day now and can't seem to get anywhere with it (all I get in the non-descriptive "unexpected $end" message). It works simple enough; user answers to preset security questions and the answers are matched to the appropriate info on the database. Maybe someone smarter than me could help out

    Have a look for yourself, any help would be greatly appreciated! Thanks in advance!:

    PHP Code:
    <?PHP

    $host
    ="localhost";
    $username=".";
    $password=".";
    $db_name=".";

    $Color=$_POST['Color'];
    $Hobby=$_POST['Hobby'];

    mysql_connect("$host""$username""$password")or die("cannot connect to server");
    mysql_select_db("$db_name")or die("cannot select DB");

    $User=mysql_query("SELECT User FROM users WHERE Color='$Color'")or die('failed to find username');

    $Pass=mysql_query("SELECT Pass FROM users WHERE Hobby='$Hobby'")or die('failed to find password');

    $Email=mysql_query("SELECT Email FROM users WHERE Color='$Color'") or die('failed to get email address');

    $result=mysql_query("SELECT Account FROM users WHERE Hobby='$Hobby'") or die('Query failed'); 

    $count mysql_num_rows($result); 
    if(
    $count 1){ 
    header("Location: error.php");
    }
    else {

    // ---------------- SEND MAIL FORM ----------------

    $to=$Email;

    $subject="Your login is here!";

    $header="from: security <security@mysite.com>";

    $message"Was this what you were looking for? \r\n 
    Your username is 
    $User \r\n 
    Your password is 
    $Pass \r\n";

    if (
    mail($to$subject$message$header)) {
    header("Location: login-sent.htm");
    }
    else {
    header("Location: error.php");
    }

    ?>
    Last edited by djr33; 12-16-2009 at 07:37 PM.

  2. #2
    Join Date
    Dec 2009
    Location
    North Carolina
    Posts
    71
    Thanks
    13
    Thanked 3 Times in 3 Posts

    Default

    Not sure mate, never was good with databases. I'd wait someone will help you.

    Tim

  3. #3
    Join Date
    May 2007
    Location
    Boston,ma
    Posts
    2,127
    Thanks
    173
    Thanked 207 Times in 205 Posts

    Default

    You never ended this

    else {

    // ---------------- SEND MAIL FORM ----------------

  4. The Following User Says Thank You to bluewalrus For This Useful Post:

    oldtimer (12-16-2009)

  5. #4
    Join Date
    Dec 2009
    Location
    North Carolina
    Posts
    71
    Thanks
    13
    Thanked 3 Times in 3 Posts

    Default

    Hahahaha I shoulda looked a bit harder then I could've answered. Sorry for the waste, thank you blue.

  6. #5
    Join Date
    Oct 2009
    Posts
    9
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Well don't I feel smart right now :P

    Wow, you have no idea how much time I've wasted on this; thank yo so much for finally straightening me out!

  7. #6
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,156
    Thanks
    262
    Thanked 690 Times in 678 Posts

    Default

    Unexpected $end means that the parser reached the end of the document and is still within some sort of sub-section of code. Usually it's like above, but it could be a quote, or parentheses, etc.
    Unfortunately this type of error is hard to fix because it won't know exactly where the error originated (since it happens at the last line of code, obviously). Commenting out sections of code strategically will help, or just rescanning to be sure everything is closed. Using exit(); (which ends the execution of the script) will help, because you can find out if the endless loop or endless section of code is yet reached.
    Daniel - Freelance Web Design | <?php?> | <html>| espa˝ol | Deutsch | italiano | portuguŕs | catalÓ | un peu de franšais | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

Tags for this Thread

Bookmarks

Posting Permissions

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