473,405 Members | 2,141 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

directing user to different pages based on their responses

Could someone help me with the following problem?

I am running the pages on a php server. On page 1, I ask users to
answer one radio-button question which has options (a), (b), (c), and
(d). Based on their answer, I need to load different page 2
accordingly. At the same time, I need to save the answer for the one
question on page 1 to the database. I know how to save the answer to
the database. But, I don't know how to write the code for
differentiating which page to load and where to place the code (on
page 1 or page 2). Could someone help me, please? Thank you very
much.
Jul 17 '05 #1
1 1541
houstoncity wrote:
Could someone help me with the following problem?

I am running the pages on a php server. On page 1, I ask users to
answer one radio-button question which has options (a), (b), (c), and
(d). Based on their answer, I need to load different page 2
accordingly. At the same time, I need to save the answer for the one
question on page 1 to the database. I know how to save the answer to
the database. But, I don't know how to write the code for
differentiating which page to load and where to place the code (on
page 1 or page 2). Could someone help me, please? Thank you very
much.


There are a number a ways to do this. Here are three.
First way, store the URLS of the different "page 2"s in an array
<?
$page2url = array('a' => 'page2a',
'b'=>'another_page2',
'c'=>'yet_another_page2',
'd'=>'page2d')
if (isset($_POST['answer'])){ // $_POST['answer'] has the value of the
radio button
header('location: http://your.web.site/' .
$page2url[$_POST['answer']] . '.php');
exit(); }
?>

Second, name you "page2"s so they have the answer in their filename,
i.e. page2a.php:
<?
if (isset($_POST['answer'])) {
header('location http://your.web.site/page2' . $_POST['answer'] .
'.php');
exit();
?>

Third, keep all of your code in on file, then there is no need to pass
answers anywhere:
<?
if (isset($_POST['answer']))
switch ($_POST['answer']) {
case 'a':
// do work for answer a
break;
case 'b':
// do work for answer b
break;
case 'c':
// do work for answer c
break;
case 'd':
// do work for answer d
break;
}

The above code hasn't been tested, so YMMV.

Ken

Jul 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

60
by: Fotios | last post by:
Hi guys, I have put together a flexible client-side user agent detector (written in js). I thought that some of you may find it useful. Code is here: http://fotios.cc/software/ua_detect.htm ...
2
by: houstoncity | last post by:
Hi, I am wondering how to write the code that allows navigating to different pages based on user response. I have one question on the first page that has option (a), (b), (c), and (d) for the...
8
by: Ian Davies | last post by:
Hello I am trying to run a few INSERT queries only if the user clicks 'continue' in a <a href> The queries takes variables created from SELECT queries. I have tried to acheive this by putting The...
3
by: Amir Eshterayeh | last post by:
Dear Friends Would you please give me your professional idea about this asp.net problem. I need different virtual directory for different customer with their names like these:...
7
by: jsale | last post by:
I'm currently using ASP.NET with VS2003 and SQL Server 2003. The ASP.NET app i have made is running on IIS v6 and consists of a number of pages that allow the user to read information from the...
2
by: Stewart Rogers | last post by:
Hi all, I have been working on an ASP.NET application that is a kind of wizard ( a list of sequential pages ). We built that application for the CLIENT-A and it worked fine. After six months...
24
by: Rob R. Ainscough | last post by:
VS 2005 I have: ClickOnce deployment User's that hate and or don't want to use an IE Client (don't blame them) I don't see how ASPX web pages are going to survive? With .NET 2.0 and clickonce...
6
by: goraya | last post by:
This is design level discussion about web applications. How I design application that support 1 million concurrent requests??
3
by: kcddoorman | last post by:
Environment: Windows 2000 Server IIS 5.0 Access 2003 IIS is set up for basic authentication. This means I can set rights for logged in users using NTFS file permissions. This all works well for...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.