Tweet Follow @LawBlogger1   

Advertisments:


Sponsor Links:

Bar Exam Flashcards
Discount Legal Forms
Discounted Legal Texts

Help me with my email PHP code please!?

  
Tweet

Help me with my email PHP code please!?

Postby kirklin » Wed Dec 14, 2011 10:20 pm

I have this code for my website and am having an issue. The [email protected] email works, but [email protected] never gets the email sent to it using the email form. Help?

Contact Page Code (HTML)

Fields with a <font color="Red">*</font> Are Required

<form id="form" action="send.php">
<p class="contactformtext">
<font color="Red">*</font> Name: <input name="name" type="text" class="formname"/><br/>
<font color="Red">*</font> Email: <input name="email" type="text"/><br/>
<font color="Red">*</font> Subject: <select name="subject">
<option>Questions</option>
<option>Website Error</option>
<option>Advertising Opportunities</option>
<option>General Feedback</option>
<option>Suggestions</option>
<option>Other</option>
</select><br/>
<font color="Red">*</font> Message: <br/>
<textarea name="message" cols="75" rows="10"></textarea>
<br/>
<input class="submit" type="submit" name="sendmail" value="Submit"/>
<input class="reset" type="reset" name="sendmail" value="Reset"/>
</p>
</form>


PHP Code:

<?php
$to = "garneth@gar[email protected] ";
$from = $_REQUEST['email'];
$name = $_REQUEST['name'];
$headers = "From: $from";
$subject = $_REQUEST['subject'];

$fields = array();
$fields{"name"} = "Name";
$fields{"email"} = "Email";
$fields{"subject"} = "Subject";
$fields{"message"} = "Message";

$body = "We have received the following information:\n\n"; foreach($fields as $a => $b){ $body .= sprintf("%20s: %s\n",$b,$_REQUEST[$a]); }

$headers2 = "From: [email protected] ";
$subject2 = "Thank you for contacting us";
$autoreply = "Thank you for contacting us. Somebody will get back to you as soon as possible, usualy within 48 hours. If you have any more questions, please consult our website at http://www.garneth.co.cc/";

if($from == '') {print "You have not entered an email, please go back and try again";}
else {
if($name == '') {print "You have not entered a name, please go back and try again";}

else {
if ( preg_match( "/[\r\n]/", $name ) || preg_match( "/[\r\n]/", $email ) )
{
header('Location: http://www.garneth.co.cc/forbidden.html');
}
$send = mail($to, $subject, $body, $headers);
$send2 = mail($from, $subject2, $autoreply, $headers2);
if($send)
{header( "Location: http://www.garneth.co.cc/thankyou.html" );}
else
{print "We encountered an error sending your mail, please notify [email protected] "; }
}
}
?>
kirklin
 
Posts: 0
Joined: Sat Apr 02, 2011 12:21 am
Top

Help me with my email PHP code please!?

Postby burdett » Wed Dec 14, 2011 10:27 pm

I have this code for my website and am having an issue. The [email protected] email works, but [email protected] never gets the email sent to it using the email form. Help?

Contact Page Code (HTML)

Fields with a <font color="Red">*</font> Are Required

<form id="form" action="send.php">
<p class="contactformtext">
<font color="Red">*</font> Name: <input name="name" type="text" class="formname"/><br/>
<font color="Red">*</font> Email: <input name="email" type="text"/><br/>
<font color="Red">*</font> Subject: <select name="subject">
<option>Questions</option>
<option>Website Error</option>
<option>Advertising Opportunities</option>
<option>General Feedback</option>
<option>Suggestions</option>
<option>Other</option>
</select><br/>
<font color="Red">*</font> Message: <br/>
<textarea name="message" cols="75" rows="10"></textarea>
<br/>
<input class="submit" type="submit" name="sendmail" value="Submit"/>
<input class="reset" type="reset" name="sendmail" value="Reset"/>
</p>
</form>


PHP Code:

<?php
$to = "[email protected] ";
$from = $_REQUEST['email'];
$name = $_REQUEST['name'];
$headers = "From: $from";
$subject = $_REQUEST['subject'];

$fields = array();
$fields{"name"} = "Name";
$fields{"email"} = "Email";
$fields{"subject"} = "Subject";
$fields{"message"} = "Message";

$body = "We have received the following information:\n\n"; foreach($fields as $a => $b){ $body .= sprintf("%20s: %s\n",$b,$_REQUEST[$a]); }

$headers2 = "From: [email protected] ";
$subject2 = "Thank you for contacting us";
$autoreply = "Thank you for contacting us. Somebody will get back to you as soon as possible, usualy within 48 hours. If you have any more questions, please consult our website at http://www.garneth.co.cc/";

if($from == '') {print "You have not entered an email, please go back and try again";}
else {
if($name == '') {print "You have not entered a name, please go back and try again";}

else {
if ( preg_match( "/[\r\n]/", $name ) || preg_match( "/[\r\n]/", $email ) )
{
header('Location: http://www.garneth.co.cc/forbidden.html');
}
$send = mail($to, $subject, $body, $headers);
$send2 = mail($from, $subject2, $autoreply, $headers2);
if($send)
{header( "Location: http://www.garneth.co.cc/thankyou.html" );}
else
{print "We encountered an error sending your mail, please notify [email protected] "; }
}
}
?>
OK, great, can I have the ten points anyway?
burdett
 
Posts: 0
Joined: Sat Apr 02, 2011 3:58 am
Top


Return to Class Action

 


  • Related topics
    Replies
    Views
    Last post

Who is online

Users browsing this forum: No registered users and 0 guests