Help with code

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
dbe1800
Forum Newbie
Posts: 8
Joined: Wed Mar 03, 2010 12:11 pm

Help with code

Post 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... :banghead:


<?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";
}

?>
User avatar
flying_circus
Forum Regular
Posts: 732
Joined: Wed Mar 05, 2008 10:23 pm
Location: Sunriver, OR

Re: Help with code

Post 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";
dbe1800
Forum Newbie
Posts: 8
Joined: Wed Mar 03, 2010 12:11 pm

Re: Help with code

Post by dbe1800 »

what do you mean can you tell me in detail
how would i fix that?

(im sorry im still learning php)
:(
User avatar
flying_circus
Forum Regular
Posts: 732
Joined: Wed Mar 05, 2008 10:23 pm
Location: Sunriver, OR

Re: Help with code

Post 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?
dbe1800
Forum Newbie
Posts: 8
Joined: Wed Mar 03, 2010 12:11 pm

Re: Help with code

Post 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?
:banghead:
olidenia
Forum Newbie
Posts: 19
Joined: Mon Apr 28, 2008 12:38 pm

Re: Help with code

Post 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>
dbe1800
Forum Newbie
Posts: 8
Joined: Wed Mar 03, 2010 12:11 pm

Re: Help with code

Post by dbe1800 »

i will try it right now thank you!!!

i will let you know if it works! :mrgreen:
dbe1800
Forum Newbie
Posts: 8
Joined: Wed Mar 03, 2010 12:11 pm

Re: Help with code

Post by dbe1800 »

also am i putting this in my flash file or my email.php file?
olidenia
Forum Newbie
Posts: 19
Joined: Mon Apr 28, 2008 12:38 pm

Re: Help with code

Post 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>
dbe1800
Forum Newbie
Posts: 8
Joined: Wed Mar 03, 2010 12:11 pm

Re: Help with code

Post by dbe1800 »

1100: Syntax error: XML does not have matching begin and end tags.
Attachments
Picture 1.jpg
Picture 1.jpg (175.89 KiB) Viewed 293 times
dbe1800
Forum Newbie
Posts: 8
Joined: Wed Mar 03, 2010 12:11 pm

Re: Help with code

Post by dbe1800 »

i get that error when i put that code in my "code" sections in actions panel in flash..
olidenia
Forum Newbie
Posts: 19
Joined: Mon Apr 28, 2008 12:38 pm

Re: Help with code

Post 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;
dbe1800
Forum Newbie
Posts: 8
Joined: Wed Mar 03, 2010 12:11 pm

Re: Help with code

Post 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 :banghead:
Post Reply