scot Posted April 1, 2020 Share Posted April 1, 2020 Hello, When I submit my home-built php contact form (below) the information doesn't make it to my inbox - it just disappears. There's no error log and once I click the Submit button, it says the info was submitted successfully. <form method="POST" action="mailer.php"> Name: <input type="text" name="name" size="19"><br> <br> Company: <input type="text" name="company" size="19"><br> <br> e-Mail: <input type="text" name="email" size="19"><br> <br> <input type="checkbox" name="check[]" value="digital_sample"> <b>Please send unrestricted digital access<br> <input type="checkbox" name="check[]" value="physical_sample"> Reserve my physical, retail shipper pack</b><br><br> <p style="text-align:center; font-family:Arial"> Shipping Instructions:<br> <textarea rows="9" name="message" cols="30"></textarea><br> <br> <input type="submit" value="Submit" name="submit"></p> </form> <?php $check_msg = ""; if(isset($_POST['submit'])) { $to = "contact@stopsmokingforgood.com"; $subject = "Sample Request"; $name_field = $_POST['name']; $email_field = $_POST['email']; $company_field = $_POST['company']; $message = $_POST['message']; foreach($_POST['check'] as $value) { $check_msg .= "Checked: ".$value; } $body = "From: ".$name_field.": E-Mail: ".$email_field." : Company: ".$company_field." : Message: ".$message." : ".$check_msg; echo "Data has been submitted to ".$to; mail($to, $subject, $body); } else { echo "blarg!"; } ?> Quote Link to comment Share on other sites More sharing options...
ginerjm Posted April 1, 2020 Share Posted April 1, 2020 This script is a bit mal-constructed. YOu are outputting an html form but then your follow it with the php logic that means nothing UNTIL the form is submitted. A good layout would be to have the php come first and the html come later. Plus it is a bit out-dated. And you are missing some headers for the email. Quote Link to comment Share on other sites More sharing options...
scot Posted April 1, 2020 Author Share Posted April 1, 2020 Um, sorry - I'm new at this php stuff and not sure what you're talking about. Maybe I should've explained that the form is on my webpage and the php is separate, on my server. Quote Link to comment Share on other sites More sharing options...
ginerjm Posted April 1, 2020 Share Posted April 1, 2020 Maybe you should show us the actual code then.... What about the points I made? Quote Link to comment Share on other sites More sharing options...
Chopthewood Posted April 2, 2020 Share Posted April 2, 2020 In addition to what was suggested above, from where are you serving this? Local Server or Remote? If it is a local server such as WAMP pr MAMP you might need to configure it so it picks up the php mail(). In MAMP it is not configured this way when first installed. Quote Link to comment Share on other sites More sharing options...
ginerjm Posted April 2, 2020 Share Posted April 2, 2020 I doubt if the mail is being sent. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.