Form to E-Mail...working, but...


#1

hello…

Building a website for my local area of NA; & need lots of forms…learned form coding on my own…testing the site on one of my music site servers…my first form is basic, but covers all the info I need returned…(click on the ‘GROUP ANNIVERSARY FORM’ link…top right): http://www.moonjams.net/events5.html

So…When info is entered in all fields; & the SUBMIT button is hit…the info is sent to my e-mail address; & the thank you page pops up. Trouble is, in the e-mail I receive…I’m only getting data from two fields…the ‘time’ of the anniversary and the ‘event description’, which are the last two fields.

Here is the form page code:
[php]

Burlington County Area of NA - Events5 body { background-image: url(SAM_5626-II.jpg); }
BURLINGTON COUNTY AREA of Narcotics Anonymous
UPCOMING EVENTS

Group Anniversary Form:

Home Group Name:

Home Group Address:

# of Years Celebrating:

Anniversary Day & Date:

Anniversary Time:

Briefly Decribe the Event:



Thank you!
[/php] ...& here is the PHP code: [php]<?php if(!isset($_POST['submit'])) { echo "error; you need to submit the form!"; } $message = $_POST['message']; $message = $_POST['message']; $name = $_POST['name']; $name = $_POST['name']; $name = $_POST['name']; $message = $_POST['message'];

if(empty($message)||empty($name))
{
echo “Home Group Name and all relative info is mandatory!”;
exit;
}

$email_from = ’ ';
$email_subject = “Events Page New Form Submission”;
$email_body = “You have received Events information from $name.\n”.
“Here is the message:\n $message”.

$to = "mark4man@comcast.net";
$headers = “From: $email_from \r\n”;
$headers .= “Reply-To: $visitor_email \r\n”;

mail($to,$email_subject,$email_body,$headers);

header(‘Location: thank-you.html’);

function IsInjected($str)
{
$injections = array(’(\n+)’,
‘(\r+)’,
‘(\t+)’,
‘(%0A+)’,
‘(%0D+)’,
‘(%08+)’,
‘(%09+)’
);
$inject = join(’|’, $injections);
$inject = “/$inject/i”;
if(preg_match($inject,$str))
{
return true;
}
else
{
return false;
}
}

?>
<!doctype html>

Events - PHP [/php] can anyone please help?...(I've almost got this)...thanx,

mark4man


#2

You copied and pasted the form elements. So, you have multiple elements with the same name, “name”, resulting in the last value for it rather than all of those inputs.


#3

astonecipher…

thanx very much…!!!..& yes, I know. Also, the two message fields have the same names as well. I had thought that may be the problem, so I did try 7 different names (for the 7 different form fields), but it didn’t work because…not being a coder…I have no idea which part of the snippet to customize [& the informational I got the code from…(I think it was from LinkedIn) wasn’t specific as to how to exactly customize your own fields]. If you could just give me one ‘name’ example & one ‘message’ example, I would be eternally grateful.

thanx again,


mark4man


#4

You need to give the form fields sensible names.

[php] Home Group Name:

[/php]

this could be called group_name instead (you can give it any name you want, just be consistent)

[php] Home Group Name:

[/php]

[hr]

Then you need to make the same change in the PHP code handling the form

[php]
$message = $_POST[‘message’];
$message = $_POST[‘message’];
$name = $_POST[‘name’];
$name = $_POST[‘name’];
$name = $_POST[‘name’];
$message = $_POST[‘message’];[/php]

[php]
$field1Name= $_POST[‘field1Name’];
$groupName= $_POST[‘group_name’];
$field3Name= $_POST[‘field3Name’];
$field4Name= $_POST[‘field4Name’];
$field5Name= $_POST[‘field5Name’];
$field6Name= $_POST[‘field6Name’];[/php]

[hr]

You then need to combine the fields together into a message string that will make sense for you in an email

Note that in your current form handling you use name and email_from in the email to set the sender. You never get this data anywhere (you don’t even have name/email fields in your form)


#5

JimL…

THANX! (just got back here…sorry for the delayed response)

mark4man