Hello all,
I'm very new to programming (especially php) and I've created an incredibly simple form that I would like visitors to submit on sign up. The form is a multiple-select list submitted via $POST to a PHP file and then emailed to the administrator.
The Script is as follows:
<script type="text/javascript">
function onclick()
{
for (var i = 0; i < document.getElementById("interests").options.length; i++)
{
document.getElementById("interests").options[i].selected = true;
}
return true;
}
</script>
The HTML code is
<form id="form1" name="form1" method="post" action="email_form.php">
<p>
<select name="interests[]" size="7" multiple="multiple" id="interests" style="width: 250px" tabindex="1">
<option value="Arts">Arts and Crafts</option>
<option value="Beauty">Beauty and Personal Care</option>
<option value="Cars">Cars and Accessories</option>
<option value="Cell">Cell Phones and Accessories</option>
<option value="MenClothing">Clothing - Men</option>
<option value="WomenClothing">Clothing - Women</option>
<option value="Computers">Computers and Accessories</option>
<option value="Fitness">Fitness</option>
</select>
<p><span id="sprytextfield1">
<input type="text" name="emailid" id="emailid" tabindex="2" style="width: 250px"/>
<span class="textfieldRequiredMsg">A value is required.</span><span class="textfieldInvalidFormatMsg">!</span></span></p>
<input type="submit" name="submit" id="submit" value="Join" tabindex="3" style="width: 115px"/>
</p>
<p> </p>
</form>
And the PHP:
<?php
$to = "admin@example.com";
$subject = "New member signup";
$message = "Member email address: " . $_POST['emailid'] . "\r\n" .
"interests: " . $_POST['interests'][$i];
$from = $_POST['emailid'];
$headers = "From: $from" . "\r\n";
mail($to,$subject,$message,$headers);
?>
Everything works fine in the html, so I think my problem is in the PHP code. The admin email receives the emailid of the user and the text "interests :" but it doesn't actually display the interests, just "Array"
Can any wise PHP sages help me out? I've been searching for hours for a solution but can't make heads or tails of anything.
Thanks!