Click to See Complete Forum and Search --> : Submit to email with DW5


klwiegman
04-06-2011, 02:53 PM
OK, I am in need of help! I have a few forms - but none work. My coding is rusty. My goal: when the user clicks "send" I would like to email the validated from to my team AND return the user to the home page. None of this happens right now.
So I am begging a great guru to come to my rescue!:D

Current code:

<table class="form-table" width="100%">
<tr>
<td colspan="3" class="form-table" style="width: 175px;">Please feel free to request a quote online, however, if you do not receive a response within 15 minutes, please call 800-450-4872. Thank you. </td>
</tr>

<tr>
<td class="title" style="width: 175px;">Your Name</td>
<td colspan="2"><input name="user_id2" type="text" id="user_id2" size="40" maxlength="25" /></td>
</tr>
<tr>
<td class="title">Your Phone</td>

<td colspan="2"><input name="RQNAME" type="text" id="RQNAME" onblur="MM_validateForm('searchb','','RisNum');return document.MM_returnValue" size="15" maxlength="15" />
<label for="label">Ext.</label>

<input name="RQEXT" type="text" id="label" onblur="MM_validateForm('searchb','','NisNum');return document.MM_returnValue" size="7" maxlength="7" /><br /></td>
</tr>
<tr>
<td class="title">Email</td>
<td colspan="2"><input name="user_id3" type="text" id="user_id3" size="40" maxlength="25" />
<br /></td>
</tr>
<tr>
<td class="title">Pickup Zip Code</td>

<td colspan="2"><input name="PUzip" type="text" id="PUzip" onblur="MM_validateForm('searchb','','RisNum');return document.MM_returnValue" size="7" maxlength="7" />
<label for="textfield">Delivery Zip Code</label>
<input name="DelZip" type="text" id="DelZip" onblur="MM_validateForm('searchb','','RisNum');return document.MM_returnValue" size="7" maxlength="7" /><br /></td>
</tr>
<tr valign="top">
<td class="title">Shipment Description</td>
<td><textarea name="RQdetail" cols="30" rows="5" id="RQdetail" onblur="MM_validateForm('searchb','','R');return document.MM_returnValue">Please describe your shipment: we need size, weight, content, etc.</textarea></td>
<td width="250">&nbsp;</td>

</tr>
<tr>
<td class="title"><label for="textfield">Shipment will be ready at</label></td>
<td colspan="2"><input name="PUtime" type="text" id="PUtime" onblur="MM_validateForm('searchb','','NisNum');return document.MM_returnValue" size="5" maxlength="5" />
<label for="textfield">Preferred delivery date &amp; time</label>
<input name="textfield" type="text" id="textfield" size="20" maxlength="20" /></td>
</tr>
<tr>
<td class="title">&nbsp;</td>
<td colspan="2">Send
<input name="reqestform1" type="submit" id="reqestform1" onclick="var email_address = &quot;mailto:dispatch@usacouriers.com&quot;" value="Submit" /></td>
</tr>

</table>
<div class="action-buttons" align="center"></div>
</form>
</div>
</div>
</div>
</div>

<div class="bottomleft1">
<div class="bottomright1"> </div>
</div>
</div>
<!-- Grey Box -->

shutterbug
04-07-2011, 10:38 AM
First off put your coding in a that way we can see the pretty codes :) . Secondly if you want it to send you an email that's all pretty and send them back the the home page you need to create a php form. Such as

[html]
<form name="form1" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<label for="Name">Name:</label>
<input type="text" name="Name" id="Name" value="<?php echo $formDefaults['Name']; ?>" />
<label for="Email">Email</label>
<span id="sprytextfield1">
<input type="text" name="Email" id="Email" value="<?php echo $formDefaults['Email']; ?>" />
<p>
<label for="Phone">Phone</label>
<span id="sprytextfield2">
<input type="text" name="Phone" id="Phone" value="<?php echo $formDefaults['Phone']; ?>" />
(000-000-0000)
<label for="Comments"><br>
<br>
Comments</label>
<textarea name="Comments" id="Comments" cols="45" rows="5"><?php echo $formDefaults['Comments']; ?></textarea>
<br />
<br />
</p>
<p>&nbsp;
<label for="validate">validate</label>
<input type="text" name="validate" id="validate" />
</p>
<p><br>
<input type="submit" name="button" id="button" value="Submit">
</p>
[/html
]
<?php
exit;
}


$to = "YourEmail" ;
$from = $_REQUEST['Email'] ;
$name = $_REQUEST['Name'] ;
$headers = "From: $from";
$subject = "Contact Us";

$fields = array();
$fields{"Name"} = "Name";
$fields{"Email"} = "Email";
$fields{"Phone"} = "Phone";
$fields{"Comments"} = "Comments";

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

$headers2 = "From: YOurEmail";
$subject2 = "Thank you for contacting us";
$autoreply = "Thank you for contacting us. We will get back with you shortly.";
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.yoursite.com" );
}else{
print "We encountered an error sending your mail, please notify youremail@youremail.com";
}//else
}//else
}
?>&nbsp;</p>
</div>



Hopefully that helps you.

klwiegman
04-07-2011, 02:33 PM
I am such a PHP noob! :eek:
Everything showed up when I put it on the server.:(

I think I need to buy a book...

shutterbug
04-07-2011, 09:44 PM
Create a new php page <?php

?>

Then paste the following


<?php
exit;
}

////////Leave all this set alone//////////
$to = "YourEmail" ;
$from = $_REQUEST['Email'] ;
$name = $_REQUEST['Name'] ;
$headers = "From: $from";
$subject = "Contact Us";

//////Type $fields = array()
Then
$fields{Form text tag}
Continue this through all of your form information weather its text or dropdowns or whatever they will all work /////////
$fields = array();
$fields{"Name"} = "Name";
$fields{"Email"} = "Email";
$fields{"Phone"} = "Phone";
$fields{"Comments"} = "Comments";

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

/////////////Edit where I have notes///////
$headers2 = "From: YOur Email";//////Inside the " "enter your email youremail@gmail.com//////
$subject2 = "Thank you for contacting us"; //////Inside the " " Whatever you want the subject to say in the email they will get back////////
$autoreply = "Thank you for contacting us. We will get back with you shortly."; //////-Enter inside the " "Whatever you want the email body to say///////
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.yoursite.com" );///////Enter inside the " "Whatever location you want them to return to after the form is submitted//////
}else{
print "We encountered an error sending your mail, please notify youremail@youremail.com";
}//else
}//else
}

/////////////and thats it hopeful that helps if you have more questions please ask.