Skip to main content
Known Participant
December 29, 2022
Question

Simple form not working

  • December 29, 2022
  • 3 replies
  • 265 views

Can someone let me know where I screwed up here?

 

http://angelscancleaning.com/booking-page.html

 

<?php
 
$emailSubject = 'Bin Washing';
$webMaster = 'service@angelsjunkremoval.com';
 
$user_name = $_POST['name'];
$user_address = $_POST['address'];
$user_city = $_POST['city'];
$user_email = $_POST['email'];
$user_phone = $_POST['phone']
$user_frequency = $_POST['frequency'];
$user_bins = $_POST['bins'];
$user_notes = $_POST['notes'];
 
$body = <<<EOD
<br><hr><br>
Name: $name <br>
Address: $address <br>
City: $city <br>
Email: $email <br>
Phone: $phone <br>
Frequency: $frequency <br>
Bins: $bins <br>
Notes: $notes <br>
EOD;
 
$headers = "From: $email\r\n";
$headers .= "Content-type: text/html\r\n";
$success = mail($webMaster, $emailSubject, $body, $headers);
 
/* Results rendered as HTML */
 
$theResults = <<<EOD
<html>
<head>
<title>You're Booked</title>
</head>
<body>
<h1>Booked</h1>
<p>Thank you for booking with us. We clean the day after your trash day. We will contact you soon to let you know the date of your next appointment</p>
</body>
</html>
EOD;
echo "$theResults";
 
?>

 

    This topic has been closed for replies.

    3 replies

    Legend
    December 30, 2022

    All of your php variables are inconsistent, you use $user_name to get the information from the form field and then try to output that as $name for example. 

     

    Also do you specifically know that your server supports the php mail function? If you can clarify it does then l can most probably help.

     


     

    Nancy OShea
    Community Expert
    Community Expert
    December 30, 2022

    I highly recommend using HTML5 contact forms with a secure processing script.  The PHP script you're using now is not nearly secure enough for today's web.   See the secure script below.

    https://github.com/PHPMailer/PHPMailer

     

    PHP Mailer is what most hosting providers recommend because it sanitizes form input data before it reaches your server.  There's less chance of hackers exploiting your forms and using your server as a spam relay.

     

    If you can't work with code, use a 3rd party form-to-email service like Wufoo.com or Jotform.com   The form data is processed by their servers, not yours.

     

    Hope that helps.

     

    Nancy O'Shea— Product User & Community Expert
    Known Participant
    December 30, 2022

    Thanks for the help. Yes, I'm using an older style PHP.

    BenPleysier
    Community Expert
    Community Expert
    December 29, 2022

    Looks like you have not included the jQuery library for your JavaScript starting at line 13

    Wappler is the DMXzone-made Dreamweaver replacement and includes the best of their powerful extensions, as well as much more!