Re: Reposting elseif carry
| From: | Curt Zirzow | Date: | Sun, 16 May 2004 02:03:14 +0000 |
| Subject: | Re: Reposting elseif carry | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-186340@lists.php.net to get a copy of this message | ||
* Thus wrote Ronald The Newbie Allen (sesel@omantel.net.om):
>
> what I currently have is
>
> echo "<META HTTP-EQUIV=\"refresh\" content=\"0;
>
> URL=./Conference_Calls.php?Date_and_Time=".$_POST["$Date_and_Time"].">";
Have you looked at what this is actually outputing?
>
> Tried several things from the string and either they return a parsing error
> or they return ".$_POST
>
> kind of clueless now....help please
You might want to read:
http://www.php.net/manual/en/langref.php
It'll give you a better grasp on what you're trying to do.
>
> The code:
>
> <?
> $event = $_GET['Event_Type'];
> $Date_and_Time = $_GET['Date_and_Time'];
You're using $_GET here but $_POST in the output of your meta tag,
which one is it?
> //echo "$event";
> //echo "$time";
> if ($event == "Trouble_Tickets") {
> echo '<META HTTP-EQUIV="refresh" content="0;
> URL=./Trouble_Tickets.php">';
> } elseif ($event == "Conference_Calls") {
> print '<META HTTP-EQUIV="refresh" content="0;
> URL=./Conference_Calls.php?Date_and_Time=$_POST["Date_and_Time"]">';
> } elseif ($event == "Outage_Reports") {
> echo '<META HTTP-EQUIV="refresh" content="0;
> URL=./Outage_Reports.php">';
> } else {
> echo '<META HTTP-EQUIV="refresh" content="0;
> URL=./log.php">';
> }
>
A few points:
- You're if/elseif would better be written with a switch()
statment.
- You shouldn't really use a meta-refresh, but redirect the user
using header().
- Learn the difference between how php treats the single quote (')
vs the double quote (")
<?php // this start tag is highly recommended
// Grab the event from the Query String
$event = $_GET['Event_Type'];
// Make the base url for redirection.
$base_url = 'http://' . $_SERVER['HTTP_HOST'];
$base_url .= dirname($_SERVER['REQUEST_URI']);
switch ($event) {
case 'Trouble_Tickets':
$redirect = $base_url . $event . '.php';
break;
case 'Conference_Calls':
$redirect = $base_url . $event . '.php?Date_and_Time='.
$_POST['Date_and_Time'];
break;
case 'Outage_Reports':
$redirect = $base_url . $event . '.php';
break;
default:
$redirect = $base_url . 'log.php';
break;
}
// Now redirect the user
header('Location: ' . $redirect);
exit();
?>
Curt
--
"I used to think I was indecisive, but now I'm not so sure."