Php mailer script not working on Apache hosted Bootstrap website - php

I am creating a simple Django/Bootstrap website hosted on a VM running apache.
The path to my website is var/www/experiment/
I have followed this excellent tutorial on creating a php mailer contact form. I was having an issue with php not being installed on the account, but running sudo apt-get install libapache2-mod-php5 has solved this.
I also tried a second script given to me by a friend who has used it on several websites.
My problem is that the contact form emails are not being sent. I have checked it with 2 different email accounts and I have checked the spam folders in case. As I said, I have also checked two separate scripts.
What else could be wrong or needs to be changed/configured at my end?
My mailer.php file is located in var/www/experiment/php is this the right location?
Would anyone have a link to a better tutorial on using php mailer and apache?
EDIT: added code
Bootstrap - HTML
<form name="contactform" method="post" action="http://location_of_my_web_app/php/mailer.php"class="form-horizontal" role="form">
<div class="form-group">
<label for="inputName" class="col-lg-2 control-label">Name</label>
<div class="col-lg-10">
<input type="text" class="form-control" id="inputName" name="inputName" placeholder="Your Name">
</div>
</div>
<div class="form-group">
<label for="inputEmail1" class="col-lg-2 control-label">Email</label>
<div class="col-lg-10">
<input type="text" class="form-control" id="inputEmail" name="inputEmail" placeholder="Your Email">
</div>
</div>
<div class="form-group">
<label for="inputSubject" class="col-lg-2 control-label">Subject</label>
<div class="col-lg-10">
<input type="text" class="form-control" id="inputSubject" name="inputSubject" placeholder="Subject Message">
</div>
</div>
<div class="form-group">
<label for="inputPassword1" class="col-lg-2 control-label">Message</label>
<div class="col-lg-10">
<textarea class="form-control" rows="4" id="inputMessage" name="inputMessage" placeholder="Your message..."></textarea>
</div>
</div>
<div class="form-group">
<center>
<div class="col-lg-offset-2 col-lg-10">
<button type="submit" class="btn btn-primary">Send Message</button>
</div>
</center>
</div>
</form>
PHP
<?php
/* Set e-mail recipient */
$myemail = "my_address#gmail.com";
/* Check all form inputs using check_input function */
$name = check_input($_POST['inputName'], "Your Name");
$email = check_input($_POST['inputEmail'], "Your E-mail Address");
$subject = check_input($_POST['inputSubject'], "Message Subject");
$message = check_input($_POST['inputMessage'], "Your Message");
/* If e-mail is not valid show error message */
if (!preg_match("/([\w\-]+\#[\w\-]+\.[\w\-]+)/", $email))
{
show_error("Invalid e-mail address");
}
/* Let's prepare the message for the e-mail */
$subject = "Someone has sent you a message";
$message = "
Someone has sent you a message using your contac form:
Name: $name
Email: $email
Subject: $subject
Message:
$message
";
/* Send the message using mail() function */
mail($myemail, $subject, $message);
/* Redirect visitor to the thank you page */
header('Location: http://location_of_my_thank_you_page/Static/contact_thankyou.html');
exit();
/* Functions we used */
function check_input($data, $problem='')
{
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
if ($problem && strlen($data) == 0)
{
show_error($problem);
}
return $data;
}
function show_error($myError)
{
?>
<html>
<body>
<p>Please correct the following error:</p>
<strong><?php echo $myError; ?></strong>
<p>Hit the back button and try again</p>
</body>
</html>
<?php
exit();
}
?>

Are you using PHP's mail() function, or connecting to a server and sending mail via SMTP? Whatever the case, the official PHPMailer website has a variety of examples. Do note that if you want to test sending mail via SMTP, you can always configure a gmail account and mess around with it.
https://github.com/PHPMailer/PHPMailer/tree/master/examples

Related

Problems with PHP form validation

