IceDragon Posted August 15, 2008 Share Posted August 15, 2008 I want to make a textbox in which you would have to type in a certain word to be redirected to some other website after submiting.. but i can't figure out why it is not working.. If I upload this the page just keeps refreshing. here's the code <?php include "wrong.php"; $answer=TEST; if(isset($answer['submit'])) { if($answer==TEST) { print '<META HTTP-EQUIV="Refresh" Content="0; URL=http://somewebsite.com'; exit; } else { print "$wrong<br>"; } } else { print "<form action='index.php' method='post'>"; print "<p align='center'>Answer:<br></p>"; print "<p align='center'><input type='text' name='answer' size='30'><br></p>"; print "<p align='center'><input type='submit' name='submit' align='center' value='Send'></form></p>"; } ?> Link to comment https://forums.phpfreaks.com/topic/119897-ifelse-on-submit-problem/ Share on other sites More sharing options...
ohdang888 Posted August 15, 2008 Share Posted August 15, 2008 $answer= "TEST"; if(isset($answer['submit'])) { if($answer== "TEST") you forgot the quotations Link to comment https://forums.phpfreaks.com/topic/119897-ifelse-on-submit-problem/#findComment-617645 Share on other sites More sharing options...
IceDragon Posted August 15, 2008 Author Share Posted August 15, 2008 ok I've added the quotations and the missing '=' in $answer=="TEST"; It's not refreshing anymore, howevrer after i enter the TEST and click submit it doesn't do anything.. (it should redirect, if TEST entered) Link to comment https://forums.phpfreaks.com/topic/119897-ifelse-on-submit-problem/#findComment-617655 Share on other sites More sharing options...
ohdang888 Posted August 15, 2008 Share Posted August 15, 2008 you only need 1 equal sign to set a variable. while comparing 2 variables, you have to use 2. this is the right code" <?php include "wrong.php"; $answer= "TEST"; if(isset($answer['submit'])) { if($answer=="TEST") { print '<META HTTP-EQUIV="Refresh" Content="0; URL=http://somewebsite.com">'; exit; } else { print "$wrong<br>"; } } else { print "<form action='index.php' method='post'>"; print "<p align='center'>Answer:<br></p>"; print "<p align='center'><input type='text' name='answer' size='30'><br></p>"; print "<p align='center'><input type='submit' name='submit' align='center' value='Send'></form></p>"; } ?> Link to comment https://forums.phpfreaks.com/topic/119897-ifelse-on-submit-problem/#findComment-617659 Share on other sites More sharing options...
ohdang888 Posted August 15, 2008 Share Posted August 15, 2008 you only need 1 equal sign to set a variable. while comparing 2 variables, you have to use 2. this is the right code" EDIT: you never set $answer['submit'] its set in this now... <?php include "wrong.php"; $answer['submit'] ="go"; $answer= "TEST"; if(isset($answer['submit'])) { if($answer=="TEST") { print '<META HTTP-EQUIV="Refresh" Content="0; URL=http://somewebsite.com">'; exit; } else { print "$wrong<br>"; } } else { print "<form action='index.php' method='post'>"; print "<p align='center'>Answer:<br></p>"; print "<p align='center'><input type='text' name='answer' size='30'><br></p>"; print "<p align='center'><input type='submit' name='submit' align='center' value='Send'></form></p>"; } ?> Link to comment https://forums.phpfreaks.com/topic/119897-ifelse-on-submit-problem/#findComment-617661 Share on other sites More sharing options...
IceDragon Posted August 15, 2008 Author Share Posted August 15, 2008 ok removed.. now the page keeps refreshing again hmm. Link to comment https://forums.phpfreaks.com/topic/119897-ifelse-on-submit-problem/#findComment-617663 Share on other sites More sharing options...
ohdang888 Posted August 15, 2008 Share Posted August 15, 2008 php is fine this... its this: print '<META HTTP-EQUIV="Refresh" Content="0; URL=http://www.google.com">'; that needs help. idk about meta refreshes though Link to comment https://forums.phpfreaks.com/topic/119897-ifelse-on-submit-problem/#findComment-617666 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.