# Mail Form

**URL:** <https://forum.kirupa.com/t/mail-form/263752>\
**Category:** Uncategorized\
**Created:** [June 18, 2008, 9:35pm UTC](https://forum.kirupa.com/t/mail-form/263752 "2008-06-18T21:35:50Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![loydster](https://avatars.discourse-cdn.com/v4/letter/l/cdc98d/32.png) [@loydster](https://forum.kirupa.com/u/loydster)\
**Post date:** [June 18, 2008, 9:35pm UTC](https://forum.kirupa.com/t/mail-form/263752/1 "2008-06-18T21:35:50Z")

</div>

Hey All~

I am a n00b and looking for some help, please. I am using the Kirupa PHP Mailer, but my server is posting errors on “submit”. Here’s what i have so far:

**My HTML form is formatted thusly:**

\<form method=“POST” action=“mailer.php” style=“background: url(images/portbkg3.gif) no-repeat; padding: 30px; border: 1px;”\>\<br /\>  
Name:  
\<input type=“text” name=“name” size=“29”\>\<br\>

E-Mail:  
\<input type=“text” name=“email” size=“29”\>\<br\>  
\<br\>  
\<strong\>First visit to [loydster.com](http://loydster.com)?\</strong\>\<br /\>\<input type=“radio” value=“yes” name=“radio”\> YES&nbsp;&nbsp;&nbsp;&nbsp;\<input type=“radio” value=“no” name=“radio”\> NO  
\<br\>\<br /\>  
\<strong\>What is the nature of your query?\</strong\>\<br /\>  
\<input type=“checkbox” name=“check[]” value=“opportunity”\> Opportunity&nbsp;\<input type=“checkbox” name=“check[]” value=“quote”\> Quote  
\<input type=“checkbox” name=“check[]” value=“comment”\> Comment\<br\>  
\<br\>  
\<select size=“1” name=“drop\_down”\>  
\<option\>Please select your area of interest:\</option\>  
\<option\>Website Design\</option\>  
\<option\>UI Design\</option\>  
\<option\>Graphic Design\</option\>  
\<option\>Technical Writing or Quality Analysis\</option\>  
\</select\>\<br\>  
\<br\>  
\<strong\>Message:\</strong\>\<br\>  
\<textarea rows=“7” name=“message” cols=“30”\>\</textarea\>\<br\>  
\<br\>  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\<input type=“submit” value=“Submit” name=“submit”\>\<br /\>\<br /\>  
\</form\>

**The form resides on my server [www.loydster.com](http://www.loydster.com) and the SERVER PHP FILE contains this information:**

\<?php  
if(isset($\_POST[‘submit’])) {  
$to = “[loydster@comline.com](mailto:loydster@comline.com)”;  
$subject = “Inquiry or Comment”;  
$name\_field = $\_POST[‘name’];  
$email\_field = $\_POST[‘email’];  
$message = $\_POST[‘message’];  
$option = $\_POST[‘radio’];  
$dropdown = $\_POST[‘drop\_down’];  
foreach($\_POST[‘check’] as $value) {  
$check\_msg .= "Checked: $value  
";  
}

$body = "From: $name\_field  
E-Mail: $email\_field  
$check\_msg Option: $option  
Drop-Down: $dropdown  
Message:  
$message  
";  
echo “Thank you for contacting $to!”;  
mail($to, $subject, $body);

} else {  
echo “Error on email posting.”;  
}  
?\>

**When I post from my Web page, I get the following ERROR MESSAGE:**

Notice: Undefined variable: check\_msg in d:\Customers\user1220675\www\mailer.php on line 13  
Thank you for contacting [loydster@comline.com](mailto:loydster@comline.com)!  
Warning: mail(): SMTP server response: 553 5.3.0 \<[me@localhost.com](mailto:me@localhost.com)\>… DISCARD Spam Relay in d:\Customers\user1220675\www\mailer.php on line 19

The code looks good (to me) and I am wondering if this is a “permissions” issue? Any help is greatly appreciated. And thanks in advance.:pac:

---

<div class="post-metadata">

**Author:** ![agnus](https://avatars.discourse-cdn.com/v4/letter/a/4bbf92/32.png) [@agnus](https://forum.kirupa.com/u/agnus)\
**Post date:** [June 19, 2008, 11:49am UTC](https://forum.kirupa.com/t/mail-form/263752/2 "2008-06-19T11:49:22Z")

</div>

See [here (http://www.larrykooper.com/?p=11](http://www.larrykooper.com/?p=11)) for more info about the mail error. The notice you get about the $check\_msg var is issued because you are doing concatenation on the variable but it does not exist. Try to declare it before the foreach (ie. $check\_msg=’’; )

---

<div class="post-metadata">

**Author:** ![loydster](https://avatars.discourse-cdn.com/v4/letter/l/cdc98d/32.png) [@loydster](https://forum.kirupa.com/u/loydster)\
**Post date:** [June 19, 2008, 7:56pm UTC](https://forum.kirupa.com/t/mail-form/263752/3 "2008-06-19T19:56:37Z")

</div>

Thank you Angus. I viewed the Larry Kooper site and added some code into the PHP. This is what I have now with the new error message:

\<?php  
ini\_set(“sendmail\_from”, “[loyd@loydster.com](mailto:loyd@loydster.com)”);  
if(isset($\_POST[‘submit’])) {  
$to = “[loydster@comline.com](mailto:loydster@comline.com)”;  
$subject = “Inquiry or Comment”;  
$name\_field = $\_POST[‘name’];  
$email\_field = $\_POST[‘email’];  
$message = $\_POST[‘message’];  
$option = $\_POST[‘radio’];  
$dropdown = $\_POST[‘drop\_down’];  
foreach($\_POST[‘check’] as $value) {  
$check\_msg .= “Checked: $value  
”;  
}

$body = “From: $name\_field  
E-Mail: $email\_field  
$check\_msg Option: $option  
Drop-Down: $dropdown  
Message:  
$message  
”;  
echo “Thank you for contacting $to!”;  
mail($to, $subject, $body);

} else {  
echo “Error on email posting.”;  
}  
?\>

Error Message:  
ERROR MESSAGE  
Notice: Undefined variable: check\_msg in d:\Customers\user1220675\www\mailer.php on line 13  
Thank you for contacting [loydster@comline.com!if(isset($\_POST](mailto:loydster@comline.com!if(isset(%24_POST)[‘submit’])) {19

---

<div class="post-metadata">

**Author:** ![yann](https://avatars.discourse-cdn.com/v4/letter/y/bc79bd/32.png) [@yann](https://forum.kirupa.com/u/yann)\
**Post date:** [June 19, 2008, 9:46pm UTC](https://forum.kirupa.com/t/mail-form/263752/4 "2008-06-19T21:46:01Z")

</div>

as the previous poster said, the problem is:

$check\_msg .= “Checked: $value  
”;

You don’t declare it before you use it…

if(isset($\_POST[‘submit’])) {  
$check\_msg =’’;  
$to = "loydster@comline.com";  
$subject = “Inquiry or Comment”;  
etc…

would fix that error

but that script is pretty bare, you should get one with a minimum of security checking so that your form doesn’t become a spammer’s heaven…