My form is spread across two pages. Pages are turned using the JS slider called Slick. After filling in the form and clicking the send button on page 2, the validation says I didn't fill in my name. You can see this for yourself on this website: Rofordaward. Just complete the nomination form and push send. HTML and PHP code below.
HTML
SNIPPET OF FORM (from nominate.html):
<form action="nominate.php" method="post">
<div class="single-item slider">
<div class="page1">
<label class="row">
<h2 class="headline">Your full name</h2>
<input type="text" name="yourname" placeholder="Forename and surname"></input>
</label>
<label class="row email">
<h2 class="headline">Your email address <p>Don't worry, we won't spam you or share your email address</p></h2>
<input type="text" name="email" placeholder="example#rofordaward.co.uk"></input>
</label>
<label class="row">
<h2 class="headline">Name of company</h2>
<input type="text" name="companyname" placeholder="e.g. Roford"></input>
</label>
</div>
<div class="page2">
<label class="row reason">
<h2 class="headline">Reason for nomination</h2>
<textarea id="textarea" rows="6" cols="25" maxlength="1000" name="reason" placeholder="A brief evidence based summary"></textarea>
<div id="text-area-wrap">
<div id="textarea_feedback"></div>
</div>
</label>
<div class="row button-wrap">
<div class="column small-12">
<input class="button" type="submit" value="Send it!">
</div>
</div>
</div>
</div>
</form>
PHP
/* Check all form inputs using check_input function */
$yourname = check_input($_POST['yourname'], "Enter your name");
$email = check_input($_POST['email']);
$companyname = check_input($_POST['companyname']);
$reason = check_input($_POST['reason'], "Write your reason");
/* If e-mail is not valid show error message */
if (!preg_match("/([\w\-]+\#[\w\-]+\.[\w\-]+)/", $email))
{
show_error("E-mail address not valid");
}
/*Message for the e-mail */
$message = "New submission
Name: $yourname
E-mail: $email
Company name: $companyname
Reason:
$reason
End of message
";
/* Send the message using mail() function */
mail($myemail, $subject, $message);
/* Redirect visitor to the thank you page */
header('Location: thanks.htm');
exit();
/* Functions used */
function check_input($data, $problem='')
{
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
if ($problem && strlen($data) == 0)
{
show_error($problem);
}
return $data;
}
function show_error($myError)
{
?>
<html>
<body>
<b>Please correct the following error:</b><br />
<?php echo $myError; ?>
</body>
</html>
<?php
exit();
}
?>
When I remove the scripts for the JS slider, the form becomes fully functional.
In your PHP Code, You are using $_POST['email'] which suits good according to code on your last HTML Block when <input type="text" name="email" /> as you have set it to 'email'
On other hand, in your First HTML Code Block:
<label class="row email">
....
<input type="text" name="youremail" ....></input>
</label>
You set name="youremail", which is definitely going to derive wrong result with your PHP Code. You should be using it like $_POST['youremail'] in your PHP Code to get it working.

How do I get my php form to display a succes notice?

