data not being transferred from one php file to another (POST)

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • webgenius
    New Member
    • Apr 2007
    • 15

    data not being transferred from one php file to another (POST)

    CheckLogin.php
    <?php
    ob_start();
    $host="localhos t"; // Host name
    $username="root "; // Mysql username
    $password="secr et"; // Mysql password
    $db_name="game" ; // Database name
    $tbl_name="memb ers"; // Table name

    // Connect to server and select databse.
    mysql_connect(" $host", "$username" , "$password" )or die("cannot connect");
    mysql_select_db ("$db_name") or die("cannot select DB");

    // Define $myusername and $mypassword
    $myusername=$_P OST['Username'];
    $mypassword=$_P OST['Password'];

    $sql="SELECT * FROM $tbl_name WHERE username='$myus ername' and password='$mypa ssword'";
    $result=mysql_q uery($sql);

    // Mysql_num_row is counting table row
    $count=mysql_nu m_rows($result) ;
    // If result matched $myusername and $mypassword, table row must be 1 row

    if($count==1){
    // Register $myusername, $mypassword and redirect to file "LoginOK.ph p"
    $_session['username']=$myusername;
    $_session['password']=$mypassword;
    session_registe r("Username") ;
    session_registe r("Password") ;
    header("locatio n:LoginOK.php") ;
    }
    else {
    echo "Wrong Username or Password";
    }

    ob_end_flush();
    ?>
    LoginOK.php
    <?
    session_start() ;
    echo "hello";
    $Username=$_GET['Username'];
    echo $Username;
    if(!session_is_ registered('use rname')){
    header("locatio n:index.php");
    }
    ?>
    I'm not able to see the value of Username in LoginOK.php. Please help me with this.

    Is there any IDE or debugger which will help me trace the values of variables?
  • Markus
    Recognized Expert Expert
    • Jun 2007
    • 6092

    #2
    Originally posted by webgenius
    CheckLogin.php


    LoginOK.php


    I'm not able to see the value of Username in LoginOK.php. Please help me with this.

    Is there any IDE or debugger which will help me trace the values of variables?
    Well, is username present in the url?
    url:
    Code:
    somewebsite.com?username=makusn00b
    Wait, you say it's being POSTed, then why are you using GET?
    [php]
    $username = $_POST['username'];
    [/php]

    Comment

    • webgenius
      New Member
      • Apr 2007
      • 15

      #3
      Originally posted by markusn00b
      Well, is username present in the url?
      url:
      Code:
      somewebsite.com?username=makusn00b
      Wait, you say it's being POSTed, then why are you using GET?
      [php]
      $username = $_POST['username'];
      [/php]
      Nope. The username is not present in the URL

      Comment

      • TheServant
        Recognized Expert Top Contributor
        • Feb 2008
        • 1168

        #4
        Originally posted by webgenius
        Nope. The username is not present in the URL
        GET is used when the variable is stored in the URL. POST is done behind the scenes. Try POST instead of GET in your form.

        Comment

        • webgenius
          New Member
          • Apr 2007
          • 15

          #5
          Another small question....Is there any IDE or debugger which will help me trace the values of variables?
          Tried Eclipse with some defualt plugin for PHP. But it threw an error whenever it saw a MySQL statement.

          Comment

          • TheServant
            Recognized Expert Top Contributor
            • Feb 2008
            • 1168

            #6
            Originally posted by webgenius
            Another small question....Is there any IDE or debugger which will help me trace the values of variables?
            Tried Eclipse with some defualt plugin for PHP. But it threw an error whenever it saw a MySQL statement.
            No sure about free and official ones, but I recommend just using echo statements to echo variables as you go through.

            {function1}
            echo ("After function 1: A=".$var_a." B=".$var_b);
            {function2}
            echo ("After function 2: A=".$var_a." B=".$var_b);

            Comment

            Working...