gotmedia Posted May 4, 2012 Share Posted May 4, 2012 Hi! I'm attempting to do this and feel that I'm fairly close. Would you take a look and throw me any bones? PHP Code: <?php if (isset($_POST['ppassword']) && (stristr($string,'') === TRUE)) { switch($_POST['ppassword']) { case "Google": header("Location: http://www.google.com"); exit(); case "Yahoo": header("Location: http://www.yahoo.com"); exit(); case "Bing": header("Location: http://www.bing.com"); exit(); } } ?> The Form: <form name="portal" id="portal" method="post" action=""> <input name="ppassword" type="text" id="ppassword" maxlength="25" onfocus="this.select()" onblur="this.value=!this.value?'company name':this.value;" value="company name" onclick="this.value=''" /> <input name="login" type="submit" id="login" value="Continue" /> </form> I appreciate any of your help. I feel close and this part (stristr($string,'') feels like the missing piece of the puzzle. Link to comment https://forums.phpfreaks.com/topic/262071-directing-user-based-on-password-entered-using-stristr/ Share on other sites More sharing options...
Jessica Posted May 4, 2012 Share Posted May 4, 2012 What is $string? You'll only find '' in $string if $string == ''; stristr will also NEVER return true. What are you trying to do? Link to comment https://forums.phpfreaks.com/topic/262071-directing-user-based-on-password-entered-using-stristr/#findComment-1343037 Share on other sites More sharing options...
gotmedia Posted May 4, 2012 Author Share Posted May 4, 2012 I got $string from another website lol, trying to piece things together. I'm trying to say: "If you type in a password that includes these words 'Google' for example, then you will be redirected to this page -> http://www.google.com" The above will work if you type in "Google, Inc.", "Google Corp", etc. as long as the word "google" (case insensitive) is inputted. Link to comment https://forums.phpfreaks.com/topic/262071-directing-user-based-on-password-entered-using-stristr/#findComment-1343040 Share on other sites More sharing options...
Jessica Posted May 4, 2012 Share Posted May 4, 2012 If you just randomly put code in and don't know why or what it does, you won't get very far. Link to comment https://forums.phpfreaks.com/topic/262071-directing-user-based-on-password-entered-using-stristr/#findComment-1343051 Share on other sites More sharing options...
Mahngiel Posted May 4, 2012 Share Posted May 4, 2012 So... if you use "google" as your password, and you log into your site... you get redirected to google.com? Have i got that right? Link to comment https://forums.phpfreaks.com/topic/262071-directing-user-based-on-password-entered-using-stristr/#findComment-1343090 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.