Thanks nancy, I forgot you couldn't see the PHP. Hereis the form:
<!DOCTYPE html>
<html lang="en">
<head>
<script src="../js/jquery.js"></script>
<script>
// here is showver and hidever
$(document).ready(function() {
function showver() {
$('#trigger').show();
}
function hidever() {
$('#trigger').hide();
}
$('#trigger').hide();
$('#trigger').hover(showver,hidever);
});
</script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>higgsy - Contact</title>
<link href="../css/xampp_higgsy_new.css" rel="stylesheet" type="text/css" />
<link href="../css/higgs.css" rel="stylesheet" type="text/css" />
<style>
.push_form {
margin-left: 300px;
margin-top: 50px;
}
.detail {
width:260px;
padding: 7px 8px;
margin: 0;
display: block;
}
</style>
</head>
<body>
<?php include_once("../analyticstracking_DAV.php") ?>
<div class="container">
<div class="sidebar1">
<ul class="nav">
<li><a href="../index.php">Home</a></li>
<li><a href="../adoption/10_adoption.php">Adoption</a></li>
<li><a href="../ancestry/10_ancestry.php">Ancestry</a></li>
<li><a href="../Drinking/10_drinks_index.php">Drinking</a></li>
<li><a href="../dvds/05_login_url.php">DVDs</a></li>
<li><a href="../garage/garage.php">Garage</a></li>
<li><a href="../garden/garden.php">Garden</a></li>
<li><a href="../france/france.php">France</a></li>
<li><a href="../work/100_work_bookbinding.php">Work</a></li>
<li><a href="../schooldays/10_school.php">School</a></li>
<li><a href="../journey/journey.php">Journey</a></li>
<li><a href="../2018.php">2018</a></li>
<li><a href="contact_form.php">Contact</a></li>
</ul>
</div> <!-- end .sidebar1 -->
<div class="content">
<!-- my Back/Next nav bar -->
<table class="navtable">
<tr>
<td> </td>
<td><a href="../index.php">Back</a></td>
<td>Next</td>
</tr>
</table>
<h2 class="centre_this_text">Contact</h2>
<div class="push_form">
<form method="post" action="send.php">
<input class="detail" type="text" name="name" placeholder="Your Name" required><br><br>
<input type="email" name="email" placeholder="Your Email" required><br><br>
<textarea name="message" placeholder="Your Message" required></textarea><br><br>
<!-- <input type="hidden" name="phone2">-->
<button type="submit">Send Email</button>
</form>
</div>
</div><!-- end .content -->
<div class="footer">
<?php include("../includes/footer.htm"); ?>
</div> <!-- end .footer -->
</div> <!-- end .container -->
</body>
</html>
and here is the send.php with the non-functioning PHP header statement at the bottom of the code.
<!DOCTYPE html>
<html lang="en">
<head>
<script src="../js/jquery.js"></script>
<script>
// here is showver and hidever
$(document).ready(function() {
function showver() {
$('#trigger').show();
}
function hidever() {
$('#trigger').hide();
}
$('#trigger').hide();
$('#trigger').hover(showver,hidever);
});
</script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>higgsy - Contact</title>
<link href="../css/xampp_higgsy_new.css" rel="stylesheet" type="text/css" />
<link href="../css/higgs.css" rel="stylesheet" type="text/css" />
</head>
<body>
<?php include_once("../analyticstracking_DAV.php") ?>
<div class="container">
<div class="sidebar1">
<ul class="nav">
<li><a href="../index.php">Home</a></li>
<li><a href="../adoption/10_adoption.php">Adoption</a></li>
<li><a href="../ancestry/10_ancestry.php">Ancestry</a></li>
<li><a href="../Drinking/10_drinks_index.php">Drinking</a></li>
<li><a href="../dvds/05_login_url.php">DVDs</a></li>
<li><a href="../garage/garage.php">Garage</a></li>
<li><a href="../garden/garden.php">Garden</a></li>
<li><a href="../france/france.php">France</a></li>
<li><a href="../work/100_work_bookbinding.php">Work</a></li>
<li><a href="../schooldays/10_school.php">School</a></li>
<li><a href="../journey/journey.php">Journey</a></li>
<li><a href="../2018.php">2018</a></li>
<li><a href="contact_form.php">Contact</a></li>
</ul>
</div> <!-- end .sidebar1 -->
<div class="content">
<!-- my Back/Next nav bar -->
<table class="navtable">
<tr>
<td> </td>
<td><a href="../index.php">Back</a></td>
<td>Next</td>
</tr>
</table>
<?php
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
require '../vendor/autoload.php';
$name = filter_var($_POST['name'], FILTER_SANITIZE_STRING);
$phone = filter_var($_POST['phone'], FILTER_SANITIZE_STRING);
$email = filter_var($_POST['email'], FILTER_SANITIZE_STRING);
$message = filter_var($_POST['message'], FILTER_SANITIZE_STRING);
$mail = new PHPMailer(true);
try {
error_log( "DH0010 - send.php entered v7", 0 ); // works!!
$mail->setFrom('email@example.com [real email removed by moderator]');
$mail->addAddress($email, $name); //Add a recipient
//Body content
$body = "<p><strong>Hello</strong>, enquiry from " . $name . " the msg is " . $message . "</p>";
//Content
$mail->isHTML(true);
$mail->Subject = 'Website Enquiry from ' . $name;
$mail->Body = $body;
$mail->AltBody = strip_tags($body);
$mail->send();
echo "email sent";
//header('location: http://example.com [real URL removed by moderator]');
header('location: thankyou.php');
error_log( "DH0020 - send.php finished...", 0 ); // works!!
} catch (Exception $e) {
echo "Message could not be sent. MMailer Error: {$mail->ErrorInfo}";
} // close the catch
?>
</div><!-- end .content -->
<div class="footer">
<?php include("../includes/footer.htm"); ?>
</div> <!-- end .footer -->
</div> <!-- end .container -->
</body>
</html>
I am wondering if my PHP is in the correct place as I seem to recall there is a case where you have to put the PHP right at the top of the document, before the DOCTYPE - is my code ok where i've put it?
Also your example code looks very useful and I'll take closer look once I'm clear of this present problem!
many thanks
David
... View more