dthievin Posted April 12, 2007 Share Posted April 12, 2007 I don't know anything about php, and I probably shouldn't be here. I need to write a small php script that will compel visitors to enter a specific word, for example, "cat". If they enter the correct word, then they are granted access to the next page. I realize that this is really the same as any image-recognition script such as those used right here on php freaks. The only difference is that I don't need to portray a graphic, nor will my script have any other registration purpose. Really basic. I sure appreciate whatever help someone offers. Link to comment https://forums.phpfreaks.com/topic/46773-i-need-a-small-php-script/ Share on other sites More sharing options...
designknights Posted April 12, 2007 Share Posted April 12, 2007 <?PHP $mysecret="CAT"; if (!isset($_GET['secretword']) | $_GET['secretword']!=$mysecret){ header("location:/"); } ?> Thar ya go Link to comment https://forums.phpfreaks.com/topic/46773-i-need-a-small-php-script/#findComment-227977 Share on other sites More sharing options...
dthievin Posted April 12, 2007 Author Share Posted April 12, 2007 Great! Now aside from making the secret word something other than "cat", do I need to modify any of your other lines ... "location:/", for example? Link to comment https://forums.phpfreaks.com/topic/46773-i-need-a-small-php-script/#findComment-227981 Share on other sites More sharing options...
Cheeseweasel Posted April 12, 2007 Share Posted April 12, 2007 Yes, because that defines where your secret question/answer thingy actually leads to. Link to comment https://forums.phpfreaks.com/topic/46773-i-need-a-small-php-script/#findComment-227983 Share on other sites More sharing options...
clown[NOR] Posted April 12, 2007 Share Posted April 12, 2007 designknights.. why using $_GET[]? thought he was going to use a form.. in that case use this make a file called index.php or whatever you want.. (in this example it's index.php) <?php if (isset($_POST['secretword'])) { if ($_POST['secretword'] == "CAT") { Header("Location: http://www.url-to-next-page.com/nextfile.php"); } else { echo "You did not type the correct word"; } } ?> <html> <body> <form name="thesecret" method="post" action="index.php"> Enter the secret word: <input name="secretword" type="text" /> <br /><input type="submit" value="Submit" /> </form> think that should fit your request? Link to comment https://forums.phpfreaks.com/topic/46773-i-need-a-small-php-script/#findComment-227985 Share on other sites More sharing options...
dthievin Posted April 12, 2007 Author Share Posted April 12, 2007 Thanks again. I take it, Clown, that the code you wrote is really both files, first the script, and next the form? Link to comment https://forums.phpfreaks.com/topic/46773-i-need-a-small-php-script/#findComment-228002 Share on other sites More sharing options...
clown[NOR] Posted April 12, 2007 Share Posted April 12, 2007 yes.... the php code on top... it only triggers if a user has pressed Submit or hit Enter on the keyboard and i also forgot the closing BODY and HTML tags... in case u didnt notice =) Link to comment https://forums.phpfreaks.com/topic/46773-i-need-a-small-php-script/#findComment-228011 Share on other sites More sharing options...
dthievin Posted April 12, 2007 Author Share Posted April 12, 2007 Works like a charm, and thank you sincerely. Link to comment https://forums.phpfreaks.com/topic/46773-i-need-a-small-php-script/#findComment-228022 Share on other sites More sharing options...
clown[NOR] Posted April 12, 2007 Share Posted April 12, 2007 no problem... =) NOTE: Make sure you mark this post as solved now Link to comment https://forums.phpfreaks.com/topic/46773-i-need-a-small-php-script/#findComment-228031 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.