Jump to content

php form to email, simple error, RESULYS going to USER's email, conf email to me


verano

Recommended Posts

ok so the email that is being SENT OUT is going the wrong direction, it is going to me instead, and the RESULTS are going to the user that submitted them.

 

<html><body><font face=Arial size=2>
<form method="post" action="contactvol.php">
<table width="635" align=center bgcolor=white>
<tr>
  <td colspan=2><strong>Request to join volunteer at our organization using this form:</strong></td></tr>
<tr>
  <td width="222"><font color=red>*</font> Full Name:</td><td width="401"><input size=25 name="Name"></td></tr>
<tr><td><font color=red>*</font> Email:</td><td><input size=25 name="Email"></td></tr>
<tr>
<input name="sendto" value="[email protected]" type="hidden">
  <td>Animal Shelter/Rescue Name (if applicable)</td><td><p>
    <input size=25 name="Shelter" id="Shelter">
  </p>
    <p>  </p></td></tr>
<tr>
  <td>Where did you find out about us?</td><td><label>
    <input name="WebsiteQuestion" type="text" id="WebsiteQuestion" size="25">
    <br>
    <br>
  </label></td></tr>
<tr>
  <td colspan=2>Reason you would like to be a volunteer:</td></tr>
<tr><td colspan=2 align=center><textarea name="Message" rows=5 cols=35></textarea></td></tr>
<tr><td colspan=2 align=center><input type=submit name="send" value="Submit"></td></tr>
<tr><td colspan=2 align=center><small>A <font color=red>*</font> indicates a field is required</small></td></tr>
</table>
</form>
</body>
</html>

 

PHP FILE

<?php
$to = $_REQUEST['sendto'] ;
$from = $_REQUEST['Email'] ;
$name = $_REQUEST['Name'] ;
$headers = "From: $from";
$subject = "Domain.com:  Volunteer Form";

$fields = array();
$fields{"Name"} = "Name";
$fields{"Email"} = "Email";
$fields{"Shelter"} = "Shelter";
$fields{"WebsiteQuestion"} = "WebsiteQuestion";
$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 www.ipetrescue.com";

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 {
$send = mail($to, $subject, $body, $headers);
$send2 = mail($from, $subject2, $autoreply, $headers2);
if($send)
{header( "Location: http://www.domain.com/thankyou.html" );}
else
{print "We encountered an error sending your mail, please notify [email protected]"; }
}
}
?> 

Just swap the fields around

<input size=25 name="Email"></td></tr>
<tr>
<input name="sendto" value="[email protected]" type="hidden">

 

swap the Email and sendto around!

 

<input size=25 name="sendto"></td></tr>
<tr>
<input name="Email" value="[email protected]" type="hidden">

Tried that and it gave me an error message, can you send the entire code, so I can try that?

 

Just swap the fields around

<input size=25 name="Email"></td></tr>
<tr>
<input name="sendto" value="[email protected]" type="hidden">

 

swap the Email and sendto around!

 

<input size=25 name="sendto"></td></tr>
<tr>
<input name="Email" value="[email protected]" type="hidden">

You shouldn't be getting any errors

 

try something like this (so its easier to read)

<?php
$to = $_REQUEST['clientmail'];
$from = $_REQUEST['sitemail'];
$name = $_REQUEST['Name'];
$headers = "From: $from";
$subject = "Domain.com:  Volunteer Form";

$fields = array();
$fields{"Name"} = "Name";
$fields{"Email"} = "Email";
$fields{"Shelter"} = "Shelter";
$fields{"WebsiteQuestion"} = "WebsiteQuestion";
$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]);
}

$c_headers = "From: [email protected]";
$c_subject = "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 www.ipetrescue.com";

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 {
	$send = mail($from, $subject, $body, $headers); //Send to site
	$send2 = mail($to, $c_subject, $autoreply, $c_headers);//send to client
	if($send){
		header( "Location: http://www.domain.com/thankyou.html" );
	}else{
		print "We encountered an error sending your mail, please notify [email protected]";
	}
}
}
?> 
<html><body><font face=Arial size=2>
<form method="post" action="contactvol.php">
<table width="635" align=center bgcolor=white>
<tr>
  <td colspan=2><strong>Request to join volunteer at our organization using this form:</strong></td></tr>
<tr>
  <td width="222"><font color=red>*</font> Full Name:</td><td width="401"><input size=25 name="Name"></td></tr>
<tr><td><font color=red>*</font> Email:</td><td><input size=25 name="clientmail"></td></tr>
<tr>
<input name="sitemail" value="[email protected]" type="hidden">
  <td>Animal Shelter/Rescue Name (if applicable)</td><td><p>
    <input size=25 name="Shelter" id="Shelter">
  </p>
    <p>  </p></td></tr>
<tr>
  <td>Where did you find out about us?</td><td><label>
    <input name="WebsiteQuestion" type="text" id="WebsiteQuestion" size="25">
    <br>
    <br>
  </label></td></tr>
<tr>
  <td colspan=2>Reason you would like to be a volunteer:</td></tr>
<tr><td colspan=2 align=center><textarea name="Message" rows=5 cols=35></textarea></td></tr>
<tr><td colspan=2 align=center><input type=submit name="send" value="Submit"></td></tr>
<tr><td colspan=2 align=center><small>A <font color=red>*</font> indicates a field is required</small></td></tr>
</table>
</form>
</body>
</html>

It still does the same thing, but no error message and much cleaner to view, thank you for that.  I have spend 2 solid days on this lol, this is sad.  My fault though...  but I dont get any message this time from the email I input. 

 

 

This is a headache.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.