#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2000
    Location
    Liverpool, UK
    Posts
    1
    Rep Power
    0
    I'm trying to redirect to a page after making a mysql query.

    $SQL=("SELECT Email FROM users
    WHERE users.Email = '$Password'");
    $result = mysql_query($SQL);

    echo ("$result");
    if(($result = 0){
    echo("<B>The password you entered is not valid.<B>");
    }
    elseif ($result=something) {
    ("Location: http:/path/");
    /*exit()*/;

    } else {
    ("Location: http:/path/");
    /*exit()*/;
    }
    Can anyone tell me how to do it...my attempt is above, and doesn't work

    Thanks
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jul 2000
    Posts
    669
    Rep Power
    15
    the echo("$result"); line is what is killing it. You cannot print out anything before you have your header() function. Try something like this
    $SQL=("SELECT Email FROM users
    WHERE users.Email = '$Password'");
    $result = mysql_query($SQL);

    if ($result=something) {
    ("Location: http:/path/");
    /*exit()*/;

    else {
    echo("<B>The password you entered is not valid.<B>");
    }

  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2000
    Location
    Ontario, Canada
    Posts
    498
    Rep Power
    18
    I personally think your best bet is to use a META Refresh tag. These are a helluvalot easier to work with than header(), since you can insert the META Refresh whenever, or wherever you want. It's what I always use, if I'm not using a Javascript setTimeout().

    eg;

    <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">code:</font><HR><pre>
    $SQL=("SELECT Email FROM users
    WHERE users.Email = '$Password'");
    $result = mysql_query($SQL);

    echo ("$result");
    if(($result = 0){
    echo("<B>The password you entered is not valid.<B>");
    }
    elseif ($result=something) {
    echo("<META http-equiv="refresh" content="0;URL=http:/path/"");
    /*exit()*/;

    } else {
    echo("<META http-equiv="refresh" content="0;URL=http:/path/"");
    /*exit()*/;
    }

    [/code]


    ------------------
    To alcohol! The cause of, and solution to, all of life's problems. -- Homer Simpson
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2000
    Posts
    79
    Rep Power
    15
    ummm, you forgot to type 'header' ??

    Basil

Similar Threads

  1. jsp forward vs redirect +patterns
    By bculp2000 in forum Java Help
    Replies: 1
    Last Post: December 27th, 2003, 12:49 PM
  2. Change form redirect location from dropdown.
    By stanbridge in forum HTML Programming
    Replies: 7
    Last Post: November 19th, 2003, 06:44 PM
  3. compiling .java, thought I knew what I was doing?!
    By geoffgarcia in forum Java Help
    Replies: 10
    Last Post: September 9th, 2003, 11:56 AM
  4. Need help: redirect to page based on text in URL
    By JPElectron in forum HTML Programming
    Replies: 2
    Last Post: July 19th, 2003, 12:44 AM
  5. Installation LDAP under cygwin
    By joze in forum LDAP Programming
    Replies: 3
    Last Post: July 16th, 2003, 04:30 PM

IMN logo majestic logo threadwatch logo seochat tools logo