NamePros
Welcome, Guest! Ready to make a name for yourself in the domain business? We welcome both the hobbyist and professional domainer to join the discussion as part of the NamePros community.

Click here to create your profile to start earning reputation for posting, and trader ratings for buying & selling in our free e-marketplace. Build your trader rating with each successful sale. Our system has tracked over 100,000 sales and counting!
FAQ & TOS Register Search Today's Posts Mark Forums Read

Go Back   NamePros.com > Website Development Discussion Forums > Programming
Reload this Page Populate a dropdown for PHP form

Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics.

Advanced Search


Closed Thread
 
LinkBack Thread Tools
Old 08-10-2005, 04:11 AM THREAD STARTER               #1 (permalink)
NamePros Member
Join Date: May 2005
Location: Norfolk UK
Posts: 32
static1635 is an unknown quantity at this point
 



Populate a dropdown for PHP form


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
__________________
Justin's Squat
http://grelizard.nfshost.com/
static1635 is offline  
Old 08-10-2005, 04:19 AM   #2 (permalink)
Professional Monkey
 
Amnezia's Avatar
Join Date: Jul 2005
Location: Escaped from the zoo
Posts: 907
Amnezia has a spectacular aura aboutAmnezia has a spectacular aura about
 


Cancer Survivorship Save a Life
i dont quite know what you mean but this is the code for a drop down list

PHP Code:
<select name='menuselect'>
    <
option>option1</option>
????: NamePros.com http://www.namepros.com/programming/114318-populate-a-dropdown-for-php-form.html
    <
option>option2</option>
    <
option>option3</option>
</
select
__________________
Webmaster Words
Amnezia is offline  
Old 08-10-2005, 04:47 AM THREAD STARTER               #3 (permalink)
NamePros Member
Join Date: May 2005
Location: Norfolk UK
Posts: 32
static1635 is an unknown quantity at this point
 



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 bob@microsoft.com
mail("linkdirectory@greylizard.net", "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>
????: NamePros.com http://www.namepros.com/showthread.php?t=114318
<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>
__________________
Justin's Squat
http://grelizard.nfshost.com/
static1635 is offline  
Old 08-10-2005, 05:01 AM   #4 (permalink)
Professional Monkey
 
Amnezia's Avatar
Join Date: Jul 2005
Location: Escaped from the zoo
Posts: 907
Amnezia has a spectacular aura aboutAmnezia has a spectacular aura about
 


Cancer Survivorship Save a Life
i think this is what your looking for

PHP Code:
<form action="sel.php" method="post">
????: NamePros.com http://www.namepros.com/showthread.php?t=114318
    <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
__________________
Webmaster Words
Amnezia is offline  
Old 08-10-2005, 05:15 AM THREAD STARTER               #5 (permalink)
NamePros Member
Join Date: May 2005
Location: Norfolk UK
Posts: 32
static1635 is an unknown quantity at this point
 



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("myname@mydomain.net", "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">
????: NamePros.com http://www.namepros.com/showthread.php?t=114318
<input type="reset" value="Reset">
__________________
Justin's Squat
http://grelizard.nfshost.com/
static1635 is offline  
Old 08-10-2005, 05:26 AM   #6 (permalink)
Professional Monkey
 
Amnezia's Avatar
Join Date: Jul 2005
Location: Escaped from the zoo
Posts: 907
Amnezia has a spectacular aura aboutAmnezia has a spectacular aura about
 


Cancer Survivorship Save a Life
when you create it, it says "categroy"

when you reference it it says "category"
__________________
Webmaster Words
Amnezia is offline  
Old 08-10-2005, 05:32 AM THREAD STARTER               #7 (permalink)
NamePros Member
Join Date: May 2005
Location: Norfolk UK
Posts: 32
static1635 is an unknown quantity at this point
 



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
__________________
Justin's Squat
http://grelizard.nfshost.com/
static1635 is offline  
Closed Thread


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools


Similar Threads
Thread Thread Starter Forum Replies Last Post
Paypal Settlement CMachuca The Break Room 3 07-31-2004 11:14 PM
PAYPAL Litigation johnn Domain Name Discussion 6 07-31-2004 10:51 PM
Paypal Settlement Lord The Break Room 2 07-30-2004 10:30 PM

Liquid Web Smart Servers  
All times are GMT -7. The time now is 07:03 AM.

Managed Web Hosting by Liquid Web
Domain name forum recommended by Domaining.com Powered by: vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.6.0 Ad Management plugin by RedTyger