Redesigning a site for a friend and they have a contact form on the site with some simple stuff on it.
I would like to use the most effective and upto date method.
What scripts do use to send results from an online form.
Thanks
Steven
What mailing script do you use
Online form to email
Page 1 of 1
What mailing script do you use Online form to email
#2
Posted 03 November 2008 - 10:07 AM
Steven Gardner said:
What scripts do use to send results from an online form.
Do you mean a pre-made script, or are you referring to code (using SMTP or PHPmail)?
#3
Posted 03 November 2008 - 10:15 AM
I'm not sure myself what i mean
I think what i want to know is
what php code do you use to send a Contact forms results to an email address.
If you use your own custom php then if you would like to share then great but if you use a free script from somewhere on the web then also please share.
Thanks
Steven
I think what i want to know is
what php code do you use to send a Contact forms results to an email address.
If you use your own custom php then if you would like to share then great but if you use a free script from somewhere on the web then also please share.
Thanks
Steven
#4
Posted 03 November 2008 - 02:27 PM
Yeh i use my own, I dont mind sharing 
Heres the php
Heres the html/php
Any problems or explanations needed let me know!
Heres the php
//If enquiry form is submitted
if(isset($_POST['Submit'])) {
//Function for checking valid email
function check_email_address($email) {
// First, we check that there's one @ symbol, and that the lengths are right
if (!ereg("^[^@]{1,64}@[^@]{1,255}$", $email)) {
// Email invalid because wrong number of characters in one section, or wrong number of @ symbols.
return false;
}
// Split it into sections to make life easier
$email_array = explode("@", $email);
$local_array = explode(".", $email_array[0]);
for ($i = 0; $i < sizeof($local_array); $i++) {
if (!ereg("^(([A-Za-z0-9!#$%&'*+/=?^_`{|}~-][A-Za-z0-9!#$%&'*+/=?^_`{|}~\.-]{0,63})|(\"[^(\\|\")]{0,62}\"))$", $local_array[$i])) {
return false;
}
}
if (!ereg("^\[?[0-9\.]+\]?$", $email_array[1])) { // Check if domain is IP. If not, it should be valid domain name
$domain_array = explode(".", $email_array[1]);
if (sizeof($domain_array) < 2) {
return false; // Not enough parts to domain
}
for ($i = 0; $i < sizeof($domain_array); $i++) {
if (!ereg("^(([A-Za-z0-9][A-Za-z0-9-]{0,61}[A-Za-z0-9])|([A-Za-z0-9]+))$", $domain_array[$i])) {
return false;
}
}
}
return true;
}
//Set error value and variables
$error = FALSE;
//Set all your vairables here
$name = $_POST['Name'];
$email = $_POST['Email'];
$address = $_POST['Address'];
$enquiry = $_POST['Enquiry'];
$address = strip_tags($address);
$enquiry = strip_tags($enquiry);
//Set title of the email and which address its going to
$title = "You have received an email!";
$semail = "someone@domain.com";
//Check if any required fields are blank
if(!$name | !$email) {
$error = TRUE;
$error_msg = "<strong>ERROR:</strong> Please fill in the required fields for <strong>Name</strong> and <strong>Email Address</strong>.";
}
//Check to see if the email address is valid
if (check_email_address($email) == FALSE) {
$error = TRUE;
$error_msg = "<strong>ERROR:</strong> Please enter a <strong>valid</strong> email address.";
}
//Add more error checks if needed for other variables
if ($error == FALSE) {
//Prepare email data for reading
$query .= "<h1>Customer Enquiry</h1>";
$query .= "<p>From: <strong>$name</strong></p>";
$query .= "<p>Email Address: <strong>$email</strong></p>";
$query .= "<p>Address: <strong>$address</strong></p>";
$query .= "<p>Enquiry: <strong>$enquiry</strong></p>";
//If no validation errors have occured send the email
$headers = "MIME-Version: 1.0 \r\n";
$headers .= "Content-type: text/html;";
$headers .= "charset=iso-8859-1\r\n";
$headers .= "From: $email\r\n";
//send mail
mail($semail,$title,"$query",$headers);
$success = TRUE;
}
}
Heres the html/php
<?php
if($error == TRUE) {
echo "<div class=\"warningContent\">$error_msg</div>\n";
}
elseif($success == TRUE){
echo "<div class=\"successContent\"><strong>Enquiry sent!</strong> Please allow upto <em>24 hours</em> for a response.</div>\n";
}
?>
<form id="enquiryForm" name="Enquiry" method="post" action="nameofthefileyouchoosehere.php">
<label>Your Name
<input name="Name" type="text" size="25" value="<?php echo $_POST['Name'];?>" /></label>
<label>Your Email
<input name="Email" type="text" size="25" value="<?php echo $_POST['Email'];?>" /></label>
<label>Your Address
<textarea name="Address" cols="45" rows="3"><?php echo $_POST['Address'];?></textarea></label>
<label>Your Enquiry
<textarea name="Enquiry" cols="45" rows="3"><?php echo $_POST['Enquiry'];?></textarea></label>
<input name="Submit" type="submit" id="Submit" value="Submit" />
<input name="Reset" type="reset" id="Reset" value="Reset" />
</form>
Any problems or explanations needed let me know!
#5
Posted 03 November 2008 - 05:13 PM
Thanks Sypher!
Here is the code i have been working with. Its not working at the moment and i dont know whats wrong. Can someone take a look and tell me whats wrong.
Thanks
Here is the code i have been working with. Its not working at the moment and i dont know whats wrong. Can someone take a look and tell me whats wrong.
Thanks
<?php
/* ========================= Begin Configuration ============================ */
define("kContactEmail","robandpaul@twoscompanycreations.co.uk");
/* ========================= End Configuration ============================== */
// init variables
$error_msg = 'The following fields were left empty or contain invalid information:<ul>';
$error = false;
// determine is the form was submitted
$submit = $_POST['submit'];
if (empty($submit))
$form_submitted = false;
else
$form_submitted = true;
if ($form_submitted) {
// read out data
$name = $_POST['name'];
$phone = $_POST['phone'];
$email = $_POST['email'];
$message = $_POST['message'];
// verify required data
if(!$name) { $error_msg .= "<li>Full Name</li>"; $error = true; }
if(!$phone) { $error_msg .= "<li>Phone Number</li>"; $error = true; }
if($email) { if(!eregi("^[a-z0-9_]+@[a-z0-9\-]+\.[a-z0-9\-\.]+$", $email)){ $error_msg .= "<li>E-mail Address</li>"; $error = true; }}
$error_msg .= "</ul>";
// email message if no errors occurred
if (!$error) {
// prepare message
$msg = "Full Name: \t $name \n";
$msg .= "Phone Number: \t $phone \n";
$msg .= "E-mail Address: \t $email \n";
$msg .= "Message: \n---\n $message \n---\n";
$subject = "Website Contact Form Results";
// prepare message header
$mailheaders = "MIME-Version: 1.0\r\n";
$mailheaders .= "Content-type: text/plain; charset=iso-8859-1\r\n";
$mailheaders .= "From: $name <$email>\r\n";
$mailheaders .= "Reply-To: $name <$email>\r\n";
// send out email
mail(kContactEmail, $subject ,stripslashes($msg), $mailheaders);
}
}
?>
</head>
<body>
<body>
<div id="left-col">
<h1 class="page-title">Contact Us</h1>
<p>If you are interested in what we offer, fantastic. Get in touch and either Rob or Paul will be glad to help</p><br />
<?php
// email was successfully send
if (($form_submitted) && (!$error)) {
?>
<!-- display submitted data -->
Thank you for your message, <?php echo $name; ?>.
This is the information you submitted:<br>
<br>
<?php echo nl2br(stripslashes($msg)); ?>
<?php
}
// display contact form
else {
// display error message
if ($error) {
echo "<font class='form_check'>" . $error_msg . "</font>\n";
}
?>
<form action="<?php echo $PHP_SELF; ?>" method="post" name="contact">
<fieldset>
<legend>Contact Details</legend>
<ol>
<li>
<label for="name">Name:</label>
<input id="name" name="name" class="text" value="<?php echo $name ?>" type="text" size="30" />
</li>
<li>
<label for="phone">Telephone:</label>
<input id="phone" name="phone" class="text" value="<?php echo $phone ?>" type="text" />
</li>
<li>
<label for="email">Email:</label>
<input name="email" type="text" class="text" value="<?php echo $email ?>" id="email" size="35" />
</li>
<li>
<label for="message">Message:</label>
<textarea name="message" cols="45" rows="4" ><?php echo $message ?></textarea>
</li>
</ol>
<input class="submit" type="submit" value="Send Message" />
</fieldset></form>
<?php
}
?>
</div><!-- End of Left Column -->
#6
Posted 03 November 2008 - 05:59 PM
Whats the current error your getting?
#7
Posted 04 November 2008 - 04:42 AM
The confirmation message when the form has been sent dosen't appear and i dont think its sending any results to the recipient.
#8
Posted 26 May 2010 - 07:55 AM
Mail Manager is a great mailing list script that allows visitors to your website to subscribe and unsubscribe to your mailing list
without ANY work from you. This is a great way to inform your visitors on what's happening, and bring them back!
web development services
without ANY work from you. This is a great way to inform your visitors on what's happening, and bring them back!
web development services
Share this topic:
Page 1 of 1


Help
This topic is locked

MultiQuote











