Unstoppable Domains

Populate a dropdown for PHP form

Spaceship Spaceship
Watch

static1635

Established Member
Impact
0
Hi
can any one tell me how to populate a drop down for a php form?
you can see the one I have done on my website:
http://www.greylizard.net/linkdirectory/addyourlink.php
the form works ok but just the dropdown has no php form values, and I can't work out how to add those
Thanks
Justin
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
i dont quite know what you mean but this is the code for a drop down list

PHP:
<select name='menuselect'>
    <option>option1</option>
    <option>option2</option>
    <option>option3</option>
</select>
 
0
•••
Yes that is what I have at the moment.
I am not sure the best way to describe it, it's just that when someone selects the dropdown and sends the form the value they selected with the dropdown is not transmitted along with the other items which have nice php values handled by the post and mail functions which I have built in o.k.

some code from the page:


// Handle POST method.
if ($_POST)
{
$name = $_POST['name'];
$email = $_POST['email'];
$linkname = $_POST['linkname'];
$url = $_POST['url'];
$description = $_POST['description'];
$category = $_POST['category'];
$categorysug = $_POST['categorysug'];
$linkback = $_POST['linkback'];



// Compose simple text message:
$message = "linkdirectory\r\n
Name: $name\r\n
email: $email\r\n
Link name: $linkname\r\n
URL: $url\r\n
Description: $description\r\n
Category: $category\r\n
Category Sug: $categorysug\r\n
Link back: $linkback\r\n



";


// Send message to [email protected]
mail("[email protected]", "Link Directory Add", $message);

// Thank the generous user
echo "<h2>Your information has been submitted, thank you.</h2>\n";
}
else
{

?>
<div align="center">
<table border="0" cellpadding="0" cellspacing="0">
<tr>
<td> <form action="<?= $PHP_SELF ?>" method="post">
<table border="0" cellspacing="0" cellpadding="3">
<tr>
<td><font size="-1">Your name</font></td>
<td><font size="-1">
<input name="name" type="text" >
</font></td>
</tr>
<tr>
<td><font size="-1">e-mail</font></td>
<td><font size="-1">
<input name="email" type="text" >
</font></td>
</tr>
<tr>
<td><font size="-1">Site name</font></td>
<td><font size="-1">
<input name="linkname" type="text" size="40" >
</font></td>
</tr>
<tr>
<td><font size="-1">URL to add</font></td>
<td><font size="-1">
<input name="url" type="text" size="40" >
</font></td>
</tr>
<tr>
<td><font size="-1">Short description</font></td>
<td><font size="-1">
<input name="description" type="text" size="50" >
</font></td>
</tr>
<tr>
<td><font size="-1">Category</font></td>
<td><select name="categroy">
<option>Automotive</option>
<option>Alternative</option>
<option>Music</option>
<option>Online shops</option>
<option>Travel</option>
<option>Cats</option>
<option>Webdesign</option>
<option>Personal sites</option>
<option>Misc</option>
<option>Adult</option>
</select> <font size="-1">(or suggested)
<input name="categorysug" type="text" >
</font></td>
</tr>
<tr>
<td><font size="-1">Link back URL</font></td>
<td><font size="-1">
<input name="linkback" type="text" size="40" >
</font></td>
</tr>
</table>
<p><font size="-1">Please allow 1 week to be included,
link back preferred (<a href="linkback.html" target="_blank"><u>options</u></a>).<br>
Submission at discretion of webmaster and does not guarantee
listing.</font></p>
<p>
<input type="submit" value="Submit">
<input type="reset" value="Reset">
</p>
</form></td>
</tr>
</table>
 
0
•••
i think this is what your looking for

PHP:
<form action="sel.php" method="post">
    <select name='menuselect'>
        <option>option1</option>
        <option>option2</option>
        <option>option3</option>
    </select>
    <input type="submit" value="Submit"></input>
</form>

<?

if (isset($_POST['menuselect'])){
    echo $_POST['menuselect'];
}

the selected option is posted via the select object
 
0
•••
So... how does that differ to what I have?....

// Handle POST method.
if ($_POST)
{
$category = $_POST['category'];


// Compose simple text message:
Category: $category\r\n
";

--snip--

// Send message
mail("[email protected]", "Link Directory Add", $message);

--snip--

<form action="<?= $PHP_SELF ?>" method="post">
<select name="categroy">
<option>Automotive</option>
<option>Alternative</option>
<option>Music</option>
<option>Online shops</option>
<option>Travel</option>
<option>Cats</option>
<option>Webdesign</option>
<option>Personal sites</option>
<option>Misc</option>
<option>Adult</option>
</select>
<input type="submit" value="Submit">
<input type="reset" value="Reset">
 
0
•••
when you create it, it says "categroy"

when you reference it it says "category"
 
0
•••
Oh thanks! Doh! Aren't I a twit? I thought something was wrong but I just couldn't see it, and they say dyslexics are good webmasters!

Thanks for that, you are a star :)
 
0
•••
Dynadot — .com Registration $8.99Dynadot — .com Registration $8.99

We're social

Unstoppable Domains
Domain Recover
DomainEasy — Zero Commission
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back