Page 1 of 1
Help with code
Posted: Wed Mar 03, 2010 12:15 pm
by dbe1800
Hello all,
i need help with my coding for my contact page...
im using flash and action script 3
the site is the5150crew.com - Contact Page
below i put my email.php code notice any errors?
when i test my file i get no errors but the email does not go thru...
<?php
$emailRecipient = "
admin@the5150crew.com";
$emailHeaders = "From:
admin@the5150crew.com\r\nContent-type: text/html\r\n";
$emailHeaders = "Reply-To: " .$_POST["userEmail"]. "\r\n";
$emailHeaders = "\r\n";
foreach ($_POST as $key => $value) {
$$key = stripslashes($value);
}
$emailBody = "<HTML>
<BODY>
<TABLE BORDER='1'>
<TR>
<TD align='left' width='780'>Email : ".$userEmail."</TD>
</TR>
<TR>
<TD align='left' width='780'>Name : ".$userName."</TD>
</TR>
<TR>
<TD align='left' width='780'>Message: <br><br>".$userMessage."</TD>
</TR>
</TABLE>
</BODY>
</HTML>";
if(mail($emailRecipient, "admin Form\n\n", $emailBody, $emailHeaders)){
echo "var1=success";
} else {
echo "var1=failure";
}
?>
Re: Help with code
Posted: Wed Mar 03, 2010 12:48 pm
by flying_circus
First thing that jumps out at me is that you're sending an empty set of headers.
Code: Select all
$emailHeaders = "From: admin@the5150crew.com\r\nContent-type: text/html\r\n";
$emailHeaders .= "Reply-To: " .$_POST["userEmail"]. "\r\n";
$emailHeaders .= "\r\n";
Re: Help with code
Posted: Wed Mar 03, 2010 4:37 pm
by dbe1800
what do you mean can you tell me in detail
how would i fix that?
(im sorry im still learning php)

Re: Help with code
Posted: Wed Mar 03, 2010 5:30 pm
by flying_circus
I posted the solution above. Notice the "." (period) before the equal sign in the bit of code I posted. The period concatenates strings.
Sending email can be a tricky beast, and there are many reasons that it wont go through, and its hard to troubleshoot if the mail has been rejected, filtered, and/or lost in transit. Is the email landing in your spam folder?
Re: Help with code
Posted: Thu Mar 04, 2010 2:43 pm
by dbe1800
yea i tried that one already... i have been stuck on this problem for weeks...
is there any easier way to send contact form email?

Re: Help with code
Posted: Thu Mar 04, 2010 5:57 pm
by olidenia
This sould work, make the 3 imput fields Name Email Message, submit button and call the script below.
Code: Select all
<script language="php">
$from = "From:admin@the5150crew.com";
$mailto = "admin@the5150crew.com";
$mailsubj = "This has been sent from the5150crew.com";
$mailhead = "From:admin@the5150crew.com\nContent-type: text/html; charset=iso-8859-1";
reset ($HTTP_POST_VARS);
$userName = $_REQUEST['name'] ;
$userEmail = $_REQUEST['email'] ;
$userMessage = $_REQUEST['message'] ;
if (empty($userName)) {
echo 'Hello search engine,this is a form';
exit;
}
$mailbody = "<HTML>
<BODY>
<TABLE BORDER=\"1\">
<TR>
<TD align=\"left\" width=\"780\">Email : \"$userEmail\"</TD>
</TR>
<TR>
<TD align=\"left\" width=\"780\">Name : \"$userName\"</TD>
</TR>
<TR>
<TD align=\"left\" width=\"780\">Message: <br><br>\"$userMessage\"</TD>
</TR>
</TABLE>
</BODY>
</HTML>";
if (!eregi("\n",$HTTP_POST_VARS[email])) { mail($mailto, $mailsubj, $mailbody, $mailhead); }
</script>
Re: Help with code
Posted: Thu Mar 04, 2010 6:33 pm
by dbe1800
i will try it right now thank you!!!
i will let you know if it works!

Re: Help with code
Posted: Thu Mar 04, 2010 6:40 pm
by dbe1800
also am i putting this in my flash file or my email.php file?
Re: Help with code
Posted: Thu Mar 04, 2010 6:48 pm
by olidenia
Your email.php
Sould look like this:
Code: Select all
<script language="php">
$from = "From:admin@the5150crew.com";
$mailto = "admin@the5150crew.com";
$mailsubj = "This has been sent from the5150crew.com";
$mailhead = "From:admin@the5150crew.com\nContent-type: text/html; charset=iso-8859-1";
reset ($HTTP_POST_VARS);
$userEmail = $_REQUEST['email'] ;
$userName = $_REQUEST['name'] ;
$userMessage = $_REQUEST['message'] ;
if (empty($userName)) {
echo 'Hello search engine,this is a form';
exit;
}
$mailbody = "<HTML>
<BODY>
<TABLE BORDER=\"1\">
<TR>
<TD align=\"left\" width=\"780\">Email : \"$userEmail\"</TD>
</TR>
<TR>
<TD align=\"left\" width=\"780\">Name : \"$userName\"</TD>
</TR>
<TR>
<TD align=\"left\" width=\"780\">Message: <br><br>\"$userMessage\"</TD>
</TR>
</TABLE>
</BODY>
</HTML>";
if (!eregi("\n",$HTTP_POST_VARS[email])) { mail($mailto, $mailsubj, $mailbody, $mailhead); }
</script>
And the form:
Code: Select all
<form action="email.php" method="post">
Email: <input type="text" name="email" /><br>
Name: <input type="text" name="name" /><br>
<textarea name="message" rows="" cols=""></textarea><br>
<input type="submit" />
</form>
Re: Help with code
Posted: Thu Mar 04, 2010 7:01 pm
by dbe1800
1100: Syntax error: XML does not have matching begin and end tags.
Re: Help with code
Posted: Thu Mar 04, 2010 7:02 pm
by dbe1800
i get that error when i put that code in my "code" sections in actions panel in flash..
Re: Help with code
Posted: Thu Mar 04, 2010 7:20 pm
by olidenia
OK I see, well, scrap the form bit I gave you.
Try this, if it doesnt work I don't know the solution, i don't touch much flash:
Change on your script:
urlVal.userName = userName.text; (for) urlVal.name = name.text;
urlVal.userEmail = userEmail.text; (for) urlVal.email = email.text;
urlVal.userMssage = userMessage.text; (for) urlVal.message = message.text;
Re: Help with code
Posted: Fri Mar 05, 2010 10:38 am
by dbe1800
OK thanks ill give it a shot.. boy i hope this works.. lol i don't no what to do if it doesn't... ill probably
