Page 1 of 1

PHP Form Page Switcher

Posted: Mon Nov 08, 2010 7:11 am
by paulcronin
Hi All,

I want to make a very simple 'search tool' that works by matching words from a form's input box to a specific page (i.e. if you enter 'Contact' the form would redirect you to contact.html).

index.html
<form method='post' action='forwarder.php'>
<input id="myInput" type="text">
<input type='submit'>
</form>

forwarder.phpThis doesn't work, but you get the idea...
<?php
switch($myInput) {
default:
include('no_match.html');
break; case "about":
include('about.html');
break; case "contact":
include('contact.html');
break; case "page1":
include('page1.html');
break; case "page2":
include('page2.html');
break; case "page3":
include('page3.html');
}
?>

Please can you help me with forwarder.php?

Thank you,
Paul

Re: PHP Form Page Switcher

Posted: Mon Nov 08, 2010 9:42 am
by AbraCadaver
You are posting data from the form so the data is in the $_POST array:

Code: Select all

switch($_POST['myInput']) {