PLZ help

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ashtaj
    New Member
    • Feb 2007
    • 7

    PLZ help

    hi all first off all am new,,, i develop login form by php and my database is mysql data but the proplem i can not go to the next page when i write the correct user name and password ,,how i can link it to the next page i write the code to show me what is the error please i realy need it



    <?php

    if( (!$username) or (!password) )
    { header("Locatio n:$HTTP_REFERER "); exit();}

    $conn=@mysql_co nnect("localhos t","","")
    or die("Could not connection");

    $rs=@mysql_sele ct_db("java_db" , $conn)
    or die("Could not select database");

    $uid= $_POST["username"];
    $pwd= $_POST["password"];

    $sql="select * from login where usname='$uid'

    and pass= '$pwd'";
    //echo $sql;
    $rs=mysql_query ($sql,$conn)
    or die("query not work correctly");

    $num= mysql_numrows($ rs);

    if($num != 0)
    { $msg="welcome $username - your log in

    succeeded!"; }
    // else
    //{header("Locati on:C:\ash work\Object.htm l");

    exit(); }

    ?>

    <body> <?php echo($msg); ?> </body>
  • Atli
    Recognized Expert Expert
    • Nov 2006
    • 5062

    #2
    Hi.
    First id like to ask you to read the posting guidlines before you post anything else.
    That said, there are a number of errors in your code.
    Originally posted by ashtaj
    if( (!$username) or (!password) )
    { header("Locatio n:$HTTP_REFERER "); exit();}
    The password part of the if statment is missing a $ sign, and I'm guessing your reading this from POST data so youd have to change it into $_POST['password'].
    The exit() call will never be executed, the browser has already been redirected.
    The $HTTP_REFERER should be {$_SERVER['HTTP_REFERER"]}

    Originally posted by ashtaj
    if($num != 0)
    { $msg="welcome $username - your log in

    succeeded!"; }
    // else
    //{header("Locati on:C:\ash work\Object.htm l");
    The header("Locatio n: C:\...") will never work. The location should be an URL

    Originally posted by ashtaj
    exit(); }
    This exit calls stops the rest of the page from diplaying, it should be removed.

    These are all minor errors. You could try to find yourself some tutorial to have as a reference when you write, that would make it easyer to spot these kind of errors.
    Also, the official PHP web is a goldmine when your writing PHP. It has a complete list of all functions you can use with PHP and usefull code snippets to explain them.

    Comment

    • ashtaj
      New Member
      • Feb 2007
      • 7

      #3
      realy thanx man

      Comment

      • prashanth023
        New Member
        • Apr 2007
        • 13

        #4
        Hi Athli,

        You have give a good answer.

        Comment

        Working...