Miko Posted May 28, 2009 Share Posted May 28, 2009 Hello, I have a search form where a user can insert 2 different values: - track - reference depending with what kind of value the user want's to search this one is send to another website/link - track -> for ex: www.track.com - reference -> for ex: www.reference.com The form has 2 radio buttons, so the user must chose one of both to get his result. The action is not a problem, but it's how to know if the user has chosen track or reference. I know that it should work with a if($track){go website}else{go other website} But I don't know the whole technical part of this, anyone can help me out here? Thanks Quote Link to comment https://forums.phpfreaks.com/topic/160005-solved-form-action/ Share on other sites More sharing options...
Michdd Posted May 28, 2009 Share Posted May 28, 2009 Say the name of the track radio button is 'track' and the other is 'ref' then you'd use: if(isset($_POST['track'])) { //Do whatever } elseif(isset($POST['ref'])) { //Do whatever } Quote Link to comment https://forums.phpfreaks.com/topic/160005-solved-form-action/#findComment-844034 Share on other sites More sharing options...
Miko Posted May 28, 2009 Author Share Posted May 28, 2009 thanks this is not realy the problem, I forgot the mention the real question (d'oh). in the if(isset($track){ // how can I code here that he must go to website a? }else{ // same thing here? } Quote Link to comment https://forums.phpfreaks.com/topic/160005-solved-form-action/#findComment-844037 Share on other sites More sharing options...
chelnov63 Posted May 28, 2009 Share Posted May 28, 2009 if(isset($track){ header('Location:http://www.hotmail.com'); }else{ header('Location:http://www.yahoo.com'); } Quote Link to comment https://forums.phpfreaks.com/topic/160005-solved-form-action/#findComment-844050 Share on other sites More sharing options...
Miko Posted May 28, 2009 Author Share Posted May 28, 2009 I've tried this one, but I got this as error :-\ Warning: Cannot modify header information - headers already sent by (output started at D:\xampp\htdocs\Test\google.php:1) in D:\xampp\htdocs\Test\google.php on line 11 my code: <form action="<?php $_SERVER['PHP_SELF'] ?>" method="post" target="_blank"> Go Google: <input type="text" name="bla"><input type="submit" name="go" value="GO"> </form> <?php $go = $_POST['go']; if(isset($go)){ header('Location:http://www.hotmail.com'); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/160005-solved-form-action/#findComment-844053 Share on other sites More sharing options...
Miko Posted May 28, 2009 Author Share Posted May 28, 2009 go it, I've changed the "action" into action="other.php" and put there the php code. Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/160005-solved-form-action/#findComment-844058 Share on other sites More sharing options...
chelnov63 Posted May 28, 2009 Share Posted May 28, 2009 see if this helps: <?php ob_start(); ?> <form action="<?php $_SERVER['PHP_SELF'] ?>" method="post" target="_blank"> Go Google: <input type="text" name="bla"><input type="submit" name="go" value="GO"> </form> <?php $go = $_POST['go']; if(isset($go)){ header('Location:http://www.hotmail.com'); } ?> <?php ob_end_flush(); ?> Quote Link to comment https://forums.phpfreaks.com/topic/160005-solved-form-action/#findComment-844060 Share on other sites More sharing options...
Miko Posted May 28, 2009 Author Share Posted May 28, 2009 yep, that works allso. This code is new to me, what is the exact functionality of this one? Quote Link to comment https://forums.phpfreaks.com/topic/160005-solved-form-action/#findComment-844063 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.