Need help with header("Location:.......") tag

Discussion in 'PHP' started by php_noobie, Jun 7, 2008.

  1. #1
    Hi guys pls refer to the coe below

    -----------------------------------

    <?php
    include "dbFunction.php";
    /*Array ( [spapackage] => 1 [name] => => [telephone] => [hiddenField] => member_id,
    password [member_id] => [day] => 1 [month] => Jan [year] => 2008 [time] => 1 [Submit] => Submit ) */
    $package = $_POST['spapackage'];
    $name = $_POST['name'];
    $email = $_POST['email'];
    $telephone = $_POST['telephone'];
    $member = $_POST['member_id'];
    $day = $_POST['day'];
    $month = $_POST['month'];
    $year = $_POST['year'];
    $time = $_POST['time'];
    $roomId = "";
    $location="/paradigm/thankyou.html";
    $con = connect();
    $rs3 = mysql_query("Select * from room where packageId = '".$package."'");
    //echo "Select * from room where packageId = '".$package."'";

    while ($row3 = mysql_fetch_array($rs3))
    {
    $rs1 = mysql_query("Select count(*) as 'count' from reservation where time = '". $time ."' and apptDay = '".$day."' and apptMonth = '".$month."' and apptYear = '".$year."' and reservation.roomId = '". $row3['roomId']."'");
    $row1 = mysql_fetch_array($rs1);
    if ($row1['count'] == 0)
    {
    $roomId = $row3['roomId'];
    $roomNumber= $row3['roomNumber'];
    $roomName= $row3['roomName'];
    }
    }

    if ($roomId != "")
    {
    mysql_query("Insert into reservation (name, contact, roomId, apptMonth, apptYear, apptDay, membershipId, email, time)
    values ('$name', '$telephone', '$roomId', '$month', '$year', '$day', '$member', '$email', '$time')");
    //echo "Insert into reservation (name, contact, roomId, apptMonth, apptYear, apptDay, membershipId, email, time) values ('$name', '$telephone', '$roomId', '$month', '$year', '$day', '$member', '$email', '$time')";
    //echo "Registration successful. Your room number is ".$roomNumber;
    header("Location:confirmation.php?roomName=".$roomName );

    }
    else
    {
    //echo "no room";
    header("Location:$location");
    }
    ?>
    ------------------------------------------------------

    That is the code for my processing script. I refer u to the line ''header("Location:confirmation.php?roomName=".$roomName );"

    That is the piece of code to retrieve the $roomName variable from the script for processing in the confirmation.php page. The purpose is to display the data in the confirmation.php page to let the user see his/her selections. However, other than room name, I want to let the user see the room Id as well and to do that, I've got to retrieve the $roomId variable also.

    Anyone here knows how to modify the header("Location:.....") tag in the code to attach multiple variables?
     
    php_noobie, Jun 7, 2008 IP
  2. Danltn

    Danltn Well-Known Member

    Messages:
    679
    Likes Received:
    36
    Best Answers:
    0
    Trophy Points:
    120
    #2
    header('Location:confirmation.php?roomName='.$roomName.'&amp;roomID='.$roomID);
     
    Danltn, Jun 7, 2008 IP
  3. php_noobie

    php_noobie Peon

    Messages:
    22
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Bro I tried that but still doesn't work. Only the room name appears in the confirmation page, the room id was a blank
     
    php_noobie, Jun 7, 2008 IP
  4. Danltn

    Danltn Well-Known Member

    Messages:
    679
    Likes Received:
    36
    Best Answers:
    0
    Trophy Points:
    120
    #4
    Have you urlencoded any data?

    Dan

    Edit: Fixed a silly typo, try again.
     
    Danltn, Jun 7, 2008 IP
  5. EricBruggema

    EricBruggema Well-Known Member

    Messages:
    1,740
    Likes Received:
    28
    Best Answers:
    13
    Trophy Points:
    175
    #5
    EricBruggema, Jun 8, 2008 IP
  6. kirpikinzi

    kirpikinzi Peon

    Messages:
    15
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    header("Location:confirmation.php?roomName=".$roomName."&roomID".$roomID );


    may be this will work
     
    kirpikinzi, Jun 8, 2008 IP
  7. Barti1987

    Barti1987 Well-Known Member

    Messages:
    2,703
    Likes Received:
    115
    Best Answers:
    0
    Trophy Points:
    185
    #7
    
    $roomName = urlencode($roomName);
    header("Location: confirmation.php?roomName=$roomName&roomID=$roomID");
    
    PHP:
    Peace,
     
    Barti1987, Jun 8, 2008 IP