Welcome to Dream.In.Code
Getting PHP Help is Easy!

Join 132,683 PHP Programmers for FREE! Get instant access to thousands of PHP experts, tutorials, code snippets, and more! There are 1,224 people online right now. Registration is fast and FREE... Join Now!




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

 
Reply to this topicStart new topic

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

PHP_noob
post 7 Jun, 2008 - 08:46 AM
Post #1


New D.I.C Head

*
Joined: 5 Jun, 2008
Posts: 24

Hi there pls refer to the following code

CODE

<?php
      include "dbFunction.php";
/*Array ( [spapackage] => 1 [name] => [email] => [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");
      }
      /*
      $rs1 = mysql_query("Select COUNT(*) as 'count' from reservation, room where time = '". $time ."' and apptDay = '".$day."' and apptMonth = '".$month."' and apptYear = '".$year."' and room.packageId = '". $package."' and reservation.roomId = room.roomId");
     //echo "Select COUNT(*) from reservation, room where time = '". $time ."' and apptDay = '".$day."' and apptMonth = '".$month."' and apptYear = '".$year."' and room.packageId = '". $package."' and reservation.roomId =  room.roomId";
     $rs2 = mysql_query("Select COUNT(*) as 'count' from room where packageId = '".$package."'");
     $row1 = mysql_fetch_array($rs1);
     $row2 = mysql_fetch_array($rs2);
     if ($row1['count'] == 0)
      {
            $rs3 = mysql_query("Select * from room where packageId = '".$package."'");
            $row3 = mysql_fetch_array($rs3);
          $roomid = $row3['roomId'];
          //$rs3 = mysql_query("Select * as 'count' from reservation, room where time = '". $time ."' and apptDay = '".$day."' and apptMonth = '".$month."' and apptYear = '".$year."' and room.packageId = '". $package."' and reservation.roomId = room.roomId");
          //
        }
      else if ($row1['count'] == $row2['count'])
     {
            $roomid = "";
      }
      else
      {

     } */
?>



This is my script to process my hotel website spa booking. The code header("Location:confirmation.php?roomName=".$roomName ); is used to retrieve the $roomName variable and for processing in the confirmation.php page. But I am not very sure how to retrieve >1 variables. For example, retrieving both the $roomName and $roomId variables for confirmation.php, anyone how to code the script for this purpose?
User is offlineProfile CardPM

Go to the top of the page

musya
post 7 Jun, 2008 - 09:42 AM
Post #2


D.I.C Regular

Group Icon
Joined: 25 Apr, 2007
Posts: 291



Thanked 1 times

Dream Kudos: 50
My Contributions


use & so
CODE

header("Location:confirmation.php?roomName=$roomName&roomid=$roomId);
User is offlineProfile CardPM

Go to the top of the page

PHP_noob
post 7 Jun, 2008 - 10:15 AM
Post #3


New D.I.C Head

*
Joined: 5 Jun, 2008
Posts: 24

Hey bro I tried adding that code but to no avail
User is offlineProfile CardPM

Go to the top of the page

akozlik
post 7 Jun, 2008 - 10:38 AM
Post #4


D.I.C Addict

Group Icon
Joined: 25 Feb, 2008
Posts: 596



Thanked 22 times

Dream Kudos: 750
My Contributions


Hey man,

I'm a bit confused as to what's you're trying to do. Are you trying to pass all those variables to the next page? If so, you can do what musya above stated

php

header("Location:confirmation.php?roomName=".$roomName."&roomid=".$roomId);


Then, on your confirmation.php page, you would get the variables from the url like this.

php

$roomName = $_GET['roomName'];
$roomid = $_GET['roomid'];


You can then use $roomName and $roomid on the next page. There's a great tutorial on DIC about the use of $_GET and $_POST, make sure you read it.

User is offlineProfile CardPM

Go to the top of the page

Fast ReplyReply to this topicStart new topic
Time is now: 11/23/08 06:51AM

Live PHP Help!

PHP Tutorials

Reference Sheets

PHP Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month