Solved

PHP- why does this not select the posted value?

Posted on 2006-06-26
2
253 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
2 Comments
 
LVL 3

Accepted Solution

by:
AndyWHV earned 500 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

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

Here we come across an interesting topic of coding guidelines while designing automation test scripts. The scope of this article will not be limited to QTP but to an overall extent of using VB Scripting for automation projects. Introduction Now…
Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

932 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

13 Experts available now in Live!

Get 1:1 Help Now