/    Sign up×
Community /Pin to ProfileBookmark

POST multiple selections

I’m very green when it comes to PHP, but am learning. Anyhow, here is my problem… I have created a simple mail form that sends the posted HTML data to a PHP form which sends it to my email. I’m sure you’re all familiar. My problem is I’ve added a drop down list with multiple selections enabled, but it doesn’t post the all selections only the first one picked. I don’t know what I need to do to get it to post every selection.

[B]This is the page:[/B]
[url]http://www.digitalartsolutions.com/html/artwork/cc.htm[/url]

[B]Form[/B]

[code=html]<form method=”post” action=”../../php/artwork/info.php”>

<p><strong>Name:</strong><br>
<input type=”text” name=”name” size=30></p>

<p><strong>Company:</strong><br>
<input type=”text” name=”company” size=30></p>

<p><strong>Phone:</strong><br>
<input name=”phone” type=”text” size=30 maxlength=”13″></p>

<p><strong>Email:</strong><br>
<input type=”text” name=”email” size=30></p>

<p><strong>Address</strong><br>
<input type=”text” name=”address1″ size=”30″ maxlength=”50″>
</p>
<p><strong>City</strong><br>
<input type=”text” name=”city” size=”30″ maxlength=”40″>
</p> <p><strong>State</strong><br>
<input type=”text” name=”state” size=”2″ maxlength=”2″>
</p>

<p><strong>Artwork:</strong><br>
<select name=”artwork” size=”6″ multiple>
<option value=”Smart Templates 04″>Smart Templates 04</option>
<option value=”Smart Templates 03″>Smart Templates 03</option>
<option value=”Smart Templates 02″>Smart Templates 02</option>
<option value=”Smart Templates 01″>Smart Templates 01</option>
<option value=”Sports and Mascots 02″>Sports and Mascots 02</option>
<option value=”Sports and Mascots 01″>Sports and Mascots 01</option>
<option value=”Power Graphics 02″>Power Graphics 02</option>
<option value=”Power Graphics 01″>Power Graphics 01</option>
<option value=”Creative Concepts” selected>Creative Concepts</option>
<option value=”Destination Graphics”>Destination Graphics</option>
<option value=”Digital Art Library”>Digital Art Library</option>
<option value=”EPS Clipart Library”>EPS Clipart Library</option>
<option value=”Vector Art Mega Collection 02″>Vector Art Mega Collection 02</option>
<option value=”Vector Art Mega Collection 01″>Vector Art Mega Collection 01</option>
<option value=”Digital Racing Collection”>Digital Racing Collection</option>
<option value=”Smart Concepts”>Smart Concepts</option>
</select>
</p>

<p><input type=”submit” name=”submit” value=”Send”></p>

</form>
[/code]

[B]PHP[/B]

[code=php]<?

$msg .= “Name: $_POST[name] n”;
$msg .= “Company: $_POST[company] n”;
$msg .= “Phone: $_POST[phone] n”;
$msg .= “Email $_POST[email] n”;
$msg .= “Artwork: $_POST[artwork] n”;
$msg .= “Message: $_POST[message] nn”;

$to = “[email protected]”;
$subject = “Artwork Info Request”;

$mailheaders = “Artwork Info n”;
$mailheaders .= “Reply-To: $_POST[email]nn”;

mail($to, $subject, $msg, $mailheaders);
?>

<html>
<head>
<title>Artwork Request Form</title>

<link href=”../../css/global.css” rel=”stylesheet” type=”text/css”>

<meta http-equiv=”Content-Type” content=”text/html; charset=iso-8859-1″></head>
<body bgcolor=”#efefef”>

<h4>Information Sent: </h4>

<p class=”bolder”><strong>Name: </strong></p>
<p><? echo “$_POST[name]”; ?></p>
<p class=”bolder”><strong>Company: </strong></p>
<p><? echo “$_POST[company]”; ?></p>
<p class=”bolder”><strong>Phone: </strong></p>
<p ><? echo “$_POST[phone]”; ?></p>
<p class=”bolder”><strong>Email: </strong></p>
<p ><? echo “$_POST[email]”; ?></p>
<p class=”bolder”><strong>Artwork: </strong></p>
<p><? echo “$_POST[artwork]”; ?></p>
<p class=”bolder”><strong>Message: </strong></p>
<p><? echo “$_POST[message]”; ?></p>

</body>
</html>[/code]

to post a comment
PHP

1 Comments(s)

Copy linkTweet thisAlerts:
@NogDogJul 06.2006 — Change the name of the select element to "artwork[]". Then in your form-handler PHP script the selections will be available in an array called $_POST['artwork'], with a second, numeric index for each selection the user made, e.g. $_POST['artwork'][1] would hold one of the selections. You can do a print_r($_POST); (inside of <pre> tags) for testing purposes to see what the post data looks like.
×

Success!

Help @csramin spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.25,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...