This topic is locked

Redirect script th add page by if statement

11/5/2009 3:23:36 PM
PHPRunner General questions
M
mmponline author

I have the following code to redirect to a add page via the view page (as used in the Cars and Realty templates):

global $dal;

$rs = $dal->functions->Query($strWhereClause,"");

$data = db_fetch_array($rs);

$_SESSION["FunctionID"] = $data["FunctionID"];

$_SESSION["Logo"] = $data["Logo"];

$_SESSION["Company"] = $data["Company"];

$_SESSION["FunctionName"] = $data["FunctionName"];

$_SESSION["Venue"] = $data["Venue"];

$_SESSION["Date"] = $data["Date"];

$_SESSION["Time"] = $data["Time"];

$_SESSION["ReplyMail"] = $data["ReplyMail"];

$_SESSION["RSVPdate"] = $data["RSVPdate"];
?>

<script>

window.location='./form1_add.php';

</script>

<?php

exit();


I want to customise this code to redirect to a different add page depending on the field selection in Type field:
Eg.

If Type in the functions table = Form1, then script should go to

?>

<script>

window.location='./form1_add.php';

</script>

<?php

exit();
If Type in the functions table = Form2, then script should go to

?>

<script>

window.location='./form2_add.php';

</script>

<?php

exit();
etc.
I know this should be achieved with if and else statements but not sure how.
Please assist!

J
Jane 11/9/2009

Hi,
here is just a sample:

if ($data["Type"]=="Form1")

{

...

}



More info here:

http://us.php.net/manual/en/control-structures.if.php