Solved

Problem with directing to correct pages

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
The viewer will learn how to dynamically set the form action using jQuery.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

863 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

22 Experts available now in Live!

Get 1:1 Help Now