Marcus2000 Posted February 28, 2011 Share Posted February 28, 2011 Hi people, please can any of you guys help us out? I need to write some php code but i'm getting more and more confused everytime i get into php. Anyways this is what i'm trying to do on my site: I want the user to type in a company name in a text field in a very simple html form. The user hits submit buton and the text the user typed in gets sent to a php document for processing. If the user has typed in a company name that matches one of the 3 company names that i have, then the user gets sent to one page. (sucess page) If the what the user has entered into the search form does not match one of my 3 company names, then I want them to be sent to another page (error page). I know this is real simple stuff guys, but i just cant get my head round this so far, please, please help. Many thanks in advance, Marcus. Quote Link to comment https://forums.phpfreaks.com/topic/229116-if-else-statements-php-newbe-still-struggling/ Share on other sites More sharing options...
flolam Posted February 28, 2011 Share Posted February 28, 2011 assuming the three company names are in an array: <?php $companies = array("Mercedes", "VW", "Porsche") if (in_array(trim($_GET["companyname"]), $companies)) { //show success page } else { //showerror page } ?> Quote Link to comment https://forums.phpfreaks.com/topic/229116-if-else-statements-php-newbe-still-struggling/#findComment-1180696 Share on other sites More sharing options...
Marcus2000 Posted February 28, 2011 Author Share Posted February 28, 2011 Thanks for the quick response mate. that looks like what i'm after. Just one thing, how to i edit the code to go to either a sucess page or got to the error page? Cheers. Quote Link to comment https://forums.phpfreaks.com/topic/229116-if-else-statements-php-newbe-still-struggling/#findComment-1180698 Share on other sites More sharing options...
flolam Posted February 28, 2011 Share Posted February 28, 2011 use http://php.net/manual/de/function.header.php Quote Link to comment https://forums.phpfreaks.com/topic/229116-if-else-statements-php-newbe-still-struggling/#findComment-1180701 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.