Results 1 to 2 of 2
  1. #1
    Join Date
    Jun 2008
    Location
    pakistan
    Posts
    109

    Unanswered: Login Coding Doesn't Work.

    The coding which is i used i get from a website people appriciate this script so i get that one but the login script doesn't work i have a table
    called userid,username,password

    and the inserted values is userid 1 ,username admin,password waridtel but some thing went wrong the script is here see and tell me
    PHP Code:
    <?php
    include('vars.php');
    include(
    'connection.php');

    //check that the user is calling the page from the login form and not accessing it directly 

    //and redirect back to the login form if necessary 

    if (!isset($username) || !isset($password)) { 
    echo 
    "<script type='text/javascript'>";

    echo 
    "window.location = 'index.php'";
    echo 
    "</script>"



    //check that the form fields are not empty, and redirect back to the login page if they are 


    elseif (empty($username) || empty($password)) { 
    echo 
    "<script type='text/javascript'>";
    echo 
    "window.location = 'index.php' ";
    echo 
    "</script>"

    else{ 

    //convert the field values to simple variables 
    //add slashes to the username and md5() the password 


    $user addslashes($_POST['username']); 
    $pass md5($_POST['password']); 

    $result=mysql_query("select * from user where username='$user' AND password='$pass'"); 

    //check that at least one row was returned 

    //$rowCheck = mysql_num_rows($result); 
    //if($rowCheck = 1 ){ 
    while($row mysql_fetch_assoc($result)){ 

      
    //start the session and register a variable 

      
    session_start(); 
      
    session_register('username'); 

      
    //successful login code will go here... 
      
    echo 'Success!'

      
    //we will redirect the user to another page where we will make sure they're logged in 
    echo "<script type='text/javascript'>";
    echo 
    "window.location = 'index2.php' ";
    echo 
    "</script>";

      } 

    /*  } 
      else { 

      //if nothing is returned by the query, unsuccessful login code goes here... 

      echo 'Incorrect login name or password. Please try again.'; 
      } */
      


    ?>

  2. #2
    Join Date
    Jun 2008
    Location
    pakistan
    Posts
    109
    if possible then give me the explanation of coding like isset function, || pipesign function and other explanation or provide me another one solid coding another question i will ask later after this solution.

Posting Permissions

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