Page 2 of 2 FirstFirst 12
Results 11 to 13 of 13

Thread: parse error in php

  1. #11
    Join Date
    Jul 2011
    Location
    hyderabad,India
    Posts
    58
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default reply

    below is my modified script. but it is not redirecting to the
    page "products.php"
    what went wrong here....
    PHP Code:
    <?php 
    session_start
    ();
    mysql_connect("localhost","root","") or die("mysql_error()");
    mysql_select_db("shopping") or die("mysql_error()"); 
    $result mysql_query("SELECT * from login where username='" $_POST['username'] . "' AND password='" $_POST['password'] . "'"); 
    $rows=mysql_num_rows($result);
    if(isset(
    $_SESSION['username']))
    {
     
    $messages "UserId : ".$_SESSION['username'];
     unset(
    $_SESSION['username']);

    else 
    {
      
    $_SESSION['username'] = time();
    }
    if (
    $rows 0

    session_register('username');
    $_SESSION['username'] = $_POST['username'];
    echo 
    $messages;
    header("Location:products.php");
    exit; 

    else

    //unsuccessful login 
    header("Location:login3.php");
    exit; 

    ?>

  2. #12
    Join Date
    Apr 2008
    Location
    So.Cal
    Posts
    3,643
    Thanks
    63
    Thanked 516 Times in 502 Posts
    Blog Entries
    5

    Default

    is it redirecting to login3.php ? is it giving you an error message? please be as specific as possible about what's going on.

    in addition, it is always best to use absolute URLs when you use the header() function:
    PHP Code:
    header("Location: http://www.example.com/page.php");
    // is much more reliable than 
    header("Location: page.php");
    // while this works sometimes, 
    // according to the HTTP/1.1 spec, it technically shouldn't work at all. 

  3. #13
    Join Date
    Jul 2011
    Location
    hyderabad,India
    Posts
    58
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default reply

    first when the session has started he need to go to the "products.php" page
    using the session name(here using time()).here username is the output of time()
    that should be stored in the database.
    tell me how to do this one....

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
  •