Open different pages depending on value entered into input box

This is a discussion on "Open different pages depending on value entered into input box" within the PHP Forum section. This forum, and the thread "Open different pages depending on value entered into input box are both part of the Program Your Website category.



Go Back   Webforumz.com > Main Forums > Program Your Website > PHP Forum

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Sep 15th, 2006, 13:36
New Member
Join Date: Sep 2006
Location: United Kingdom
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Open different pages depending on value entered into input box

Im hoping somebody can point me in the right direction with this one !

Im have created a page for my companies website that is going to have an input box on, in this box the customer will enter there customer number.

I want it so if the customer number is recognized then the customer is directed to one page but if its not recognized then they are directed to a different page..

I know this is possible but I dont know how to explain it or what its called so I cant just google it !

Any help much appreciated !
Reply With Quote

  #2 (permalink)  
Old Sep 15th, 2006, 14:40
Junior Member
Join Date: Sep 2006
Location: Portugal
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Open different pages depending on value entered into input box

Very simple m8.

You action the form to a specific file, example: goquery.php

And this is your goquery.php

Quote:
<?
if ($_POST['submit']) {
//hoping that the name of your submit button is submit
//then we receive the value
$box = $_POST['name_variable'];

//name_variable once again is the name of the input box.
//now lets check it

switch ($box) {
case 1:
do something;
break;

case 5:
do something for 5;
break;


}

}
Reply With Quote
  #3 (permalink)  
Old Sep 15th, 2006, 14:49
New Member
Join Date: Sep 2006
Location: United Kingdom
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Open different pages depending on value entered into input box

Thanks,

Im not too hot on PHP but i'll have a good go at getting it to work, im sure i'll be back for a few tips though

thx again

Ian
Reply With Quote
  #4 (permalink)  
Old Sep 15th, 2006, 14:54
Junior Member
Join Date: Sep 2006
Location: Portugal
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Open different pages depending on value entered into input box

no problem, m8.

if ur good at IE stupid bugs. check html forum and gimme a BIG hand.
Reply With Quote
  #5 (permalink)  
Old Sep 15th, 2006, 15:03
New Member
Join Date: Sep 2006
Location: United Kingdom
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Open different pages depending on value entered into input box

Sorry, im not a web designer m8, im strictly a drag and dropper lol

If it was a technical issue then maybe I could of helped (im tech support )
Reply With Quote
  #6 (permalink)  
Old Sep 15th, 2006, 17:48
Most Reputable Member
Join Date: Apr 2006
Location: Cornwall, UK
Posts: 1,310
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Skype™ to ukgeoff
Re: Open different pages depending on value entered into input box

Presumably there are only two page options, one for known customers and one for others?

Assuming customer numbers kept on a database and form using method='post'.

Your php code needs to do the following:

The code must start with; ob_start(); This buffers the header output until you have made up your mind what you want to do.

Code: Select all
$custnum = $_POST['custnum'];
... additional code
Code: Select all
$query = 'select id from customers where custnum ='.$custnum;
... more code
Code: Select all
if ($rows == 1){
   header('Location: http://domain.co.uk/customer.html');
}
else {
   header('Location: http://domain.co.uk/notcustomer.html');
}
... anything else you want to do

And finally:
Code: Select all
ob_end_flush();
Sends the header to the browser and the redirection takes place.
Reply With Quote
Reply

Tags
open, different, pages, depending, value, entered, input, box

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Repeat data entered in a text box... and maybe change it? simbo1231 JavaScript Forum 4 Dec 2nd, 2007 10:24
IF value entered is nothing? PicoDeath PHP Forum 16 Aug 2nd, 2007 17:19
How to customize content depending on URL? matthewpage Classic ASP 1 Nov 13th, 2006 04:50
Open a specific page dependent on what is entered into a criteria box??? IanW Web Page Design 2 Sep 15th, 2006 12:39
Resizing a div depending on another div size AdRock Web Page Design 2 Sep 3rd, 2006 14:26


All times are GMT. The time now is 05:52.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43