Greetings Fellow PHPFreaks!
LovableCodeMan here - newbie to this forum an pretty new to this PHP thing that all these youngsters are raving about - who knew?!
Anyway, so I have an HTML form set up with a PHP document attached in order to send the data from the form to an email -a pretty basic setup by todays standards.
In the PHP document, you can see that there is a section for the user (
[email protected]) to submit the information in the form to us & is sent to our email address "
[email protected]". The bottom segment is to send a confirmation email back to the sender - to "
[email protected]" - as a thank you and a "We will get back to you ASAP" etc etc etc.
The confirmation email sent to the
[email protected] works flawlessly when pressing the "Send Your Message" button, but then I just see "https://www.xyz.com/scripts/mail.php" in the address bar and no email is received by
[email protected] - aka "Us".
This is the PHP document - confidential information redacted & the "
[email protected]" & "
[email protected]" replace the real email addresses.
<!doctype html>
<?php
$title = $_POST['title'];
$first = $_POST['first'];
$surname = $_POST['surname'];
$email = $_POST['email']; <!-------
[email protected]>
$internationalCode = $_POST['internationalCode'];
$number = $_POST['number'];
$userMessage = $_POST['userMessage'];
$company = $_POST['company'];
$Industrytype = $_POST['Industrytype'];
$inc_status = $_POST['inc_status'];
$state = ['state'];
$email_from = "$first $surname <smtp server login>";
$Password = 'smtp server password';
$email_subject = "Website Enquiry from $first $surname";
$messageTo = "
[email protected]";
$email_body =
"User title: $title. \n".
"The department this message is for is: $department.\n".
"User First Name: $first.\n".
"User Surname Name: $surname. \n".
"User email: $email.\n".
"International Dialing Code: $internationalCode. \n".
"User Contact Number: $number.\n".
"State of Incorporation: $state.\n".
"File: $attachment.\n".
"Company Name: $company, $inc_status.\n".
"Industry type: $Industrytype.\n".
"User Message is: $userMessage.\n";
$headers = "From: $email_from" . "\r\n" . "Reply to: $first $surname". "\r\n";
mail($messageTo, $email_subject, $email_body, $headers, "
[email protected]");
header('Location: https://www.xyz.com/thank_you.html');
<!--------Confirmation email send to
[email protected] below---------------->
$respond_subject = "Thank you for your message";
/* Prepare autoresponder message */
$respond_message = "
Hi $first,
Thank you for messaging to us. We will aim to reply to you within 24 hours.
In the meantime, why not follow our other stories via, as well as following, our Facebook page. Simply go to https://www.facebook.com/xyz/
Yours sincerely,
The Support Team
[email protected].
";
$headers = 'From: <Sender> <
[email protected]>' . "\r\n" .
'Reply-To: $email' . "\r\n" .<!-------
[email protected]>
'X-Mailer: PHP/' . phpversion();
/* Send the message using mail() function */
mail($email, $respond_subject, $respond_message, $headers, "
[email protected]");
//}
?>
This is the HTML document:
<!doctype html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>
</head>
<body>
<form role="form-inline" method="POST" action="../scripts/mail.php">
<div class="form-group">
<div class="row">
<div class="col-lg-2 col-md-4 col-sm-4 col-xs-4 select ">
<select class="" id="standard-select" name="title">
<option selected disabled>Title *</option>
<option>Dr.</option>
<option>Mr.</option>
<option>Mrs.</option>
<option>Ms.</option>
<option>Prof.</option>
<option>Rev.</option>
<option>Pastor.</option>
<option>Miss.</option>
</select>
</div>
<div class="col-lg-4 col-md-4 col-sm-8 col-xs-8">
<input name="first" type="text" placeholder="First Name *" required/>
</div>
<div class="col-lg-6 col-md-4">
<input name="surname" type="text" placeholder="Surname *" required/>
</div>
</div>
<div class="row">
<div class="col-lg-6 col-md-4 col-sm-6 col-xs-12">
<input name="email" type="email" placeholder="Email *" required/>
</div>
<label for="standard-select"></label>
<div class="col-lg-2 col-md-4 col-sm-6 col-xs-5 select">
<select class="" name="internationalCode" id="">
<option data-countryCode="GB" value="44" Selected>UK (+44)</option>
<option data-countryCode="US" value="1" >USA (+1)</option>
<optgroup label="Other countries">
<option data-countryCode="DZ" value="213">Algeria (+213)</option>
<option data-countryCode="AD" value="376">Andorra (+376)</option>
<option data-countryCode="AO" value="244">Angola (+244)</option>
<option data-countryCode="AI" value="1264">Anguilla (+1264)</option>
<option data-countryCode="AG" value="1268">Antigua & Barbuda (+1268)</option>
<option data-countryCode="AR" value="54">Argentina (+54)</option>
<option data-countryCode="AM" value="374">Armenia (+374)</option>
</optgroup>
</select>
</div>
<div class="col-lg-4 col-md-4 col-sm-12 col-xs-7">
<input type="tel" name="number" placeholder="Telephone Number *" required/>
</div>
</div>
<div class="row">
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-12 select">
<select name="inc_status" required>
<option selected disabled>Incorporation status *</option>
<option>Limited by Guarantee</option>
<option>Limited by Shares</option>
<option>CIC</option>
<option>CIO</option>
<option>Unincorporated</option>
<option>LLP</option>
<option>LLC</option>
<option>Other</option>
</select>
</div>
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-12 select">
<select name="state" disabled>
<option selected disabled>State of incorporation *</option>
<option value="AL">Alabama</option>
<option value="AK">Alaska</option>
<option value="AZ">Arizona</option>
<option value="AR">Arkansas</option>
<option value="CA">California</option>
<option value="CO">Colorado</option>
<option value="CT">Connecticut</option>
<option value="DE">Delaware</option>
<option value="DC">District Of Columbia</option>
<option value="FL">Florida</option>
</select>
</div>
</div>
<div class="row">
<div class="col-xs-12 col-sm-12 col-md-6 col-lg-6">
<input name="company" type="text" placeholder="Company *" required/>
</div>
<div class="col-xs-12 col-sm-12 col-md-6 col-lg-6 select">
<select class="" name="Industrytype" id="select" value="">
<option selected disabled value="">Industry *</option>
<option value="Appraisal/Disposition">Appraisal/Disposition</option>
<option value="Business Services">Business Services</option>
<option value="Consulting">Consulting</option>
<option value="Business Broker">Business Broker</option>
<option value="Distribution">Distribution</option>
<option value="Education">Education</option>
<option value="Financial Services (Non-Lender)">Financial Services (Non-Lender)</option>
<option value="Government">Government</option>
<option value="Healthcare">Healthcare</option>
<option value="Insurance">Insurance</option>
<option value="Investment Banking">Investment Banking</option>
<option value="Law">Law</option>
<option value="Lender">Lender</option>
<option value="Logistics">Logistics</option>
<option value="Manufacturing">Manufacturing</option>
<option value="Media/Print/Broadcast/Internet">Media/Print/Broadcast/Internet</option>
<option value="Other">Other</option>
<option value="Private Equity/Venture Capital">Private Equity/Venture Capital</option>
<option value="Real Estate Services">Real Estate Services</option>
<option value="Receivables">Receivables</option>
<option value="Retail">Retail</option>
<option value="Technology">Technology</option>
<option value="Turnaround/Restructuring">Turnaround/Restructuring</option>
<option value="Utility">Utility</option>
<option value="Wholesale">Wholesale</option>
</select>
</div>
</div>
<div class="row">
<div class="col-lg-12">
<textarea name="userMessage" placeholder="Please type your message here. Do not include any personal information such as your NIN or any banking information."></textarea>
</div>
</div>
<div class="row">
<div class="col-lg-6 col-md-12 col-sm-12 col-xs-12">
<div class="" style="background-color: #E0DDDD; padding: 20px;">
<p style="font-size: 12px; color: #0d0155">Information is held under the provision of the General Data Protection Regulation (GDPR). We will not pass your details on to any other organisation. We will process your information in accordance with our privacy policy. By send this message, you agree to xxxxxxx's <a style="color: #0D0155; text-decoration: underline;" href="/privacy/online_privacy_notice.html" target="_new" class="inline_link__new_window">Online Privacy Policy</a>
</p>
</div>
</div>
<div class="col-lg-6 col-md-12 col-sm-12 col-xs-12">
<input type="submit" id="submit" name="submit" value="Send your message"/>
</div>
</div>
</div>
</form>
</body>
</html>
Anyone know where I'm going wrong, it "half works" so I'm Half Way There - & yes, I am Livin' on a Prayer!
Thanks in advance!
The LovableCodeman