Solved

Problem with directing to correct pages

Posted on 2006-07-17
5
171 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
Comment Utility
// 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
Comment Utility
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
Comment Utility
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
Comment Utility
guess I'll stick with this solution so :)
Thanks TeRReF
0
 
LVL 29

Expert Comment

by:TeRReF
Comment Utility
You're welcome :)
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Generating table dynamically is the most common issue faced by php developers.... So it seems there is a need of an article that explains the basic concept of generating tables dynamically. It just requires a basic knowledge of html and little maths…
Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
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…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

771 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now