I am using Dreamweaver to create a website, my website has a form, but when I click on the submit button it opens my outlook application, with the information I want. I was just wondering if it was possible to send the email to my account without going through my email client. This is my code...
BTW I am using Dreamweaver to edit all the code.
<!doctype html>
<html lang="en-US">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Fiction Filming</title>
<link rel="shortcut icon" href="images/favicon3.ico" type="image/x-icon" />
<style type="text/css">
body {
background-color: #2c2c2c;
}
</style>
<link href="Css/singlePageTemplate.css" rel="stylesheet" type="text/css">
<!--The following script tag downloads a font from the Adobe Edge Web Fonts server for use within the web page. We recommend that you do not modify it.-->
<script>var __adobewebfontsappname__="dreamweaver"</script>
<script src="http://use.edgefonts.net/source-sans-pro:n2:default.js" type="text/javascript"></script>
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body>
<!-- Main Container -->
<div class="container">
<!-- Navigation -->
<!-- Hero Section -->
<!-- About Section -->
<!-- Stats Gallery Section -->
<div class="gallery"><img src="Images/Newbannercomingsoon.png" alt="" width="1000" height="500" class="logo-pic"/> </div>
<!-- Parallax Section -->
<!-- More Info Section -->
<!-- Footer Section -->
<section class="footer_banner" id="contact">
<form class="subscribeForm form-fix" name="Subscription Form" method="post" action="mailform.php" enctype="text/plain">
<div class="newform">
<div> </div>
<div>
<input id="fname" type="text" placeholder="NAME" name="name" required>
</div>
<div>
<input name="email" type="email" required id="email" placeholder="EMAIL">
</div>
<div>
<select name="select" required id="myselect">
<option>HELP / SUPPORT</option>
<option>BUSINESS ENQUIRES</option>
<option>OTHER</option>
</select>
</div>
<div class="text-form">
<div>
<textarea name="textarea" required id="textarea" placeholder="TYPE YOUR TEXT HERE"></textarea>
</div>
</div>
<br><input name="Send" type="submit" id="Send" value="Send">
</div>
</form>
<!-- Step 1: Add an email field here -->
<!-- Step 2: Add an address field here -->
<!-- Step 3: add a submit button here -->
</section>
<!-- Copyrights Section -->
<div class="copyright">©2016 - <strong>Fiction filming</strong></div>
</div>
<!-- Main Container Ends -->
</body>
</html>
Also, here is my php file... If you can fix it, it would be really helpful.
<!doctype html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset="UTF-8">
<META HTTP-EQUIV="refresh" content="0;URL=thankyou.html">
<title>Email Form</title>
</head>
<body>
<?php
if(isset($_POST['submit'])){
$to = "example#example.com"; // this is your Email address
$from = $_POST['email']; // this is the sender's Email address
$sender_name = $_POST['name'];
$select = $_POST['select'];
$message = $sender_name . " wrote the following:" . "\n\n" . $_POST['textarea'];
$headers = "From:" . $from;
$headers2 = "From:" . $to;
mail($to,$subject,$message,$headers);
echo "Mail Sent. Thank you " . $name . ", we will contact you shortly.";
// You can also use header('Location: thank_you.php'); to redirect to another page.
}
?>
</body>
</html>
HERE IS THE NEW PHP
<!doctype html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset="UTF-8">
<META HTTP-EQUIV="refresh" content="3;URL=thankyou.html">
<title>Email Form</title>
</head>
<body>
<?php
if(isset($_POST['submit'])){
// Or the below if using "name="Send" for the input. Uncomment and get rid of the above
// if(isset($_POST['Send'])){
if(!empty($_POST['email'])
&& !empty($_POST['name'])
&& !empty($_POST['select'])
&& !empty($_POST['textarea'])) {
$to = "mail#fictionfilming.com";
$from = $_POST['email'];
$sender_name = $_POST['name'];
$select = $_POST['select'];
$textarea = $_POST['textarea'];
$message = $sender_name . " wrote the following:" . "\n\n" . $textarea;
if(mail($to,$subject,$message,$headers)){
echo "Mail was sent. Check both your inbox and spam, as mail as done its job.";
}
else{
echo "There was a problem. Check your logs.";
}
}
}
// $headers = "From:" . $from;
// $headers2 = "From:" . $to;
//echo "Mail Sent. Thank you " . $name . ", we will contact you shortly.";
// You can also use header('Location: thank_you.php'); to redirect to another page.
//}
?>
</body>
</html>
There are a few issues with your code.
Firstly, remove enctype="text/plain". That type isn't valid to send POST arrays with a form.
You should also remove <META HTTP-EQUIV="refresh" content="0;URL=thankyou.html"> as that may play some nasty tricks on you.
Then your input <input name="Send" type="submit" id="Send" value="Send"> bears the Send name attribute and you're using the following conditional statement which will never fire up:
if(isset($_POST['submit']))
Either rename your input to name="submit", or your conditional statement to read as if(isset($_POST['Send'])); the choice is yours.
Error reporting would have thrown you something about it.
Now, I don't see why you have this in your code $headers2 = "From:" . $to; since it's not being used anywhere, therefore I can't say much about this, other than just to get rid of it.
You should also check for empty fields, should someone decide not to fill any or all of the inputs, resulting in an empty email.
I.e., and I replaced your $_POST['textarea'] with $textarea while assigning it for the POST array.
Sidenote: See the above in regards to "submit" and "Send"; modify accordingly for the if(isset($_POST['submit'])) below here.
if(isset($_POST['submit'])){
// Or the below if using "name="Send" for the input. Uncomment and get rid of the above
// if(isset($_POST['Send'])){
if(!empty($_POST['email'])
&& !empty($_POST['name'])
&& !empty($_POST['select'])
&& !empty($_POST['textarea'])) {
$from = $_POST['email'];
$sender_name = $_POST['name'];
$select = $_POST['select'];
$textarea = $_POST['textarea'];
$message = $sender_name . " wrote the following:" . "\n\n" . $textarea;
// Put your other mail code here
}
}
All this assuming that mail() is available on the server you are running this from.
I suggest you replace:
mail($to,$subject,$message,$headers);
with a conditional statement, in order to check if it was sent:
if(mail($to,$subject,$message,$headers)){
echo "Mail was sent. Check both your inbox and spam, as mail as done its job.";
}
else{
echo "There was a problem. Check your logs.";
}
Add error reporting to the top of your file(s) which will help find errors.
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
// Then the rest of your code
Sidenote: Displaying errors should only be done in staging, and never production.
Footnotes:
I noticed you are using ID's, so if you're using JS/Ajax/jQuery that you didn't include in your original question, would be beyond the scope of the question.
It is unknown as to how you are accessing your files, so if you are on a hosted site, then what I have given you should work.
If it is a server issue, then that also is beyond the scope of the question and you will need to contact your service provider for tech support.
If you're using this from your own PC, then PHP, a webserver and mail() need to be installed, properly configured and using http://localhost/file.xxx as opposed to file:///file.xxx.
Sidenote: If nothing is passed from <option>, then you may have to give them values.
I.e.: <option value="HELP / SUPPORT"> while doing that for the others.
I believe I have given you enough to move ahead here.
Since in the form tag u mentioned the action as action="mailto:mail#fictonfilming.com" it is trying to access outlook
change the action to the name of your php file
action="yourphpfilename.php"
Depending on your server configuration, you may not be able to send mails using the simple php mail function.
To test it, use:
print mail($to,$subject,$message,$headers);
If the result is not 1, something is not good, and fixing it maybe not be easy.
I suggest you use the PHPmailer or API based services like MailGun.
Related
I'm trying to create a contact page for my portfolio, where the user could place in their email, subject, and their message and then click a button to send it. I already downloaded XAMPP and PHP and I have been checking the website on the localhost. However, every time I type in the necessary fields and send, it would open up my computers email app and place text into the message field. I don't want this - i'm trying to make the email send from the webpage.
Here is the code for my PHP file:
<?php
$subject = $_Post['subject'];
$visitor_email = $_Post['email'];
$message = $_Post['message'];
$email_body = $message;
$to = "randemail#gmail.com";
$headers= "From: $visitor_email\r\n";
$headers .= "Reply-To:$visitor_email\r\n";
mail($to, $subject,$message,$headers);
header("Location:index.html");
?>
here is the code to my contact page:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Game Design Projects | My Portfolio</title>
<link rel="stylesheet" href="css/styles.css">
<link href="https://fonts.googleapis.com/css2?family=Raleway:ital,wght#0,300;1,200;1,400;1,700&display=swap"
rel="stylesheet">
</head>
<body>
<div id = "MainBody">
<div class="contactmeborder">
<div class="PortObjname">
<h2>Reach Out</h2>
</div>
<form action="mailto:randemail#gmail.com" method="post" action = "PHP/contact-form-handler.php">
<input type="text" name="email" placeholder=" Email"><br>
<input type="text" name="subject" placeholder=" Subject"><br>
<textarea type="text" name="message" placeholder="Your Message"></textarea> <br>
<input type="submit">
</form>
</div>
</div>
<div class="Footer">
<p class="footinfo">footer</p>
</div>
</body>
</html>
The PHP/contact-form-handler.php holds what you see for the PHP part of this post.
The form action is using mailto:, but it should be pointed to the URL for your PHP script.
mailto: is for links on your site so that users can send emails a specific address.
I would also look into using an API service like SendGrid, MailGun, etc. to send emails instead of mail(). PHP's mail() function is very unreliable.
<form action="mailto:randemail#gmail.com" , action need to be the php_send_mail.php
It's open your mail client because that is the current settings. (mailto...)
Note: apparently you added twice action (just keep the proper one)
<form action="mailto:randemail#gmail.com" method="post" action = "PHP/contact-form-handler.php">
So I'm in a web design class in school right now and I want to set up a contact page that will send the results to my email. I followed a really good tutorial and made sure I typed everything correct but it wont send. I'm using freehosting.com to host my pages.
Here's my index.php:
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="stylesheet.css">
<meta charset="UTF-8">
<title>Email Form</title>
</head>
<body>
<main>
<p class="header">E-MAIL FORM</p>
<form class="contact-form" action="contactform.php" method="post">
<p class="title">Your Name</p>
<input type="text" name="name" placeholer="Full Name"><br/>
<p class="title">Your E-Mail</p>
<input type="text" name="mail" placeholer="Your E-mail"><br/>
<p class="title">Subject</p>
<input type="text" name="subject" placeholer="Subject"><br/>
<p class="title">Message</p>
<textarea name="message" maxrows="10" placeholder="Message"></textarea><br/>
<button type="submit" name="submit"><h2>SUBMIT</h2></button><br/>
</form>
</main>
</body>
Here's my contactform.php:
<?php
if (isset($_POST['submit'])) {
$name = $_POST['name'];
$subject = $_POST['subject'];
$mailFrom = $_POST['mail'];
$message = $_POST['message'];
$mailTo = "terryjtowell#terrytowell.com";
$headers = "From: ".$mailFrom;
$txt = "You have received an Email from ".$name.".\n\n".$message;
mail($mailTo, $subject, $txt, $headers);
header("Location: index.php?mailsend");
}
Any help would be great. I'm new to PHP but really familiar with html. the live link for the test contact form is terrytowell.com/test/index.php I've made sure to upload my code to a live hosting service so that I'll be able to use server-side scripting. Thanks
Your code is right. The problem comes from your hosting.
Freehosting.com won't allow you to use mail() function unless you pay for an addon. It's all explained here -> https://www.freehosting.com/client/knowledgebase.php?action=displayarticle&id=25
I have a PHP code and I want to put the successful print (instead of a new white page) into my design in the html part of that php file:
PHP
<?php
// GET EMAIL
$email=$_POST["email"];
// To avoid problems, only lower case is used
$email=strtolower($email);
// Check whether email is correct by using a function
// function requires the email address and the error message
check_email ($email, "Error: email is not valid.");
$emails = $file;
$count = substr_count('#', $emails);
// GET VALUE FOR action : subc (subscribe) or unsubc (unsubscribe)
$action=$_POST["action"];
// this is the file with the info (emails)
// When using the link in the top to download the complete script, a new
name for this file
// will be generated (p.e.: emaillist-2ax1fd34rfs.txt), so users will be
unable to find it
$file = "emaillist-5g04kNwj69.txt";
// lets try to get the content of the file
if (file_exists($file)){
// If the file is already in the server, its content is pasted to variable
$file_content
$file_content=file_get_contents($file);
}else{
// If the file does not exists, lets try to create it
// In case file can not be created (probably due to problems with
directory permissions),
// the users is informed (the first user will be the webmaster, who must
solve the problem).
$cf = fopen($file, "w") or die("Error: file does not exits, and it can not
be create.<BR>Please check permissions in the directory or create a file with coresponding name.");
fputs($cf, "Mailing list subscribers\n");
fclose($cf);
}
// IF REQUEST HAS BEEN TO SUBSCRIBE FROM MAILING LIST, ADD EMAIL TO THE FILE
if ($action=="subc"){
// check whether the email is already registered
if(strpos($file_content,"<$email>")>0){die("Error: your email is already
included in this mailing list");}
// write the email to the list (append it to the file)
$cf = fopen($file, "a");
fputs($cf, "\n<$email>"); // new email is written to the file in a
new line
fclose($cf);
// notify subscription
print "Your email has been added to our mailing list.<br>Thanks for
joining us.";
}
// IF REQUEST HAS BEEN TO UNSUBSCRIBE FROM MAILING LIST, REMOVE EMAIL FROM THE
FILE
if ($action=="unsubc"){
// if email is not in the list, display error
if(strpos($file_content,"<$email>")==0){die("Error: your email is not
included in this mailing list");}
// remove email from the content of the file
$file_content=preg_replace ("/\n<$email>/","",$file_content);
// print the new content to the file
$cf = fopen($file, "w");
fputs($cf, $file_content);
fclose($cf);
// notify unsubscription
print "Your email has been removed from our mailing list. ";
}
?>
and I want to insert that print instead on my html
HTML
<html>
<head>
<meta charset="UTF-8">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<meta http-equiv="Content-Language" content="en">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>TAPITAP APP</title>
<link rel="stylesheet" type="text/css" href="css/main.css">
<link href="https://fonts.googleapis.com/css?family=Raleway" rel="stylesheet">
</head>
<body>
<audio id="audioPromotional" src="promotional.mp3" ></audio>
<img id="tapiLogo" src="images/logo.svg">
<div id="tapiWrapper">
<img id="finger" src="images/finger.svg"/>
<img id="tapi2" src="images/img1.svg"/>
<img id="tapi1" src="images/img2.svg"/>
<img id="tapi1Shadow" src="images/shadow.svg"/>
</div>
<div id="emailBox">
<form action="<?php $PHP_SELF; ?>" method="post">
<div id="descriptionText">
<h4 class="descriptionText">We’re about to launch our game app really soon!
If you subscribe we'll let you know few days before the big day!! and also the very same day the app is active on store, thanks for your help!</h4>
</div>
<div id="emailImputPositioning">
<input type="text" name="email" placeholder="Email...">
</div>
<div id="responsiveTest">
<input type="radio" id="unsubscribe" class="rad" name="action" value="unsubc"/>
<label class="labelFirst" for="unsubscribe">UNSUBSCRIBE</label>
</div>
<div id="responsiveTest2">
<input type="radio" id="subscribe" class="rad" name="action" value="subc"/>
<label class="labelSecond" for="subscribe">SUBSCRIBE</label>
</div>
<button class="btn" id="btn" type="submit" value="Submit">SEND</button>
</form>
I WANT TO INSERT THAT PRINT HERE
</div>
</body>
</html>
That's what I would like to do, could someone help me to understand how to solve this? appreciated.
You can save your output into a PHP variable and echo it where you need.
Instead of print use like this:.
<?php
$output= "my Output message";
?>
<html>
....
</form>
<?php
echo $output;
?>
</body>
</html>
You could wrap your PHP script into a function and call the latter in your HTML where you want to display your message.
I am beginner in web developing, I am building a website which has contact form and when the details are entered the details has to be sent to my mail id. But I am not sure why the code is not working.
<?php
if(isset($_POST["submit"])){
// Checking For Blank Fields..
if($_POST["name"]==""||$_POST["email"]==""||$_POST["note"]==""){
echo "Fill All Fields..";
}else{
// Check if the "Sender's Email" input field is filled out
$email=$_POST['email'];
// Sanitize E-mail Address
$email =filter_var($email, FILTER_SANITIZE_EMAIL);
// Validate E-mail Address
$email= filter_var($email, FILTER_VALIDATE_EMAIL);
if (!$email){
echo "Invalid Sender's Email";
}
else{
$message = $_POST['note'];
$headers = 'From:'. $email2 . "\r\n"; // Sender's Email
$headers .= 'Cc:'. $email2 . "\r\n"; // Carbon copy to Sender
// Message lines should not exceed 70 characters (PHP rule), so wrap it
$message = wordwrap($message, 70);
// Send Mail By PHP Mail Function
mail("[ email removed ]", $message, $headers);
echo "Your mail has been sent successfuly ! Thank you for your feedback";
}
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Hire-a-Tent</title>
<meta name="description" content="">
<meta name="author" content="">
<!-- Le styles -->
<link href="css/style.css" rel="stylesheet">
<!-- HTML5 shim, for IE6-8 support of HTML5 elements -->
<!--[if lt IE 9]>
<script src="js/html5shiv.js"></script>
<![endif]-->
<!-- jQuery -->
<script src="https://code.jquery.com/jquery-1.10.2.min.js"></script>
<!-- Javascript -->
<script src="js/jquery.placeholder.js"></script>
<script src="js/custom.js"></script>
<!-- Fav and touch icons -->
<link rel="shortcut icon" href="favicon.ico">
</head>
<body>
<div class="background">
<div class="wrapper">
<header>
<div class="tel"><span>CALL US:</span> 9738479234 <br /><span style="padding-left:150px;">9731015469</span></div>
<div class="social">
<img src="images/facebook.png" alt="" />
<img src="images/twitter.png" alt="" />
</div>
</header>
<div class="sidebar">
<div class="order-form">
<div class="order-form-head">
<h1>Rent -a- Tent</h1>
</div>
<div class="taxi-line"></div>
<!-- Contact Form -->
<form action="email_code.php" id="form" method="post" name="form">
<div class="inp"><input type="text" class="required" name="name" id="name" placeholder="Name..." /></div>
<div class="inp"><input type="text" class="required" name="tel" id="tel" placeholder="Telephone..." /></div>
<div class="inp"><input type="text" class="required" name="email" id="email" placeholder="Email..." /></div>
<div class="inp"><textarea class="required" name="note" id="note" placeholder="Message..."></textarea></div>
<button type="submit"></button>
<div class="spacer"></div>
</form>
<?php include "email_code.php"?>
</div>
<div class="address-box">
<img src="images/icon.png" class="icon" alt="" />
<div class="text">
<span>We are located at</span><br />
85, 4th cross road,<br />
GKW layout, vijayanagar<br />
Bengaluru-40
</div>
</div>
</div>
<div class="character">
<!-- <img src="images/transparent2.png" class="taxi-driver" alt="" /> -->
<marquee behavior="alternate">T2 Tent: Rs 100/day --- T3 Tent: Rs 200/day -- Sleeping Bag: Rs 50/day --</marquee>
</div>
<div class="spacer"></div>
<footer>
<p><strong><br/><br/>Hire-a-tent</strong> © All Rights Reserved. <!--Developed by the Frequency Themes --></p>
</footer>
</div>
</div>
</body>
</html>
There are a few things wrong here, so please go over my entire answer carefully.
Firstly, your entire code's execution is relying on the conditional statement it's set in:
if(isset($_POST["submit"])){...}
where it is looking for and is relying on a named attribute of the same name, which would most likely be your submit button being:
<button type="submit"></button>
It needs to be named:
<button type="submit" name="submit"></button>
or use an input type with a name attribute:
<input type="submit" name="submit" value="Submit">
Then you have an undefined variable $email2 which would most likely need to be $email, as per:
$email=$_POST['email'];
Having used error reporting, would have both signaled an "Undefined index submit..." warning, as well as "Undefined variable email2...".
Add error reporting to the top of your file(s) which will help find errors.
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
// rest of your code
Sidenote: Error reporting should only be done in staging, and never production.
Now, this line:
mail("[ email removed ]", $message, $headers);
It is missing the "subject" parameter, which is an important parameter when using mail().
I.e.:
mail("[ email removed ]", $subject, $message, $headers);
therefore, you will need to add a variable for it.
I.e.:
$subject = "Form submission";
For more information on mail() and headers, visit:
http://php.net/manual/en/function.mail.php
From the manual:
bool mail ( string $to , string $subject , string $message [, string $additional_headers [, string $additional_parameters ]] )
To check if mail() has been in fact executed, change:
mail("[ email removed ]", $message, $headers);
to
if(mail("[ email removed ]", $message, $headers)){
echo "Mail has been sent.";
}
else{
echo "Error. Check your mail logs.";
}
If/when you see "Mail has been sent.", then mail() has done its job.
If you don't receive mail, then check your Spam or contact your hosting company if you're on a hosted site.
If you're running this from your own computer, then make sure that PHP and mail are in fact installed, running and configured properly.
Footnotes:
You're using the following twice, which one of them can be safely removed:
$email= filter_var($email, FILTER_VALIDATE_EMAIL);
EDIT:
To add other form variables to the message, first declare the POST variables:
$name=$_POST['name'];
$email=$_POST['email'];
$tel=$_POST['tel'];
Then change $message = $_POST['note']; to $comment = $_POST['note'];
and then do:
$message = "$name\n$email\n$tel\n$comment";
The \n adds line breaks.
I am trying to set up a contact form at:
http://48hrcodes.com/contact.php
however I am trouble getting it to work.
Here is the code I am using:
<?php
/**
* Change the email address to your own.
*
* $empty_fields_message and $thankyou_message can be changed
* if you wish.
*/
// Change to your own email address
$your_email = "";
// This is what is displayed in the email subject line
// Change it if you want
$subject = "48hrcodes contact form";
// This is displayed if all the fields are not filled in
$empty_fields_message = "<p>Please go back and complete all the fields in the form.</p>";
// This is displayed when the email has been sent
$thankyou_message = "<p>Thank you. Your message has been received.</p>";
// You do not need to edit below this line
$name = stripslashes($_POST['txtName']);
$email = stripslashes($_POST['txtEmail']);
$message = stripslashes($_POST['txtMessage']);
if (!isset($_POST['txtName'])) {
?>
<html lang="en">
<head>
<link href='https://fonts.googleapis.com/css?family=Droid+Sans:400,700' rel='stylesheet' type='text/css'>
<link href='https://fonts.googleapis.com/css?family=Oswald' rel='stylesheet' type='text/css'>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<link rel="stylesheet" href="css/style.css">
<title>Free 48hr Xbox Live Gold Codes</title>
</head>
<body>
<div id="content">
<div id="c1"> <center>
<header id="nav">
<ul>
<li>Home</li>
<li>Get Your Code</li>
<li>Testimonials and Proof</li>
<li>Frequently Asked Questions</li>
<li>Contact Us</li>
</ul>
</header>
<img class="clear" src="img/grab3.png" alt="header">
</center>
<form class="form" method="post" action="<?php echo $_SERVER['REQUEST_URI']; ?>">
<p class="name">
<input type="text" name="txtName" id="name" placeholder="John Doe" />
<label for="name">Name</label>
</p>
<p class="email">
<input type="text" name="txtEmail" id="email" placeholder="mail#example.com" />
<label for="email">Email</label>
</p>
<p class="text">
<textarea name="txtMessage" placeholder="Write something to us" /></textarea>
</p>
<p class="submit">
<input type="submit" value="Send" />
</p>
</form>
<div id="cttxt">
<h3>
Contact Us
</h3>
<p>
Simply send us message using the contact form to the left and we will get back to you within 24-48 hours.
</p>
</div>
<center>
<footer>
© 48hrcodes.com 2013 - site by ollie rex
</footer>
</div></center>
</div>
</body>
</html>
<?php
}
elseif (empty($name) || empty($email) || empty($message)) {
echo $empty_fields_message;
}
else {
// Stop the form being used from an external URL
// Get the referring URL
$referer = $_SERVER['HTTP_REFERER'];
// Get the URL of this page
$this_url = "http://".$_SERVER['HTTP_HOST'].$_SERVER["REQUEST_URI"];
// If the referring URL and the URL of this page don't match then
// display a message and don't send the email.
if ($referer != $this_url) {
echo "You do not have permission to use this script from another URL, nice hacking attempt moron.";
exit;
}
// The URLs matched so send the email
mail($your_email, $subject, $message, "From: $name <$email>");
// Display the thankyou message
echo $thankyou_message;
}
?>
I get errors at the top of the page, as well as when i submit the form, the email i get only has the messagebox text, not the name or email.
I have tried everything i could think of, however it still fails to send anything except the msg variable.
Thanks :)
change
$name = stripslashes($_POST['txtName']);
$email = stripslashes($_POST['txtEmail']);
$message = stripslashes($_POST['txtMessage']);
To,
$name = (isset($_POST['txtName']))?stripslashes($_POST['txtName']):"";
$email = (isset($_POST['txtEmail']))?stripslashes($_POST['txtEmail']):"";
$message = (isset($_POST['txtMessage']))?stripslashes($_POST['txtMessage']):"";
To avoid the warnings at the top.
Use
like this
if(isset($_POST['txtName'])
{
$name = stripslashes($_POST['txtName']);
}