This is my first post here. I'm really hoping you can help me out!
I just implemented a bootstrap contact form on my website. The form is set to redirect to another website if the mail is sent successfully. I really want it to just show a notice saying "E-mail sent" or something like that.
I do realize that
header('Location: http://address-of-confirmation-page.html');
exit();
is what needs to be changed, i just don't know how to change it to the success message
Here's my code:
The PHP
/* Set e-mail recipient */
$myemail = "your-email#gmail.com";
/* Check all form inputs using check_input function */
$name = check_input($_POST['inputName'], "Your Name");
$email = check_input($_POST['inputEmail'], "Your E-mail Address");
$subject = check_input($_POST['inputSubject'], "Message Subject");
$message = check_input($_POST['inputMessage'], "Your Message");
/* If e-mail is not valid show error message */
if (!preg_match("/([\w\-]+\#[\w\-]+\.[\w\-]+)/", $email))
{
show_error("Invalid e-mail address");
}
/* Let's prepare the message for the e-mail */
$subject = "Someone has sent you a message";
$message = "
Someone has sent you a message using your contac form:
Name: $name
Email: $email
Subject: $subject
Message:
$message
";
/* Send the message using mail() function */
mail($myemail, $subject, $message);
/* Redirect visitor to the thank you page */
header('Location: http://address-of-confirmation-page.html');
exit();
/* Functions we used */
function check_input($data, $problem='')
{
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
if ($problem && strlen($data) == 0)
{
show_error($problem);
}
return $data;
}
function show_error($myError)
{
?>
<html>
<body>
<p>Please correct the following error:</p>
<strong><?php echo $myError; ?></strong>
<p>Hit the back button and try again</p>
</body>
</html>
The HTML
<div class="container">
<div class="panel panel-default" style="margin:0 auto;width:500px">
<div class="panel-heading">
<h2 class="panel-title">Contact Form</h2>
</div>
<div class="panel-body">
<form name="contactform" method="post" action="php/contact.php" class="form-horizontal" role="form">
<div class="form-group">
<label for="inputName" class="col-lg-2 control-label">Name</label>
<div class="col-lg-10">
<input type="text" class="form-control" id="inputName" name="inputName" placeholder="Your Name">
</div>
</div>
<div class="form-group">
<label for="inputEmail1" class="col-lg-2 control-label">Email</label>
<div class="col-lg-10">
<input type="text" class="form-control" id="inputEmail" name="inputEmail" placeholder="Your Email">
</div>
</div>
<div class="form-group">
<label for="inputSubject" class="col-lg-2 control-label">Subject</label>
<div class="col-lg-10">
<input type="text" class="form-control" id="inputSubject" name="inputSubject" placeholder="Subject Message">
</div>
</div>
<div class="form-group">
<label for="inputPassword1" class="col-lg-2 control-label">Message</label>
<div class="col-lg-10">
<textarea class="form-control" rows="4" id="inputMessage" name="inputMessage" placeholder="Your message..."></textarea>
</div>
</div>
<div class="form-group">
<div class="col-lg-offset-2 col-lg-10">
<button type="submit" class="btn btn-default">
Send Message
</button>
</div>
</div>
</form>
</div>
</div>
</div>
Bootstrap already has success messages like this one, which would be nice to have:
<div class="bs-example">
<div class="alert alert-success fade in">
×
<strong>Success!</strong> Your message has been sent successfully.
</div>
</div>
Thanks in advance!
I suppose you can use
header('Location: http://current-page.php?success');
And put this somewhere suitable
if(isset($_GET['success'])){
//echo the success message
}
I guess this is kinda "hacky" but it works.
I would also recommend jQuery to submit the form to an external page and have it return a success and have jQuery return a success flag and then dynamically show the success message on the page. You can do some research on that, rather than using PHP to do this.
Why not just set the "http://address-of-confirmation-page.html" page to a simple thank you page? This wouldn't involve any clever scripting. Its basic, but it fits with your script!
so change :
/* Redirect visitor to the thank you page */
header('Location: http://address-of-confirmation-page.html');
exit();
to
/* Redirect visitor to the thank you page */
header('Location: http://yourwebsite.com/thank_you.php');
exit();
and thank_you.php would be :
<div class="bs-example">
<div class="alert alert-success fade in">
×
<strong>Success!</strong> Your message has been sent successfully.
</div>
</div>
Does that answer your question, or is that too simplistic of a solution?
The best way to do it, and it's not so hard (and easy to maintain) is using Ajax like the other suggested.
Javascript/jQuery
First add an id to the form element, let's say #contact-form, then let's send the form via ajax:
$("#contact-form").submit(function(e) {
$.ajax({
type: "POST",
url: php/contact.php,
data: $("#contact-form").serialize(),
success: function(data){
$('#message')
.addClass('alert-'+ data.status)
.append(data.message);
}
);
e.preventDefault();
});
HTML
Hide the message by default, and let's show the correct message depending of the p
<div id="message" class="alert" style="display: none;">
×
</div>
<!-- Your contact form here -->
PHP
That's your homework, the script should be waiting a response in json, something like:
$result = array(
'status' => // success | error ,
'message' => // 'Success Message' | 'validation message'
);
echo json_encode($result);

Code or Server issue - PHP contact form?

I'm redesigning a site, and having just uploaded the files to the host, am now testing that everything works. The message form is not working consistently - sometimes it sends the user to the thank you confirmation page and sometimes it displays the error: "500 Internal Server Error, The server encountered an internal error or misconfiguration and was unable to complete your request." However, no test email has arrived at the recipient address showing that the form has worked. Strangely, it successfully went through when I substituted my personal email address in the mailer.php document. This makes me think that the code works.
I'm suspecting that this is a server or email configuration issue, because I've also been having issues with email, after changing hosts, but possibly it has to do with my code?
HTML:
<form class="form-horizontal" method="post" action="mailer.php" class="form-horizontal" role="form">
<div class="form-group">
<label for="name" class="col-sm-2"><small>Name</small></label>
<div class="col-sm-10">
<input type="text" class="form-control" id="inputName" name="inputName" placeholder="Enter your full name" required>
</div>
</div>
<div class="form-group">
<label for="email" class="col-sm-2"><small>Email</small></label>
<div class="col-sm-10">
<input type="email" class="form-control" id="inputEmail" name="inputEmail" placeholder="Enter your email, example#domain.com" required>
</div>
</div>
<div class="form-group">
<label for="name" class="col-sm-2"><small>Telephone</small></label>
<div class="col-sm-10">
<input type="text" class="form-control" id="inputPhone" name="inputPhone" placeholder="Enter your telephone number" required>
</div>
</div>
<div class="form-group">
<label for="message" class="col-sm-2"><small>Message</small></label>
<div class="col-sm-10">
<textarea class="form-control" rows="4" name="inputMessage" id="inputMessage" placeholder="Enter your message here" required></textarea>
</div>
</div>
<div class="form-group">
<!-- The following field is for robots only, invisible to humans: -->
<p class="robotic" id="pot">
<label>If you're human leave this blank:</label>
<input name="robotest" type="text" name="robotest" id="robotest" class="robotest" />
</p>
</div>
<div class="form-group">
<div class="col-sm-10 col-sm-offset-2">
<input style="font-size:22px;" id="submit" name="submit" type="submit" value="Send" class="btn">
</div>
</div>
<div class="form-group">
<div class="col-sm-10 col-sm-offset-2">
<! Will be used to display an alert to the user>
</div>
</div>
</form>
mailer.php file:
<?php
/* Set e-mail recipient */
$myemail = "info#domain.com";
/* Check all form inputs using check_input function */
$name = check_input($_POST['inputName'], "Your name was not entered correctly.");
$email = check_input($_POST['inputEmail'], "Your email address was not entered correctly.");
$phone = check_input($_POST['inputPhone'], "Your telephone number was not entered correctly.");
$message = check_input($_POST['inputMessage'], "Your message was not entered correctly.");
$robotest = $_POST['robotest'];
/* If e-mail is not valid show error message */
if (!preg_match("/([\w\-]+\#[\w\-]+\.[\w\-]+)/", $email))
{
show_error("Invalid e-mail address.");
}
/* ROBOT TEST */
if($robotest)
{
show_error("Denied, robot.");
}
/* prepare the message for the e-mail */
$subject = "Inquiry from Website";
$message = "
Someone has sent you a message using your website's contact form:
Name: $name
Email: $email
Telephone: $phone
Subject: $subject
Message:
$message
";
/* send the message using mail() function */
mail($myemail, $subject, $message);
/* redirect visitor to the thank you page */
header('Location: http://www.website.com/thankyou.html');
exit();
/* functions used */
function check_input($data, $problem='')
{
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
if ($problem && strlen($data) == 0)
{
show_error($problem);
}
return $data;
}
function show_error($myError)
{
?>
<html>
<body>
<p>Please correct the following error:</p>
<strong><?php echo $myError; ?></strong>
<p>Hit the back button and try again.</p>
</body>
</html>
<?php
exit();
}
?>
It appears you have a server/configuration problem. I've used this code and put it on my own server and it works perfectly fine. (also, nice work, very clean code)
One thing to think about when checking whether you get emails or not (specifically when a personal email works, but a corporate one does not) is email heuristics. Try changing the content setup and/or the subject line. (the subject line looks suspcious to me, I'd start there).
https://en.wikipedia.org/wiki/Naive_Bayes_spam_filtering

How do I enable SMTP for my PHP contact form?

I have successfully set up a php script for my contact form on my website but I have recently found out that my server provider does not accept php. Instead I have use SMTP.
Can anyone help me as this is new to me. I've attempted using other scripts but I cannot implement it.
This is my php code:
<?php
/* Set e-mail recipient */
$myemail = "mail#louisreed.co.uk";
/* Check all form inputs using check_input function */
$name = check_input($_POST['name'], "Your Name");
$email = check_input($_POST['email'], "Your E-mail Address");
$subject = check_input($_POST['subject'], "Message Subject");
$message = check_input($_POST['message'], "Your Message");
/* If e-mail is not valid show error message */
if (!preg_match("/([\w\-]+\#[\w\-]+\.[\w\-]+)/", $email))
{
show_error("Invalid e-mail address");
}
/* Let's prepare the message for the e-mail */
$subject = "Someone has sent you a message";
$message = "
Someone has sent you a message using your contact form:
Name: $name
Email: $email
Subject: $subject
Message:
$message
";
/* Send the message using mail() function */
mail($myemail, $subject, $message);
/* Redirect visitor to the thank you page */
header('Location: http://louisreed.co.uk');
exit();
/* Functions we used */
function check_input($data, $problem='')
{
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
if ($problem && strlen($data) == 0)
{
show_error($problem);
}
return $data;
}
function show_error($myError)
{
?>
<html>
<body>
<p>Please correct the following error:</p>
<strong><?php echo $myError; ?></strong>
<p>Hit the back button and try again</p>
</body>
</html>
<?php
exit();
}
?>
My HTML form:
<div class="row">
<div class="col-lg-8 col-lg-offset-2">
<form role="form" action="http://www.louisreed.co.uk/includes/mailer.php" method="post">
<div class="row">
<div class="form-group col-xs-12 floating-label-form-group">
<label for="name">Name</label>
<input class="form-control" type="text" id="name" name="name" placeholder="Name">
</div>
</div>
<div class="row">
<div class="form-group col-xs-12 floating-label-form-group">
<label for="email">Email Address</label>
<input class="form-control" type="email" id="email" name="email" placeholder="Email Address">
</div>
</div>
<div class="row">
<div class="form-group col-xs-12 floating-label-form-group">
<label for="subject">Subject</label>
<textarea placeholder="Subject" class="form-control" id="subject" name="subject" rows="1"></textarea>
</div>
</div>
<div class="row">
<div class="form-group col-xs-12 floating-label-form-group">
<label for="message">Message</label>
<textarea placeholder="Message" class="form-control" id="message" name="message" rows="5"></textarea>
</div>
</div>
<br>
<div class="row">
<div class="form-group col-xs-12">
<button type="submit" class="btn btn-lg btn-primary">Send</button>
</div>
</div>
</form>
</div>
</div>
Any suggestions welcome!
Thanks! :)
Louis
Oke I checked a few thinks. I guess you could atleast try the following. I know your host doesn't support php which find hard to believe tough. So maybe something else is wrong. What is the host you are using?
<?php
if($_POST) {
//Strip user input
function sanitize($value) {
//Escape the user input and then strip all html tags
//mysql_* is not recommended but I guess you don't store data in a database
$value = mysql_real_escape_string(strip_tags($value));
//Return the sanitized user input
return $value;
}
//To display all errors
function errors($error) {
echo '<ul class="error">';
foreach($error as $fail) {
echo '<li>'.$fail.'</li>';
}
echo '</ul>';
}
//All the input fields
$name = sanitize($_POST['name']);
$email = sanitize($_POST['email']);
$subject = sanitize($_POST['subject']);
$message = sanitize($_POST['message']);
//Check if there are no empty fields
if(!empty($name), !empty($email) && !empty($subject) && !empty($message)) {
if(strlen($name) <= 3) {
$error[] = 'Name '.$name.' is too short';
}
if(strlen($email) <= 3) {
$error[] = 'Email '.$email.' is too short';
}
if(!filter_var($email, FILTER_VALIDATE_EMAIL)) {
$error[] = 'Email '.$email.' is not a valid email';
}
if(strlen($subject) <= 3) {
$error[] = 'Subject '.$subject.' is too short';
}
if(strlen($message) <= 8) {
$error[] = 'Message is too short';
}
//If there are no errors
if(empty($error)) {
$to = "mail#louisreed.co.uk"; //The email you want to send it to
//Subject already set
$headers = "FROM: My site"; //Sets the headers
//The message for the email
$message = "Someone has sent you a message using your contact form:\r\n\r\nName: ".$name."\r\nEmail: ".$email."\r\nSubject: ".$subject."\r\n\r\nMessage: ".$message;
$mail = mail($to, $subject, $message, $headers);
//If the mail has been send
if($mail) {
header('Location: http://louisreed.co.uk/index.php?success');
exit();
}
}
} else {
$error[] = 'There are empty fields';
}
//If there are errors show them
if(!empty($error)) {
echo errors($error);
}
}
//If issset success (from the header()) display a message
if(isset($_GET['success'])) {
echo '<p>Thank you for your message</p>';
}
?>
<form role="form" action="" method="post">
<div class="row">
<div class="form-group col-xs-12 floating-label-form-group">
<label for="name">Name</label>
<input class="form-control" type="text" id="name" name="name" placeholder="Name">
</div>
</div>
<div class="row">
<div class="form-group col-xs-12 floating-label-form-group">
<label for="email">Email Address</label>
<input class="form-control" type="email" id="email" name="email" placeholder="Email Address">
</div>
</div>
<div class="row">
<div class="form-group col-xs-12 floating-label-form-group">
<label for="subject">Subject</label>
<textarea placeholder="Subject" class="form-control" id="subject" name="subject" rows="1"></textarea>
</div>
</div>
<div class="row">
<div class="form-group col-xs-12 floating-label-form-group">
<label for="message">Message</label>
<textarea placeholder="Message" class="form-control" id="message" name="message" rows="5"></textarea>
</div>
</div>
<br>
<div class="row">
<div class="form-group col-xs-12">
<button type="submit" class="btn btn-lg btn-primary">Send</button>
</div>
</div>
</form>
So try the exact code I gave you above just copy and past it over the form code you have now. You can leave the rest of your code as is. After that save the complete file as index.php. After that remove the index.html file from your FTP. If you have done that you can upload the index.php file now check what you get. If there are still some errors please let me know

PHP Mailer. Clicking send downloads the php script but does not send mail

I am following a tutorial on how to implement a simple Bootstrap contact form with a PhP mailer script.
However when I click Send Message, my contact form downloads the PHP script rather than sending the email. What am I doing wrong?
Bootstrap - HTML
<form name="contactform" method="post" action="http://location_of_my_web_app/php/mailer.php" class="form-horizontal" role="form">
<div class="form-group">
<label for="inputName" class="col-lg-2 control-label">Name</label>
<div class="col-lg-10">
<input type="text" class="form-control" id="inputName" name="inputName" placeholder="Your Name">
</div>
</div>
<div class="form-group">
<label for="inputEmail1" class="col-lg-2 control-label">Email</label>
<div class="col-lg-10">
<input type="text" class="form-control" id="inputEmail" name="inputEmail" placeholder="Your Email">
</div>
</div>
<div class="form-group">
<label for="inputSubject" class="col-lg-2 control-label">Subject</label>
<div class="col-lg-10">
<input type="text" class="form-control" id="inputSubject" name="inputSubject" placeholder="Subject Message">
</div>
</div>
<div class="form-group">
<label for="inputPassword1" class="col-lg-2 control-label">Message</label>
<div class="col-lg-10">
<textarea class="form-control" rows="4" id="inputMessage" name="inputMessage" placeholder="Your message..."></textarea>
</div>
</div>
<div class="form-group">
<center>
<div class="col-lg-offset-2 col-lg-10">
<button type="submit" class="btn btn-primary">Send Message</button>
</div>
</center>
</div>
</form>
PHP
<?php
/* Set e-mail recipient */
$myemail = "my_address#gmail.com";
/* Check all form inputs using check_input function */
$name = check_input($_POST['inputName'], "Your Name");
$email = check_input($_POST['inputEmail'], "Your E-mail Address");
$subject = check_input($_POST['inputSubject'], "Message Subject");
$message = check_input($_POST['inputMessage'], "Your Message");
/* If e-mail is not valid show error message */
if (!preg_match("/([\w\-]+\#[\w\-]+\.[\w\-]+)/", $email))
{
show_error("Invalid e-mail address");
}
/* Let's prepare the message for the e-mail */
$subject = "Someone has sent you a message";
$message = "
Someone has sent you a message using your contac form:
Name: $name
Email: $email
Subject: $subject
Message:
$message
";
/* Send the message using mail() function */
mail($myemail, $subject, $message);
/* Redirect visitor to the thank you page */
header('Location: http://location_of_my_thank_you_page/Static/contact_thankyou.html');
exit();
/* Functions we used */
function check_input($data, $problem='')
{
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
if ($problem && strlen($data) == 0)
{
show_error($problem);
}
return $data;
}
function show_error($myError)
{
?>
<html>
<body>
<p>Please correct the following error:</p>
<strong><?php echo $myError; ?></strong>
<p>Hit the back button and try again</p>
</body>
</html>
<?php
exit();
}
?>
"my contact form downloads the PHP script rather than sending the email"
It sounds like PHP is either not installed/running or not properly configured.
I suggest that you create a file called test.php file with <?php echo "Hello world"; ?> inside it and see if it does the same thing.
If it still wants to appear like it wants to download, then there's the problem; PHP is not installed or not properly configured and isn't parsing PHP as it normally should.
Create another file and place <?php phpinfo(); ?> and it should show you the server's information.

Categories