View Full Version : How can I send an array to e-mail from a form?

11-13-2011, 10:18 AM
The form below works except the checkboxes named "features" returns in the e-mail as the word "Array" instead of the actual array of variables checked. What PHP code am I missing that corrects this? All styling has been removed for easier viewing.


$message="Title: $title \nURL: <a href='$url'>$url</a> \nE-mail: $email \nDescription: $description
\nFeatures: $features \nGenre: $genre \nUpdate: $update \nAge: $age \n
Movies: $movies \nReference: $reference \nOther: $other";

if (strpos($email,"@")==0 or strpos($email,".")==0){$email="";}

if ($email!="" and $description!="" and $title!="" and $url!=""){
mail("my@email.com","Subject", $message,"From: <my@email.com>\nContent-Type: text/plain");
print "<p id='submissionConfirmation'>Submission Sent!</p>";


<form method=post action=<? print $_SERVER["PHP_SELF"]; ?>>

Site Title:<input name="title">
URL:<input name="url">
E-mail:<input name="email">

<input type="checkbox" name="features[]" value="News" /> News<br />
<input type="checkbox" name="features[]" value="Reviews" /> Reviews<br />
<input type="checkbox" name="features[]" value="Interviews" /> Interviews<br />
<input type="checkbox" name="features[]" value="Editorials" /> Editorials<br />
<input type="checkbox" name="features[]" value="Humor" /> Humor<br />
<input type="checkbox" name="features[]" value="Gossip" /> Gossip<br />
<input type="checkbox" name="features[]" value="Podcasts" /> Podcasts<br />
<input type="checkbox" name="features[]" value="Video" /> Videos (Original)<br />
<input type="checkbox" name="features[]" value="Non-Movie" /> Non-Movie Topics

<select name="genre">
<option value="All / Other">All / Other</option>
<option value="Animation / Anime">Animation / Anime</option>
<option value="Classic">Classic</option>
<option value="Comedy">Comedy</option>
<option value="Horror">Horror</option>
<option value="Independent / Foreign">Independent / Foreign</option>
<option value="Nerdy (Sci-fi, Fantasy, etc.)">Nerdy (Sci-fi, Fantasy, etc.)</option>
<option value="Film Noir">Film Noir</option>
<option value="TV">TV</option>

How often do you update?:
<select name="update">
<option value="No Answer">Select One&hellip;</option>
<option value="Daily">Daily</option>
<option value="Every Other Day">Every Other Day</option>
<option value="Weekly">Weekly</option>
<option value="Bi-Weekly">Bi-Weekly</option>
<option value="Monthly">Monthly</option>

How old is your site?:
<select name="age">
<option value="No Answer">Select One&hellip;</option>
<option value="1 - 3 Months">1 - 3 Months</option>
<option value="3 - 6 Months">3 - 6 Months</option>
<option value="6 - 12 Months">6 - 12 Months</option>
<option value="1 - 2 Years">1 - 2 Years</option>
<option value="2+ Years">2+ Years</option>

List 3 of your favorite movies:
<textarea name="movies"><? print $text; ?></textarea>

Where did you first hear about CineBloggers?:
<textarea name="reference"><? print $text; ?></textarea>

Any other questions you would like to answer that have not been covered?:
<textarea name="other"><? print $text; ?></textarea>

<input type="submit" height="33" width="100" name="submit" value="Submit">

<? } ?>

11-13-2011, 03:45 PM
This is not the correct forum for that. Much better would be the PHP forum.

11-13-2011, 04:56 PM
why applying everything in a single php file ? create two separate files one html and one php html file will have the structure and JS to validate the fields and the php file will send you the email of whatever information has been filled on the first form using POST method. If you want I can create one for you

P S : I have executed your script write now it is very messed up :S

11-15-2011, 06:03 AM
EDIT: I have updated the code and question to make it as simple as possible. Any help is appreciated.

Also, could a mod move this to the PHP forum now that the problem has been narrowed down to PHP?