Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Posting evaluation not working

Status
Not open for further replies.

ZOR

Technical User
Jan 30, 2002
2,963
GB
I have a formpage having:

<p align="left"><input type="submit" value=" Place Order " name="V1" style="font-weight: 700"><input type="submit" value="Continue with Order" name="V2" style="font-weight: 700"></p>

It gets posted to the next form which opens with:
<?
session_start()
?>
<?
if (isset($_POST['V1'])) {
header('location: test1.php');
exit();
}

if (isset($_POST['V2'])) {
header('location: test2.php');
exit();
}
?>

But it keeps going to test2.php

Please tell me why? Thanks
 
Strange ... try this

Code:
if (isset($_POST['V1'])[COLOR=red]===true[/color])

Regards
 
i agree that the behaviour is curious. exit should kill the code; not to mention of course that both values cannot be set simultaneously.

please try this construct instead:
Code:
if (isset($_POST['V1'])) {
    header("location: test1.php");
    exit();
} elseif (isset($_POST['V2'])) {
    header("location: test2.php");
    exit();
}

i'd also recommend debugging your code by sending the POST superglobal to the screen (the header calls won't work after but it's just for debugging).

don't forget to call session_write_close() before the redirects if you are doing anything with the session data in this script
 
The code worked for me as posted.

Since the two submit buttons will only be activated one at a time, your code could also name them the same and use the submitted values:

the html file:
Code:
<html><body>
<form method="post" action="test_foo.php">
<p align="left">
	<input type="submit" value=" Place Order " name="sub_button" style="font-weight: 700">
	<input type="submit" value="Continue with Order" name="sub_button" style="font-weight: 700">
</p>
</form></body></html>

the PHP file:
Code:
<?php
session_start();	

switch ($_POST['sub_button'])
{
	case ' Place Order ':
	    header('location: test1.php');
    	exit();
    	break;
	case 'Continue with Order':
	    header('location: test2.php');
	    exit();
	    break;
} 
?>



Want the best answers? Ask the best questions! TANSTAAFL!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top