Michdd Posted November 26, 2008 Share Posted November 26, 2008 Is there some way that I can make a submit form that will directly place the person at a certain url based on what they entered. What I'm trying to do is more complicated than this, but this is just an example of what I want to do. Have a submit form and when they type in say "11" into it, and press submit, it directly brings him to like somefile.php?id=11 Link to comment https://forums.phpfreaks.com/topic/134302-form-input-into-a-redirect/ Share on other sites More sharing options...
dezkit Posted November 26, 2008 Share Posted November 26, 2008 Yes. <?php $textfield = $_POST["textfield"]; if(is_numeric($textfield)){ header("Location: ./somefile.php?id=$textfield"; } else { echo "Please enter a number"; } ?> Link to comment https://forums.phpfreaks.com/topic/134302-form-input-into-a-redirect/#findComment-699188 Share on other sites More sharing options...
Michdd Posted November 26, 2008 Author Share Posted November 26, 2008 Yes. <?php $textfield = $_POST["textfield"]; header("Location: ./somefile.php?id=$textfield"; ?> I knew that already, that won't do what I want it to do, because this is involved in a complicated script, so when it submits the form, since a certain variable isn't already set, it doesn't even get to the if(isset($textfield)){ } So it won't do that. Link to comment https://forums.phpfreaks.com/topic/134302-form-input-into-a-redirect/#findComment-699192 Share on other sites More sharing options...
br3nn4n Posted November 26, 2008 Share Posted November 26, 2008 Well give us the more complicated script Link to comment https://forums.phpfreaks.com/topic/134302-form-input-into-a-redirect/#findComment-699223 Share on other sites More sharing options...
chmpdog Posted November 26, 2008 Share Posted November 26, 2008 I knew that already, that won't do what I want it to do, because this is involved in a complicated script, so when it submits the form, since a certain variable isn't already set, it doesn't even get to the if(isset($textfield)){ } So it won't do that. Now that is one hell of a run-on sentence after re-reading it several times I think this is the answer from what I deciphered: put if(isset($certainvarable) { if(isset($textfield) } } else { //error } Link to comment https://forums.phpfreaks.com/topic/134302-form-input-into-a-redirect/#findComment-699307 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.