[advanced search]
 

Go Back   NamePros.com > Discussion > Web Design & Development > Programming

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


Closed Thread
 
LinkBack Thread Tools
Old 08-10-2005, 03:11 AM   #1 (permalink)
NamePros Member
 
Join Date: May 2005
Location: Norfolk UK
Posts: 32
42.00 NP$ (Donate)

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, 03:19 AM   #2 (permalink)
Professional Monkey
 
Amnezia's Avatar
 
Join Date: Jul 2005
Location: Escaped from the zoo
Posts: 908
13.25 NP$ (Donate)

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>
    <
option>option2</option>
    <
option>option3</option>
</
select>
__________________
[http://www.webmasterwords.com/python-split-and-join-examples]Python Tutorials[/url]
Amnezia is offline  
Old 08-10-2005, 03:47 AM   #3 (permalink)
NamePros Member
 
Join Date: May 2005
Location: Norfolk UK
Posts: 32
42.00 NP$ (Donate)

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>
<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, 04:01 AM   #4 (permalink)
Professional Monkey
 
Amnezia's Avatar
 
Join Date: Jul 2005
Location: Escaped from the zoo
Posts: 908
13.25 NP$ (Donate)

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">
    <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
__________________
[http://www.webmasterwords.com/python-split-and-join-examples]Python Tutorials[/url]
Amnezia is offline  
Old 08-10-2005, 04:15 AM   #5 (permalink)
NamePros Member
 
Join Date: May 2005
Location: Norfolk UK
Posts: 32
42.00 NP$ (Donate)

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">
<input type="reset" value="Reset">
__________________
Justin's Squat
http://grelizard.nfshost.com/
static1635 is offline  
Old 08-10-2005, 04:26 AM   #6 (permalink)
Professional Monkey
 
Amnezia's Avatar
 
Join Date: Jul 2005
Location: Escaped from the zoo
Posts: 908
13.25 NP$ (Donate)

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"
__________________
[http://www.webmasterwords.com/python-split-and-join-examples]Python Tutorials[/url]
Amnezia is offline  
Old 08-10-2005, 04:32 AM   #7 (permalink)
NamePros Member
 
Join Date: May 2005
Location: Norfolk UK
Posts: 32
42.00 NP$ (Donate)

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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


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

Site Sponsors
Advertise your business at NamePros

All times are GMT -7. The time now is 03:26 AM.


Powered by: vBulletin® Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0
Template-Modifications by TMS
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85