Solved

Problem with directing to correct pages

Posted on 2006-07-17
5
204 Views
Last Modified: 2006-11-18
Hi all,
I have a page where I trying to direct to two different pages based on what the user selects from the drop-down. For some reason this script is no longer functioning for me and keeps directing to the reg1dborg.php page regardless of what the user selects. Is there a better way of doing this or could someone tell me what I'm doing wrong here?
Thanks so much,
D

<?php
if (array_key_exists('cat_select', $_POST)) {
  $chosenoption = ($_POST['cat_select'] == '1') ? '1' : '3';
  if ($chosenoption == 'yes')
    header('location: reg1dbper.php');
  else
    header('location: reg1dborg.php');
}  ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Main Registration Page</title>
</head>

<body>
<form id="form1" name="form1" method="post" action="<?php $_SERVER['PHP_SELF']; ?>">
  <?php $_POST['cat_select'] ?>
  <label for="select">What  are You?</label>
  <p>
    <select name="cat_select" id="cat_select">
      <option value="1">Individual </option>
      <option value="3">Organisation</option>
    </select>
</p>
  <p>
    <label for="Submit"></label>
    <input type="submit" name="Submit" value="Proceed" id="Submit" />
</p>
</form>
</body>
</html>
0
Comment
Question by:dereksheahan
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 29

Accepted Solution

by:
TeRReF earned 400 total points
ID: 17120691
// here you assign either '1' or '3' to $chosenoption
$chosenoption = ($_POST['cat_select'] == '1') ? '1' : '3';
so, this should be
  if ($chosenoption == '1') // or '3'
0
 

Author Comment

by:dereksheahan
ID: 17120715
Thanks TeRReF,
Is this the best way to do it. Do I really need to send the page back to itself first?
Thanks
D
0
 
LVL 29

Expert Comment

by:TeRReF
ID: 17120736
I think so.
Of course there is Javascript you can use, but that will exclude some users since not everyone has it enabled in their browsers...
0
 

Author Comment

by:dereksheahan
ID: 17120743
guess I'll stick with this solution so :)
Thanks TeRReF
0
 
LVL 29

Expert Comment

by:TeRReF
ID: 17120751
You're welcome :)
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses four methods for overlaying images in a container on a web page
This article discusses how to implement server side field validation and display customized error messages to the client.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question