Jump to content

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


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="support@domain.com" 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: support@domain.com";
$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 support@domain.com"; }
}
}
?> 

Just swap the fields around

<input size=25 name="Email"></td></tr>
<tr>
<input name="sendto" value="support@domain.com" type="hidden">

 

swap the Email and sendto around!

 

<input size=25 name="sendto"></td></tr>
<tr>
<input name="Email" value="support@domain.com" 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="support@domain.com" type="hidden">

 

swap the Email and sendto around!

 

<input size=25 name="sendto"></td></tr>
<tr>
<input name="Email" value="support@domain.com" 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: support@domain.com";
$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 support@domain.com";
	}
}
}
?> 
<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="support@domain.com" 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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.