Variable not passed

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Big Moxy

    #1

    Variable not passed

    I've successfully tested sending the variable "msg" back to login.php.
    However further down I am sending the variable "id" to menu.php but it
    is not being sent. It does not appear in the URL in the format
    http://{domain}/menu.php?id={va lue}. It is also not retrievable via
    $_GET['id']; I don't see any differences yet one works the other
    doesn't. Please help!

    Thank you!
    Tim

    <?php
    session_start() ;
    require_once("C onnections/usersDB.php");

    // username and password sent from signup form
    $userID=$_POST['userID'];
    $password=$_POS T['password'];
    $userType=$_POS T['clientType'];

    // encrypt password
    $encrypted_pass word=md5($passw ord);
    $_SESSION["password"] = $encrypted_pass word;

    // if password encryption is not used
    //$sql="SELECT * FROM $table_name WHERE userName='$user ID' and
    password='$pass word'";
    //$result=mysql_q uery($sql);

    // if password encryption is used
    if ($userType == ""){
    $sql="SELECT * FROM $table_name WHERE userName = '$userID' and
    userPassword = '$encrypted_pas sword'";
    $result=mysql_q uery($sql);
    if (!$result) {
    header("locatio n:login.php?msg =1");
    }
    else {
    $rows = mysql_num_rows( $result);
    if($rows < 1) {
    // Return to login page with error message
    header("locatio n:login.php?msg =2");
    }
    }
    }
    else {
    $sql = "INSERT INTO $table_name
    (`userName`,`us erPassword`,`us erType`,`userSt atus`) VALUES
    ('$userID','$en crypted_passwor d','$userType', '1')";
    $result=mysql_q uery($sql);
    if (!$result) {
    header("locatio n:login.php?msg =3");
    }
    }

    // Register $userID, $password, $userType
    $_SESSION['userID'] = $userID;
    $_SESSION['password'] = $encrypted_pass word;
    $_SESSION['userType'] = $userType;

    // Determine next page based on user type
    if ($userType == "admin") {
    header("locatio n:menu.php?id=1 ");
    }
    elseif ($userType = "dynamixSI" ) {
    header("locatio n:menu.php?id=2 ");
    }
    elseif ($userType == "VAR") {
    header("locatio n:menu.php?id=3 ");
    }
    elseif ($userType == "salesAgent ") {
    header("locatio n:menu.php?id=4 ");
    }
    else {
    header("locatio n:phone.php");
    }

    ?>

  • Darko

    #2
    Re: Variable not passed

    On Nov 9, 11:37 pm, Big Moxy <bigm...@gmail. comwrote:
    I've successfully tested sending the variable "msg" back to login.php.
    However further down I am sending the variable "id" to menu.php but it
    is not being sent. It does not appear in the URL in the format
    http://{domain}/menu.php?id={va lue}. It is also not retrievable via
    $_GET['id']; I don't see any differences yet one works the other
    doesn't. Please help!
    >
    Thank you!
    Tim
    >
    <?php
    session_start() ;
    require_once("C onnections/usersDB.php");
    >
    // username and password sent from signup form
    $userID=$_POST['userID'];
    $password=$_POS T['password'];
    $userType=$_POS T['clientType'];
    >
    // encrypt password
    $encrypted_pass word=md5($passw ord);
    $_SESSION["password"] = $encrypted_pass word;
    >
    // if password encryption is not used
    //$sql="SELECT * FROM $table_name WHERE userName='$user ID' and
    password='$pass word'";
    //$result=mysql_q uery($sql);
    >
    // if password encryption is used
    if ($userType == ""){
    $sql="SELECT * FROM $table_name WHERE userName = '$userID' and
    userPassword = '$encrypted_pas sword'";
    $result=mysql_q uery($sql);
    if (!$result) {
    header("locatio n:login.php?msg =1");
    }
    else {
    $rows = mysql_num_rows( $result);
    if($rows < 1) {
    // Return to login page with error message
    header("locatio n:login.php?msg =2");
    }
    }}
    >
    else {
    $sql = "INSERT INTO $table_name
    (`userName`,`us erPassword`,`us erType`,`userSt atus`) VALUES
    ('$userID','$en crypted_passwor d','$userType', '1')";
    $result=mysql_q uery($sql);
    if (!$result) {
    header("locatio n:login.php?msg =3");
    }
    >
    }
    >
    // Register $userID, $password, $userType
    $_SESSION['userID'] = $userID;
    $_SESSION['password'] = $encrypted_pass word;
    $_SESSION['userType'] = $userType;
    >
    // Determine next page based on user type
    if ($userType == "admin") {
    header("locatio n:menu.php?id=1 ");}
    >
    elseif ($userType = "dynamixSI" ) {
    header("locatio n:menu.php?id=2 ");}
    >
    elseif ($userType == "VAR") {
    header("locatio n:menu.php?id=3 ");}
    >
    elseif ($userType == "salesAgent ") {
    header("locatio n:menu.php?id=4 ");}
    >
    else {
    header("locatio n:phone.php");
    >
    }
    >
    ?>
    I don't know if it helps, but you have to use absolute URL's in the
    location header. Also, I admit
    I haven't seen yet an example of specifying the query string in the
    location header. Are you
    sure it's included by the protocol?

    Comment

    • Big Moxy

      #3
      Re: Variable not passed

      On Nov 9, 3:11 pm, Darko <darko.maksimo. ..@gmail.comwro te:
      On Nov 9, 11:37 pm, Big Moxy <bigm...@gmail. comwrote:
      >
      >
      >
      >
      >
      I've successfully tested sending the variable "msg" back to login.php.
      However further down I am sending the variable "id" to menu.php but it
      is not being sent. It does not appear in the URL in the format
      http://{domain}/menu.php?id={va lue}. It is also not retrievable via
      $_GET['id']; I don't see any differences yet one works the other
      doesn't. Please help!
      >
      Thank you!
      Tim
      >
      <?php
      session_start() ;
      require_once("C onnections/usersDB.php");
      >
      // username and password sent from signup form
      $userID=$_POST['userID'];
      $password=$_POS T['password'];
      $userType=$_POS T['clientType'];
      >
      // encrypt password
      $encrypted_pass word=md5($passw ord);
      $_SESSION["password"] = $encrypted_pass word;
      >
      // if password encryption is not used
      //$sql="SELECT * FROM $table_name WHERE userName='$user ID' and
      password='$pass word'";
      //$result=mysql_q uery($sql);
      >
      // if password encryption is used
      if ($userType == ""){
      $sql="SELECT * FROM $table_name WHERE userName = '$userID' and
      userPassword = '$encrypted_pas sword'";
      $result=mysql_q uery($sql);
      if (!$result) {
      header("locatio n:login.php?msg =1");
      }
      else {
      $rows = mysql_num_rows( $result);
      if($rows < 1) {
      // Return to login page with error message
      header("locatio n:login.php?msg =2");
      }
      }}
      >
      else {
      $sql = "INSERT INTO $table_name
      (`userName`,`us erPassword`,`us erType`,`userSt atus`) VALUES
      ('$userID','$en crypted_passwor d','$userType', '1')";
      $result=mysql_q uery($sql);
      if (!$result) {
      header("locatio n:login.php?msg =3");
      }
      >
      }
      >
      // Register $userID, $password, $userType
      $_SESSION['userID'] = $userID;
      $_SESSION['password'] = $encrypted_pass word;
      $_SESSION['userType'] = $userType;
      >
      // Determine next page based on user type
      if ($userType == "admin") {
      header("locatio n:menu.php?id=1 ");}
      >
      elseif ($userType = "dynamixSI" ) {
      header("locatio n:menu.php?id=2 ");}
      >
      elseif ($userType == "VAR") {
      header("locatio n:menu.php?id=3 ");}
      >
      elseif ($userType == "salesAgent ") {
      header("locatio n:menu.php?id=4 ");}
      >
      else {
      header("locatio n:phone.php");
      >
      }
      >
      ?>
      >
      I don't know if it helps, but you have to use absolute URL's in the
      location header. Also, I admit
      I haven't seen yet an example of specifying the query string in the
      location header. Are you
      sure it's included by the protocol?- Hide quoted text -
      >
      - Show quoted text -
      AFIK the absolute URL is not mandatory because most web servers
      support its absence. As I indicated, the query string worked
      successfully for all of my ?msg={value} options. I did however change
      the URL to absolute and I am at least getting the ?id={value} passed
      but {value} is wrong. That's another problem for another post if I
      don't figure it out.

      Thanks,
      Tim

      Comment

      • Darko

        #4
        Re: Variable not passed

        On Nov 10, 12:53 am, Big Moxy <bigm...@gmail. comwrote:
        On Nov 9, 3:11 pm, Darko <darko.maksimo. ..@gmail.comwro te:
        >
        >
        >
        On Nov 9, 11:37 pm, Big Moxy <bigm...@gmail. comwrote:
        >
        I've successfully tested sending the variable "msg" back to login.php.
        However further down I am sending the variable "id" to menu.php but it
        is not being sent. It does not appear in the URL in the format
        http://{domain}/menu.php?id={va lue}. It is also not retrievable via
        $_GET['id']; I don't see any differences yet one works the other
        doesn't. Please help!
        >
        Thank you!
        Tim
        >
        <?php
        session_start() ;
        require_once("C onnections/usersDB.php");
        >
        // username and password sent from signup form
        $userID=$_POST['userID'];
        $password=$_POS T['password'];
        $userType=$_POS T['clientType'];
        >
        // encrypt password
        $encrypted_pass word=md5($passw ord);
        $_SESSION["password"] = $encrypted_pass word;
        >
        // if password encryption is not used
        //$sql="SELECT * FROM $table_name WHERE userName='$user ID' and
        password='$pass word'";
        //$result=mysql_q uery($sql);
        >
        // if password encryption is used
        if ($userType == ""){
        $sql="SELECT * FROM $table_name WHERE userName = '$userID' and
        userPassword = '$encrypted_pas sword'";
        $result=mysql_q uery($sql);
        if (!$result) {
        header("locatio n:login.php?msg =1");
        }
        else {
        $rows = mysql_num_rows( $result);
        if($rows < 1) {
        // Return to login page with error message
        header("locatio n:login.php?msg =2");
        }
        }}
        >
        else {
        $sql = "INSERT INTO $table_name
        (`userName`,`us erPassword`,`us erType`,`userSt atus`) VALUES
        ('$userID','$en crypted_passwor d','$userType', '1')";
        $result=mysql_q uery($sql);
        if (!$result) {
        header("locatio n:login.php?msg =3");
        }
        >
        }
        >
        // Register $userID, $password, $userType
        $_SESSION['userID'] = $userID;
        $_SESSION['password'] = $encrypted_pass word;
        $_SESSION['userType'] = $userType;
        >
        // Determine next page based on user type
        if ($userType == "admin") {
        header("locatio n:menu.php?id=1 ");}
        >
        elseif ($userType = "dynamixSI" ) {
        header("locatio n:menu.php?id=2 ");}
        >
        elseif ($userType == "VAR") {
        header("locatio n:menu.php?id=3 ");}
        >
        elseif ($userType == "salesAgent ") {
        header("locatio n:menu.php?id=4 ");}
        >
        else {
        header("locatio n:phone.php");
        >
        }
        >
        ?>
        >
        I don't know if it helps, but you have to use absolute URL's in the
        location header. Also, I admit
        I haven't seen yet an example of specifying the query string in the
        location header. Are you
        sure it's included by the protocol?- Hide quoted text -
        >
        - Show quoted text -
        >
        AFIK the absolute URL is not mandatory because most web servers
        support its absence.
        You're probably right, but HTTP specification says:
        The field value consists of a single absolute URI.
        >
        Location = "Location" ":" absoluteURI
        >
        An example is:
        >
        Location: http://www.w3.org/pub/WWW/People.html
        As I indicated, the query string worked
        successfully for all of my ?msg={value} options. I did however change
        the URL to absolute and I am at least getting the ?id={value} passed
        but {value} is wrong. That's another problem for another post if I
        don't figure it out.
        >
        Thanks,
        Tim
        Regards

        Comment

        • John Dunlop

          #5
          HTTP Location header (was: Variable not passed)

          Darko:
          [Big Moxy:]
          >
          AFIK the absolute URL is not mandatory because most web servers
          support its absence.
          Most web servers supporting relative URLs is not a reason for not
          using absolute URLs.
          You're probably right, but HTTP specification says:
          >
          The field value consists of a single absolute URI.
          >
          Location = "Location" ":" absoluteURI
          >
          An example is:
          >
          (What a poor example URL.)

          Which means that, you are right, an absolute URL is required.

          The rule that defines the Location header was fixed to include
          fragment identifiers, so in practice the rule is:

          Location = "Location" ":" absoluteURI [ "#" fragment ]

          --
          Jock

          Comment

          Working...