Jump to content

[SOLVED] Send Form to e-mail


Firstaka

Recommended Posts

Would this work?

 

 

<?PHP 

$to = "you@your.com"; 
$subject = "Results from your Request Info form"; 
$headers = "From: Form Mailer";  
$forward = 0; # redirect? 1 : yes || 0 : no 
$location = "thankyou.htm"; 

$date = date ("l, F jS, Y"); 
$time = date ("h:i A"); 

$msg = "Below is the result of your feedback form. It was submitted on $date at $time.\n\n"; 

if ($_SERVER['REQUEST_METHOD'] == "POST") {
foreach ($_POST as $key => $value) { 
	$msg .= ucfirst ($key) ." : ". $value . "\n"; 
}
}
else {
foreach ($_GET as $key => $value) { 
	$msg .= ucfirst ($key) ." : ". $value . "\n"; 
}
}

mail($to, $subject, $msg, $headers); 
if ($forward == 1) { 
    header ("Location:$location"); 
} 
else { 
    echo "Thank you for submitting our form. We will get back to you as soon as possible."; 
} 

?>

Link to comment
Share on other sites

My recommendation would be as follows (for the easiest way to sort the problem);

 

Change the current form code bellow;

               <form id="form" action="" enctype="multipart/form-data">
           		 <div class="form">
                    	<div class="indent-form"><input type="text" value="name" /></div>
                        <div class="indent-form"><input type="text" value="e-mail" /></div>
                        <div class="indent-form"><input type="text" value="phone" /></div>
                        <p>
                          <textarea cols="2" rows="2">message</textarea>

                        <a class="link" href="mailto:info@orientwatchusa.com" onclick="document.getElementById('form').submit()">Send<img src="images/link_marker.gif" alt="" /></a></p>
                        <p> </p>
           		 </div>
               </form>

 

to this

               <form id="form" action="contact_send.php">
           		 <div class="form">
                    	<div class="indent-form"><input name="name" type="text" value="name" /></div>
                        <div class="indent-form"><input name="email" type="text" value="e-mail" /></div>
                        <div class="indent-form"><input name="phone" type="text" value="phone" /></div>
                        <p>
                          <textarea name="message" cols="2" rows="2">message</textarea>

                        <input type="submit" value="Submit" name="submit" /></p>
                        <p> </p>
           		 </div>
               </form>

 

This will sort out your contact form,

 

The code bellow should be copied and pasted into notepad (or any other text editor) and saved as contact_send.php

<?php
$to = "you@your.com";
$subject = "Results from your Request Info form";
$headers = "From: Form Mailer"; 

$date = date ("l, F jS, Y");
$time = date ("h:i A");

$msg = "Below is the result of your feedback form. It was submitted on $date at $time.\n\n";

if(!isset($_REQUEST['name']) || empty($_REQUEST['name'])) die('You must fill in all details');
else $msg .= "Name: {$_REQUEST['name']}\n"

if(!isset($_REQUEST['email']) || empty($_REQUEST['email'])) die('You must fill in all details');
else $msg .= "Email: {$_REQUEST['email']}\n"

if(!isset($_REQUEST['phone']) || empty($_REQUEST['phone'])) die('You must fill in all details');
else $msg .= "Phone: {$_REQUEST['phone']}\n"

if(!isset($_REQUEST['message']) || empty($_REQUEST['message'])) die('You must fill in all details');
else $msg .= "Message: {$_REQUEST['message']}\n"

if(mail($to, $subject, $msg, $headers)) echo "Thank you for submitting our form. We will get back to you as soon as possible.";
else echo "There was a problem sending your email, please try again later.";
?>

 

This should work, but it was off the top of my head. If you have any questions or it doesn't work let me know

Link to comment
Share on other sites

<?php
$to = "you@your.com";
$subject = "Results from your Request Info form";
$headers = "From: Form Mailer"; 

$date = date ("l, F jS, Y");
$time = date ("h:i A");

$msg = "Below is the result of your feedback form. It was submitted on $date at $time.\n\n";

if(!isset($_REQUEST['name']) || empty($_REQUEST['name'])) die('You must fill in all details');
else $msg .= "Name: {$_REQUEST['name']}\n"

if(!isset($_REQUEST['email']) || empty($_REQUEST['email'])) die('You must fill in all details');
else $msg .= "Email: {$_REQUEST['email']}\n";

if(!isset($_REQUEST['phone']) || empty($_REQUEST['phone'])) die('You must fill in all details');
else $msg .= "Phone: {$_REQUEST['phone']}\n";

if(!isset($_REQUEST['message']) || empty($_REQUEST['message'])) die('You must fill in all details');
else $msg .= "Message: {$_REQUEST['message']}\n";

if(mail($to, $subject, $msg, $headers)) echo "Thank you for submitting our form. We will get back to you as soon as possible.";
else echo "There was a problem sending your email, please try again later.";
?>

Link to comment
Share on other sites

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.