fuzzylr Posted March 13, 2012 Share Posted March 13, 2012 Expectation of code: I would like it to take the number the customer selects and based on that number load a different page. So you load into index.php The options are 1 - 4. I am receiving the information into Variables. However, it's not changing the page. Here is the code for it to change the page. header('Location: driven' + $num + '.html');} Also is there a better way of breaking out of php code? <?phpif(isset($_POST['submit'])){echo "Submit button has been pressed"; ?><br /><?phpecho $num; ?><br /><?phpif ($num < 1){ $error="Invalid option"; echo $error;}else{ header('Location: driven' + $num + '.html');}}?> Notice all the <?php ?> ?? Link to comment Share on other sites More sharing options...
astralaaron Posted March 13, 2012 Share Posted March 13, 2012 There is no need for all of the <?php opening and closing, you can echo out HTML. You also had an extra bracket after your header() <?phpif(isset($_POST['submit'])){echo "Submit button has been pressed <br />";echo $num . "<br />";if ($num < 1){ $error="Invalid option"; echo $error;}else{ //header('Location: driven' + $num + '.html');} looks like an extra } on thereheader('Location: driven' + $num + '.html');}?> Link to comment Share on other sites More sharing options...
justsomeguy Posted March 13, 2012 Share Posted March 13, 2012 In PHP you use a dot to join strings, a plus is for arithmetic addition. Link to comment Share on other sites More sharing options...
astralaaron Posted March 13, 2012 Share Posted March 13, 2012 Funny how you can over look that switching back and forth from javascript to php Link to comment Share on other sites More sharing options...
fuzzylr Posted March 13, 2012 Author Share Posted March 13, 2012 In PHP you use a dot to join strings, a plus is for arithmetic addition. Thank you. This worked very well. header('Location: driven' . $num . '.html');} Link to comment Share on other sites More sharing options...
thescientist Posted March 13, 2012 Share Posted March 13, 2012 sorry, that was my bad. I gave a bad example herehttp://w3schools.invisionzone.com/index.php?showtopic=42241&st=0&p=234445entry234445 (I've since changed it to ., from +) Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.