Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Problem with directing to correct pages

Posted on 2006-07-17
5
Medium Priority
?
214 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 1600 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

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this. Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it i…
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 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 …
Suggested Courses

636 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