?
Solved

PHP- why does this not select the posted value?

Posted on 2006-06-26
2
Medium Priority
?
258 Views
Last Modified: 2010-04-17


<!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>Untitled Document</title>
</head>

<body>

<form action="testy.php" method="post">
<select name="listname">
<option value="php3"<? if(isset($_POST['listname']) && $_POST['listname'] == 'php3'){echo  ' selected = "selected" '; }?>> PHP 3</option>

<option value="php4"<? if(isset($_POST['listname']) && $_POST['listname'] == 'php3'){echo  ' selected = "selected"'; }?>> PHP 4</option>

<option value="php5"<? if(isset($_POST['listname']) && $_POST['listname'] == 'php3'){echo  ' selected = "selected"'; }?>>PHP 5</option>

</select>

<input type="submit" name="Submit" value="Submit" />
</form>
</body>
</html>
0
Comment
Question by:roscoeh23
[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
2 Comments
 
LVL 3

Accepted Solution

by:
AndyWHV earned 2000 total points
ID: 16982885
The Problem is the login in the if structure...

look at
if ( (isset($_POST['listname'])) && ($_POST['listname'] == 'php3') )

you check for php3 every time.

Greetz
Andy ;-)
0
 
LVL 2

Expert Comment

by:T3Logic
ID: 16984016
<option value="php3"<? if(isset($_POST['listname']) == 'php3'){echo  ' selected = "selected" '; }?>> PHP 3</option>

<option value="php4"<? if(isset($_POST['listname']) == 'php4'){echo  ' selected = "selected"'; }?>> PHP 4</option>

<option value="php5"<? if(isset($_POST['listname']) == 'php5'){echo  ' selected = "selected"'; }?>>PHP 5</option>
0

Featured Post

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

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

Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
What do responsible coders do? They don't take detrimental shortcuts. They do take reasonable security precautions, create important automation, implement sufficient logging, fix things they break, and care about users.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Simple Linear Regression
Suggested Courses

777 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