Solved

Problem with directing to correct pages

Posted on 2006-07-17
5
197 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
  • 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
This article discusses four methods for overlaying images in a container on a web page
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 count occurrences of each item in an array.

828 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