Monshery Posted June 26, 2006 Share Posted June 26, 2006 Well i want to have a form with List manu which you pick some choice and it will send you to a page that fits the choise - is this the way to do it ?.[code]<form name="GTP" action="<? echo $GTP; ?>" method="POST"> <p> <select name="FAM" id="FAM"> <option value="yaniv" selected>yaniv</option> <option value="shlomi">shlomi</option> <option value="kalfa">kalfa</option> </select> </p> <p> <input type="submit" name="Submit" value="Submit"> </p></form><?PHPif ($_POST['FAM'] == 'yaniv')$GTP = 'YANIV.PHP';elseif ($_POST['FAM'] == 'shlomi')$GTP = 'SHLOMI.PHP';elseif ($_POST['FAM'] == 'kalfa')$GTP = 'KALFA.PHP';?>[/code] i am allready trying this for like 40 mins Link to comment https://forums.phpfreaks.com/topic/12927-dont-know-how-to-call-this-but-need-help-in-it/ Share on other sites More sharing options...
d_barszczak Posted June 26, 2006 Share Posted June 26, 2006 Hi,This script would not work as the GTP variable is not declared at any point.You would need to change your action to something like submit.php then in this file you can decide where you want your browser to be redirected to.Something along the following lines:[code]// submit.php[\code] Link to comment https://forums.phpfreaks.com/topic/12927-dont-know-how-to-call-this-but-need-help-in-it/#findComment-49622 Share on other sites More sharing options...
Monshery Posted June 26, 2006 Author Share Posted June 26, 2006 thanks for quoting me mate - any clue how do i do it ? Link to comment https://forums.phpfreaks.com/topic/12927-dont-know-how-to-call-this-but-need-help-in-it/#findComment-49623 Share on other sites More sharing options...
d_barszczak Posted June 26, 2006 Share Posted June 26, 2006 [!--quoteo(post=388017:date=Jun 26 2006, 11:52 AM:name=Monshery)--][div class=\'quotetop\']QUOTE(Monshery @ Jun 26 2006, 11:52 AM) [snapback]388017[/snapback][/div][div class=\'quotemain\'][!--quotec--]thanks for quoting me mate - any clue how do i do it ?[/quote]Sorry mate it wont let me post my full replay??? Link to comment https://forums.phpfreaks.com/topic/12927-dont-know-how-to-call-this-but-need-help-in-it/#findComment-49625 Share on other sites More sharing options...
AndyB Posted June 26, 2006 Share Posted June 26, 2006 a javascript "jump box" is a pretty simple solution.[a href=\"http://www.javascriptkit.com/combo.htm\" target=\"_blank\"]http://www.javascriptkit.com/combo.htm[/a] Link to comment https://forums.phpfreaks.com/topic/12927-dont-know-how-to-call-this-but-need-help-in-it/#findComment-49627 Share on other sites More sharing options...
d_barszczak Posted June 26, 2006 Share Posted June 26, 2006 [!--quoteo(post=388022:date=Jun 26 2006, 12:03 PM:name=AndyB)--][div class=\'quotetop\']QUOTE(AndyB @ Jun 26 2006, 12:03 PM) [snapback]388022[/snapback][/div][div class=\'quotemain\'][!--quotec--]a javascript "jump box" is a pretty simple solution.[a href=\"http://www.javascriptkit.com/combo.htm\" target=\"_blank\"]http://www.javascriptkit.com/combo.htm[/a][/quote]Sorry about this there must be something in the code that wont allow me to post my full reply i have just tried to pm it to you but still no luck. Link to comment https://forums.phpfreaks.com/topic/12927-dont-know-how-to-call-this-but-need-help-in-it/#findComment-49628 Share on other sites More sharing options...
Monshery Posted June 26, 2006 Author Share Posted June 26, 2006 Nice solution is ther a way not useing javascript ?Or at least how do i use thi java script solution . can view the source cose of thoes pages Link to comment https://forums.phpfreaks.com/topic/12927-dont-know-how-to-call-this-but-need-help-in-it/#findComment-49629 Share on other sites More sharing options...
Orio Posted June 26, 2006 Share Posted June 26, 2006 Let's say this file is called index.php[code]//Put this at the TOP!!<?PHPif(isset($_POST['Submit'])){if ($_POST['FAM'] == 'yaniv'){$GTP = 'YANIV.PHP';}elseif ($_POST['FAM'] == 'shlomi'){$GTP = 'SHLOMI.PHP';}elseif ($_POST['FAM'] == 'kalfa'){$GTP = 'KALFA.PHP';}else{$GTP='index.php';};header("Location: ".$GTP);exit;?>//Other HTML stuff here<form name="GTP" action"index.php" method="POST"> <p> <select name="FAM" id="FAM"> <option value="yaniv" selected>yaniv</option> <option value="shlomi">shlomi</option> <option value="kalfa">kalfa</option> </select> </p> <p> <input type="submit" name="Submit" value="Submit"> </p></form>[/code]Because no info but the action is being sent, this would work. If there's other data you can pass them using sessions.Orio. Link to comment https://forums.phpfreaks.com/topic/12927-dont-know-how-to-call-this-but-need-help-in-it/#findComment-49631 Share on other sites More sharing options...
Orio Posted June 26, 2006 Share Posted June 26, 2006 Let's say this file is called index.php[code]//Put this at the TOP!!<?PHPif(isset($_POST['Submit'])){if ($_POST['FAM'] == 'yaniv'){$GTP = 'YANIV.PHP';}elseif ($_POST['FAM'] == 'shlomi'){$GTP = 'SHLOMI.PHP';}elseif ($_POST['FAM'] == 'kalfa'){$GTP = 'KALFA.PHP';}else{$GTP='index.php';};header("Location: ".$GTP);exit;?>//Other HTML stuff here<form name="GTP" action"index.php" method="POST"> <p> <select name="FAM" id="FAM"> <option value="yaniv" selected>yaniv</option> <option value="shlomi">shlomi</option> <option value="kalfa">kalfa</option> </select> </p> <p> <input type="submit" name="Submit" value="Submit"> </p></form>[/code]Because no info but the action is being sent, this would work. If there's other data you can pass them using sessions.Orio. Link to comment https://forums.phpfreaks.com/topic/12927-dont-know-how-to-call-this-but-need-help-in-it/#findComment-49632 Share on other sites More sharing options...
Monshery Posted June 26, 2006 Author Share Posted June 26, 2006 Not working this way as well Link to comment https://forums.phpfreaks.com/topic/12927-dont-know-how-to-call-this-but-need-help-in-it/#findComment-49634 Share on other sites More sharing options...
Orio Posted June 26, 2006 Share Posted June 26, 2006 Oh I think it's my fault.Try now:[code]//Put this at the TOP!!<?PHPif(isset($_POST['Submit'])){if ($_POST['FAM'] == 'yaniv'){$GTP = 'YANIV.PHP';}elseif ($_POST['FAM'] == 'shlomi'){$GTP = 'SHLOMI.PHP';}elseif ($_POST['FAM'] == 'kalfa'){$GTP = 'KALFA.PHP';}else{$GTP='index.php';};header("Location: ".$GTP);exit;};?>//Other HTML stuff here<form name="GTP" action"index.php" method="POST"> <p> <select name="FAM" id="FAM"> <option value="yaniv" selected>yaniv</option> <option value="shlomi">shlomi</option> <option value="kalfa">kalfa</option> </select> </p> <p> <input type="submit" name="Submit" value="Submit"> </p></form>[/code]And make sure you save it as index.php.Orio. Link to comment https://forums.phpfreaks.com/topic/12927-dont-know-how-to-call-this-but-need-help-in-it/#findComment-49636 Share on other sites More sharing options...
Monshery Posted June 26, 2006 Author Share Posted June 26, 2006 OK i put this at the top of the page [code] <?PHP if(isset($_POST['Submit'])) { if($_POST['FAM'] == 'yaniv') { $GTP = 'yaniv.PHP'; } else { $GTP = 'INDEX.PHP'; } header("Location: "$GTP); exit; }; ?>[/code]well it does bring an error up :Warning: Cannot modify header information - headers already sent by (output started at C:\wamp\www\Yanivs\MMO-Date\INDEX.PHP:1) in C:\wamp\www\Yanivs\MMO-Date\INDEX.PHP on line 8 Link to comment https://forums.phpfreaks.com/topic/12927-dont-know-how-to-call-this-but-need-help-in-it/#findComment-49639 Share on other sites More sharing options...
Orio Posted June 26, 2006 Share Posted June 26, 2006 Make sure the first sing on the page is the <?php tag. You can have any line breaks or even white spaces before of it.Orio. Link to comment https://forums.phpfreaks.com/topic/12927-dont-know-how-to-call-this-but-need-help-in-it/#findComment-49654 Share on other sites More sharing options...
Monshery Posted June 27, 2006 Author Share Posted June 27, 2006 OK i made it to work - but the form that i used no longer send me the Move variable with post the the next page - This is on tomp of index.php :[code]<?PHP if(isset($_POST['submit'])) { if($_POST['FAM'] == 'yaniv') { $GTP = 'Yaniv.PHP'; } else { $GTP = 'INDEX.PHP'; } header("Location: ".$GTP); exit; };?>[/code]then a little bit in the batton i got this form:[code]<form name="GTP" action"index.php" method="POST"> <p> <select name="FAM" id="FAM"> <option value="yaniv" selected>yaniv</option> <option value="shlomi">shlomi</option> <option value="kalfa">kalfa</option> </select> </p> <p><font face="Verdana, Arial, Helvetica, sans-serif">Starting age: <input name="AGE" type="text" id="GOOD" value="0" size="10" maxlength="10"> </p> <p> <input type="submit" name="Submit" value="Submit"> </p></form>[/code]then in file name . yaniv.php i have [code]<?PHPif(isset($_POST['AGE'])){echo $_POST['AGE'] .$_POST['FAM'];}?>[/code]But when i run it i will just jump to Page yaniv.php without sending me $_POST['AGE']and $_POST['FAM'].If anyone knows why it would realy help .I know its might be passiable doing with session but its too complicated with sessions. Link to comment https://forums.phpfreaks.com/topic/12927-dont-know-how-to-call-this-but-need-help-in-it/#findComment-50027 Share on other sites More sharing options...
Orio Posted June 27, 2006 Share Posted June 27, 2006 Sessions are not complicated, believe me. But if you really dont want to use them, and the information you need to pass is nothing like a password or any other sensetive information, do this:[code]<?PHP if(isset($_POST['submit'])) { $age=$_POST['age']; if($_POST['FAM'] == 'yaniv') { $GTP = 'yaniv.php'; } else { $GTP = 'index.php'; } header("Location: ".$GTP."?AGE=".$age."&FAM=".$GTP); exit; };?>Rest of HTML here...[/code]And in yaniv.php and index.php do:[code]<?PHPif(isset($_GET['AGE'])){echo $_GET['AGE'] .$_GET['FAM'];}?>[/code]If the information IS sensetive, you should use sessions.Orio. Link to comment https://forums.phpfreaks.com/topic/12927-dont-know-how-to-call-this-but-need-help-in-it/#findComment-50062 Share on other sites More sharing options...
Monshery Posted June 27, 2006 Author Share Posted June 27, 2006 LOL i didnt knew you can use this kinda of way :header("Location: ".$GTP."?AGE=".$age."&FAM=".$GTP);Well i solved it allready with sessions. alltough its not sensitive info.i know session is not complicated i just sayed that useing session for this case is just not nessesery. :-) THnx very much mate for help .Realy helped me . Link to comment https://forums.phpfreaks.com/topic/12927-dont-know-how-to-call-this-but-need-help-in-it/#findComment-50081 Share on other sites More sharing options...
Orio Posted June 27, 2006 Share Posted June 27, 2006 Bevakasha :DOrio. Link to comment https://forums.phpfreaks.com/topic/12927-dont-know-how-to-call-this-but-need-help-in-it/#findComment-50094 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.