Jump to content

Application form problem


Go to solution Solved by maxxd,

Recommended Posts

Hi.

I've been thrown in the deep end with a community shed website when the person who knows HTML bailed out
I have very little knowledge of writing forms - none actually.
I've done my best at writing (plagarising) an application form with no success.
Can someone give me a heads up where I've gone wrong?

This is the application HTML:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
  <meta content="text/html; charset=ISO-8859-1"
 http-equiv="content-type">
  <title>Application</title>
  <meta content="Alistair" name="author">
  <style>
body {
background-color:rgb(102, 255, 255);

}
ul {
list-style-type: none;
display: flex;
margin: 70;
padding: 60;
overflow: hidden;
spacing: 120;
# background-color:rgb(102, 255, 255);
}

li {
float: left;
}

li {
margin-right: 110px;
}

li a, .dropbtn {
display: inline-block;
color: black;
text-align: center;
padding: 14px 16px;
text-decoration: none;
}

li a:hover, .dropdown:hover .dropbtn {
background-color: grey;
}

li.dropdown {
display: inline-block;
}

.dropdown-content {
display: none;
position: absolute;
background-color: #f9f9f9;
min-width: 160px;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
z-index: 1;
}

.dropdown-content a {
color: black;
padding: 12px 16px;
text-decoration: none;
display: block;
text-align: left;
}

.dropdown-content a:hover {background-color: #f1f1f1;}

.dropdown:hover .dropdown-content {
display: block;
}
  </style>
</head>
<body style="margin-left: 0px; width: 1303px;">
<table style="width: 1280px; height: 129px;" border="0">
  <tbody>
    <tr>
      <td style="width: 377.25px; text-align: right;"><img
 style="width: 302px; height: 115px;" alt="Logo" src="Images/logo.png"></td>
      <td style="width: 560.883px;">
      <div style="text-align: center;"><font size="+3"><span
 style="font-family: serif;"><span
 style="font-family: Helvetica,Arial,sans-serif;">Livingston Community
Shed
      <div style="text-align: center;"><small
 style="font-family: sans-serif;">Application Form</small><br>
      </div>
      <font size="+3"><span style="font-family: serif;"><span
 style="font-family: Helvetica,Arial,sans-serif;"></span></span></font></span></span></font></div>
      <big> <font size="+3"> <font size="+3"><span
 style="font-family: serif;"></span></font> </font></big></td>
      <td style="width: 402.867px; text-align: left;"><span><img
 src="Images/smsa-logo.png" alt="smsa logo"
 style="width: 279px; height: 102px;"><br>
      </span></td>
    </tr>
  </tbody>
</table>
<ul>
  <li style="font-weight: bold;"><big><a href="index.html">Home</a></big></li>
  <li style="font-weight: bold;"><big><a href="about.html">About</a></big></li>
  <li style="font-weight: bold;"><big><a href="findus.html">Find Us</a></big></li>
  <big> </big>
  <li style="font-weight: bold;" class="dropdown"><big> <a
 href="javascript:void(0)" class="dropbtn">News</a></big>
    <div style="top: 178px; left: 671px;" class="dropdown-content"><a
 href="updates.html">Updates</a><a href="projects.html">Projects</a><a
 href="gardens.html">Gardens</a><a href="videos.html">Videos</a></div>
  </li>
  <li style="font-weight: bold;"><big><a href="join.html">Join</a></big></li>
  <big> <big> </big> </big>
  <li style="font-weight: bold;"><big><a href="contact.html">Contact</a></big></li>
</ul>
<div style="text-align: center;"><!-- ************ End of Headings ************** -->
<br>
<big><big><big><span
 style="font-family: Helvetica,Arial,sans-serif; color: rgb(51, 51, 255); font-weight: bold;">Livingston
Community Shed Application Form</span></big></big></big>
</div>
<div style="text-align: center; width: 1199px;"><br>
</div>
<table
 style="text-align: left; width: 900px; margin-left: auto; margin-right: auto;"
 cellpadding="2" cellspacing="2">
  <tbody>
    <tr>
      <td style="vertical-align: top; width: 464px;">
      <form style="margin-left: 0px; width: 410px;"><!-- ************ Forename ************** -->
        <div style="margin-left: 0px; width: 391px;">
        <div style="text-align: left;"> <label for="fname">First name:</label><br>
        </div>
        <div style="text-align: left;"><input id="fname" name="fname"
 value="" type="text"><br>
        <br>
        </div>
<!-- ************ Surname ************** -->
        <div style="text-align: left;"><label for="sname">Surname:</label><br>
        </div>
        <div style="text-align: left;"><input id="sname" name="sname"
 value="" type="text"><br>
        <br>
        </div>
<!-- ************ Address 1 ************** -->
        <div style="text-align: left;"> <label for="add1">Address 1:</label><br>
        </div>
        <div style="text-align: left;"><input size="30" id="add1"
 name="add1"><br>
        <br>
        </div>
<!-- ************ Address 2 ************** -->
        <div style="text-align: left;"><label for="add2">Address 2:</label><br>
        </div>
        <div style="text-align: left;"><input size="30" id="add2"
 name="add2"><br>
        <br>
        </div>
<!-- ************ Town ************** -->
        <div style="text-align: left;"> <label for="town">Town / City:</label><br>
        </div>
        <div style="text-align: left;"><input id="town" name="town"
 value="" type="text"><br>
        <br>
        </div>
<!-- ************ Postcode ************** -->
        <div style="text-align: left;"><label for="pcode">Postcode:</label><br>
        </div>
        <div style="text-align: left;"><input size="8" name="pcode"
 id="pcode"><br>
        <br>
        </div>
<!-- ************ email ************** -->
        <div style="text-align: left;"><label for="email">Email:<br>
        <input id="email" name="email" type="email"><br>
        </label></div>
<!-- ************ Phone number ************** -->
        <div style="text-align: left;"><label for="phone">Phone Number:</label><br>
        </div>
        <div style="text-align: left;"><input size="15" name="phone"
 id="phone" type="tel"><br>
        <br>
        </div>
<!-- ************ Birthday ************** -->
        <div style="text-align: left;"><label for="bday">Date of Birth:</label><br>
        </div>
        <div style="text-align: left;"><input size="8" id="bday"
 name="bday" value="" type="date"><br>
        <br>
        </div>
        </div>
      </form>
      </td>
      <td style="vertical-align: top; width: 632px;">
      <form style="width: 529px;"> <label for="cname">Contact name:</label><br>
        <input id="cname" name="cname" value="" type="text"><br>
        <br>
        <label for="relat">Relationship:</label><br>
        <input id="relat" name="relat" value="" type="text"> <br>
        <br>
        <label for="cphone">Contact Phone Number:</label><br>
        <input id="cphone" name="cphone" type="tel"> <span
 style="font-weight: bold;"><br>
        <br>
        </span>
        <div><label for="allergy">Please list any allergies you may
have:<br>
        </label>
        <div style="text-align: left; margin-left: 0px; width: 978px;"
 class="fcf-input-group"> <textarea cols="30" id="allergy"
 name="allergy" class="fcf-form-control" rows="5" maxlength="1000"
 required=""></textarea> </div>
        <br>
        <label for="skill">Please list any skills/interests which may
be useful to the shed:</label><br>
        <div style="text-align: left; margin-left: 0px; width: 978px;"
 class="fcf-input-group"> <textarea cols="30" id="skill" name="skill"
 class="fcf-form-control" rows="5" maxlength="1000" required=""></textarea>
        </div>
        <br>
        </div>
      </form>
      </td>
    </tr>
  </tbody>
</table>
<table
 style="text-align: left; width: 950px; margin-left: auto; height: 31px; margin-right: auto;"
 cellpadding="2" cellspacing="2">
  <tbody>
    <tr>
      <td style="vertical-align: top; width: 874px;"><input id="permit"
 name="permit" value="No" type="checkbox"> <label for="permit">May we
include a summary of this and a photo in the member&#8217;s section of the
website?</label><br>
      </td>
    </tr>
  </tbody>
</table>
<table
 style="text-align: left; height: 151px; margin-right: auto; width: 950px; margin-left: auto;"
 cellpadding="2" cellspacing="2">
  <tbody>
    <tr>
      <td colspan="1" rowspan="1"
 style="vertical-align: top; text-align: center; width: 950px;">
      <p style="line-height: 100%; margin-bottom: 0cm;" align="left"><font
 style="font-size: 14pt;" size="4"><b>Constitution acceptance</b></font></p>
      <span style="font-weight: bold;"></span>
      <p style="line-height: 100%; margin-bottom: 0cm;" align="left"><font
 style="font-size: 12pt;" size="3"><input id="perm" name="agree"
 value="No" type="checkbox"> <label for="agree">I
agree to abide by the constitution of the Livingston Community Shed, a
copy of which is held in the shed
and on this Website.</label><br>
      </font><br>
      </p>
      <p style="line-height: 100%; margin-bottom: 0cm;" align="left"><font
 style="font-size: 12pt;" size="3"><input id="smsa" name="smsa"
 value="No" type="checkbox"><label for="smsa">By
applying, I also agree to abide by the Scottish Men&#8217;s Sheds Association
(SMSA) Constitution and Purposes to which we are affiliated with group
membership.</label></font></p>
      <form style="margin-top: 16px; height: 55px;" enctype="text/plain"
 method="post" action="/application.php"> <input
 style="height: 50px; width: 70px;" value="Submit" align="middle"
 type="submit"><br>
<!-- **** If you click the "Submit" button, the form-data will be sent to a page called "/application.php **** -->
      </form>
      </td>
    </tr>
  </tbody>
</table>
</body>
</html>

The PHP page that accompanies it is:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
<?php if (isset($_POST['Email'])) {

    // EDIT THE 2 LINES BELOW AS REQUIRED
    $email_to = "merg.eosag@gmail.com";
    $email_subject = "New Application Request.";

    function problem($error)
    {
        echo "We are very sorry, but there were error(s) found with the form you submitted. ";
        echo "These errors appear below.<br><br>";
        echo $error . "<br><br>";
        echo "Please go back and fix these errors.<br><br>";
        die();
    }

    // validation expected data exists
    if (
        !isset($_POST['fname']) ||
        !isset($_POST['sname']) ||
        !isset($_POST['email']) ||
        !isset($_POST['bday']) ||
        !isset($_POST['agree']) ||
        !isset($_POST['smsa'])
        
    ) {
        problem('We are sorry, but there appears to be a problem with the form you submitted.');
    }

    $fname = $_POST['fname']; // required
    $sname = $_POST['sname']; // required
    $email = $_POST['email']; // required
    $fname = $_POST['bday']; // required
    $sname = $_POST['agree']; // required
    $email = $_POST['smsa']; // required


    $error_message = "";
    $email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/';

    if (!preg_match($email_exp, $email)) {
        $error_message .= 'The Email address you entered does not appear to be valid.<br>';
    }

    $string_exp = "/^[A-Za-z .'-]+$/";

    if (!preg_match($string_exp, $fname)) {
        $error_message .= 'The Name you entered does not appear to be valid.<br>';
    }

    $string_exp = "/^[A-Za-z .'-]+$/";

    if (!preg_match($string_exp, $sname)) {
        $error_message .= 'The Name you entered does not appear to be valid.<br>';
    }
    
   $string_exp = "";

    if(!preg_match($string_exp,$bday)) {

    $error_message .= 'You did not choose a date.<br />';

    }

    if (isset($_POST['agree'])) {
   // Checkbox is checked
  } else {
        $error_message .= 'You did not agree to the constitution.<br>';
    }

    if (isset($_POST['smsa'])) {
   // Checkbox is checked
  } else {
        $error_message .= 'You did not agree to the SMSA rules.<br>';
    }

    $email_message = "Form details below.\n\n";

    function clean_string($string)
    {
        $bad = array("content-type", "bcc:", "to:", "cc:", "href");
        return str_replace($bad, "", $string);
    }

    $email_message .= "Foreame: " . clean_string($fname) . "\n";
    $email_message .= "Surname: " . clean_string($sname) . "\n";
    $email_message .= "Address1: " . clean_string($add1) . "\n";
    $email_message .= "Address2: " . clean_string($add2) . "\n";
    $email_message .= "Town: " . clean_string($town) . "\n";
    $email_message .= "Postcode: " . clean_string($pcode) . "\n";
    $email_message .= "Email: " . clean_string($email) . "\n";
    $email_message .= "Phone Number: " . clean_string($phone) . "\n";
    $email_message .= "Date of Birth: " . clean_string($bday) . "\n";
    $email_message .= "Contact Name: " . clean_string($cname) . "\n";
    $email_message .= "Relationship: " . clean_string($relat) . "\n";
    $email_message .= "Contact Phone: " . clean_string($cphone) . "\n";
    $email_message .= "Allergies: " . clean_string($allergy) . "\n";
    $email_message .= "Skills: " . clean_string($skill) . "\n";
    $email_message .= "Page Permission: " . clean_string($permit) . "\n";
    $email_message .= "Abide by LCS Rules: " . clean_string($agree) . "\n";
    $email_message .= "Abide by SMSA Rules: " . clean_string($smsa) . "\n";

    // create email headers
    $headers = 'From: ' . $email . "\r\n" .
        'Reply-To: ' . $email . "\r\n" .
        'X-Mailer: PHP/' . phpversion();
    @mail($email_to, $email_subject, $email_message, $headers);
?><!-- include your success message below -->
  <title>Application.php</title>
</head>
<body style="color: rgb(0, 0, 0); background-color: rgb(102, 255, 255);"
 alink="#000099" link="#000099" vlink="#990099">
<br>
<div style="text-align: center;"><?php }
?>
<br>
<br>
<big>Thank you for your application. We will be in touch with you
very soon.
<br>
</big>
</div>
<div style="text-align: center;"><big><a href="index.html"><br>
Back to Home page</a></big><br>
</div>
</body>
</html>

 

 

Edited by Fitch
Link to comment
https://forums.phpfreaks.com/topic/323784-application-form-problem/
Share on other sites

  • Fitch changed the title to Application form problem

What we need to know is

6 minutes ago, Fitch said:

When anyone fills in the form, it is never sent.

that. To be blunt, we can't help you solve a problem if you don't tell us what the problem is.

 

I'm guessing that when you say "it is never sent", you mean "I always receive the 'there appears to be a problem with the form' message even when I fill out all the fields"?

Three things:
1. Only one <form> can be submitted at a time
2. Only the fields inside of that <form> will be included in the submission
3. When you click a submit button, its parent <form> is the one that gets submitted - if there is one

For the record, the actual rules are a little more complicated, but the above covers most situations. Including this one.

Considering the above, it should make sense you don't get any data: the Submit button isn't in a form at all, but if it was, you've split the fields between multiple <form> elements.

Form elements don't have any meaning when it comes to (visually) designing a page, so you can put them anywhere you want.
Have one single <form> that covers the entire form, with all the fields and the submit button. Use it to "wrap" the entire application form.

what is your goal for doing this? to have a working form to email application or to learn programming? if it's to have a working, secure, application, you need to hire someone or use an existing service. if it is to learn how to do this, i recommend that you start with a blank page (don't copy/paste out-of-date things you find on the web), and get the code to fully work for a single form field, then worry about adding all the code necessary for the rest of the fields.

some points for creating an application -

  1. put the form processing code and the form on the same page. the code for any page should be laid out in this general order - 1) initialization, 2) post method form processing, 3) get method business logic - get/produce data needed to display the web page, 4) html document
  2. validate any web page you create at validator.w3.org
  3. the form processing code should detect if a post method form was submitted before referencing any of the form data.
  4. keep the form data as a set in a php array variable, then operate on elements in this array variable throughout the rest of the code, i.e. don't create discrete variables for every form field.
  5. trim all the input data before validating it. once you do item #4 on this list, you can trim all the data using a single line of code.
  6. validate the now trimmed data, store user/validation errors in an array using the field name as the array index.
  7. don't roll your own email valuation. use php's filter_var() with the FILTER_VALIDATE_EMAIL flag.
  8. after the end of the validation logic, if there are no errors (the array holding the user/validation errors will be empty), use the submitted form data.
  9. any value you use in a html context (web page, email) needs to have htmlentities() applied to it, right before being used, to help prevent cross site scripting.
  10. these emails are not being sent from the email address that someone entered in the form. they are being sent from the mail server at your web hosting. the From: mail header must be an email address that corresponds to your web hosting. the Reply-to: mail header can be set to the entered email address.
  11. don't use the php @ error suppressor, ever.
  12. you must test the returned value from the mail() call and take an appropriate action depending on the value. if it is a false value, you need to setup a message for the user (add it to the array holding the user/validation errors) that the email was unsuccessful. for a true value, you  would let the post method form processing code run to completion.
  13. at the end of the form processing code, if there are no errors, you need to perform a redirect to the exact same URL of the current page to cause a get request. this will prevent the browser from trying to resubmit the form data should the URL get browsed back to or reloaded.
  14. to display a one-time success message, either store a flag value or the message in a session variable, then test for, display the success message, and clear the session variable at the appropriate location in the html document.
  15. if there are user/validation errors at item #8 or #13 on this list, the code will continue on to redisplay the html document, where you would test for and display the user/validation errors, and redisplay the form, populating field values, select choices, checkbox/radio fields with any existing data, so that the user doesn't need to keep reentering/reselecting data over and over upon an error.
  16. as an advanced programming subject, if you have more than 2-3 fields, you need to dynamically - validate and process the form data, and dynamically build the form.
  • Solution

In addition to everything requinix and mac_gyver have mentioned, you have several different <form></form> elements in your HTML - this is incorrect. There should be one form that encompasses all the input fields in your form. The reason you're getting the success message every time is that the form element that surrounds the submit button contains only the submit button - the Email field is in a different form (I'm assuming - your formatting got weird and hard to follow). Add the following right before the `<?php if(isset($_POST['Email']) {` line in application.php:

<pre><?php var_export($_POST, true); ?></pre>

 

On 9/3/2024 at 10:02 AM, Fitch said:

Thanks.
I've deleted the extra "form"s and put that line in the php file.

I'll give it a try tomorrow from outside as I can't access the website from the same LAN as the server is on.

Sorry to be such an idiot on this.

I'll mark it solved and won't bother you again.

No such thing as an idiot unless you are me ;)

Try this:

<!DOCTYPE HTML>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Application.php</title>
</head>
<body style="color: #000; background-color: #66FFFF;">
<?php
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    // Define recipient and subject
    $email_to = "merg.eosag@gmail.com";
    $email_subject = "New Application Request.";

    // Function to handle errors
    function handleError($error) {
        echo "We are very sorry, but there were error(s) found with the form you submitted. ";
        echo "These errors appear below:<br><br>";
        echo $error . "<br><br>";
        echo "Please go back and fix these errors.<br><br>";
        die();
    }

    // Validate required fields
    $required_fields = ['fname', 'sname', 'email', 'bday', 'agree', 'smsa'];
    foreach ($required_fields as $field) {
        if (!isset($_POST[$field])) {
            handleError('We are sorry, but there appears to be a problem with the form you submitted.');
        }
    }

    // Sanitize and validate input
    $fname = cleanInput($_POST['fname']);
    $sname = cleanInput($_POST['sname']);
    $email = cleanInput($_POST['email']);
    $bday = cleanInput($_POST['bday']);
    $agree = isset($_POST['agree']) ? 'Yes' : 'No';
    $smsa = isset($_POST['smsa']) ? 'Yes' : 'No';

    $error_message = validateInput($fname, $sname, $email, $bday);

    if (!empty($error_message)) {
        handleError($error_message);
    }

    // Prepare email message
    $email_message = "Form details below:\n\n";
    $email_message .= "First Name: $fname\n";
    $email_message .= "Surname: $sname\n";
    $email_message .= "Email: $email\n";
    $email_message .= "Date of Birth: $bday\n";
    $email_message .= "Agree to Terms: $agree\n";
    $email_message .= "Agree to SMSA Rules: $smsa\n";

    // Create email headers
    $headers = "From: $email\r\n" .
               "Reply-To: $email\r\n" .
               "X-Mailer: PHP/" . phpversion();

    // Send email
    @mail($email_to, $email_subject, $email_message, $headers);
    echo "<div style='text-align: center;'><big>Thank you for your application. We will be in touch with you very soon.</big></div>";
    echo "<div style='text-align: center;'><big><a href='index.html'>Back to Home page</a></big></div>";
}

function cleanInput($data) {
    return htmlspecialchars(stripslashes(trim($data)));
}

function validateInput($fname, $sname, $email, $bday) {
    $error_message = "";
    if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
        $error_message .= 'The Email address you entered does not appear to be valid.<br>';
    }
    if (!preg_match("/^[A-Za-z .'-]+$/", $fname)) {
        $error_message .= 'The First Name you entered does not appear to be valid.<br>';
    }
    if (!preg_match("/^[A-Za-z .'-]+$/", $sname)) {
        $error_message .= 'The Surname you entered does not appear to be valid.<br>';
    }
    if (empty($bday)) {
        $error_message .= 'You did not choose a date.<br>';
    }
    return $error_message;
}
?>
</body>
</html>

 

Hi Moorcam.

I tried it and got:

"; echo $error . "

"; echo "Please go back and fix these errors.

"; die(); } // Validate required fields $required_fields = ['fname', 'sname', 'email', 'bday', 'agree', 'smsa']; foreach ($required_fields as $field) { if (!isset($_POST[$field])) { handleError('We are sorry, but there appears to be a problem with the form you submitted.'); } } // Sanitize and validate input $fname = cleanInput($_POST['fname']); $sname = cleanInput($_POST['sname']); $email = cleanInput($_POST['email']); $bday = cleanInput($_POST['bday']); $agree = isset($_POST['agree']) ? 'Yes' : 'No'; $smsa = isset($_POST['smsa']) ? 'Yes' : 'No'; $error_message = validateInput($fname, $sname, $email, $bday); if (!empty($error_message)) { handleError($error_message); } // Prepare email message $email_message = "Form details below:\n\n"; $email_message .= "First Name: $fname\n"; $email_message .= "Surname: $sname\n"; $email_message .= "Email: $email\n"; $email_message .= "Date of Birth: $bday\n"; $email_message .= "Agree to Terms: $agree\n"; $email_message .= "Agree to SMSA Rules: $smsa\n"; // Create email headers $headers = "From: $email\r\n" . "Reply-To: $email\r\n" . "X-Mailer: PHP/" . phpversion(); // Send email @mail($email_to, $email_subject, $email_message, $headers); echo "
Thank you for your application. We will be in touch with you very soon.
"; echo "
Back to Home page
"; } function cleanInput($data) { return htmlspecialchars(stripslashes(trim($data))); } function validateInput($fname, $sname, $email, $bday) { $error_message = ""; if (!filter_var($email, FILTER_VALIDATE_EMAIL)) { $error_message .= 'The Email address you entered does not appear to be valid.
'; } if (!preg_match("/^[A-Za-z .'-]+$/", $fname)) { $error_message .= 'The First Name you entered does not appear to be valid.
'; } if (!preg_match("/^[A-Za-z .'-]+$/", $sname)) { $error_message .= 'The Surname you entered does not appear to be valid.
'; } if (empty($bday)) { $error_message .= 'You did not choose a date.
'; } return $error_message; } ?> 

which is part of the PHP file isn't it?

Thanks though, at least it got to the PHP file.

  • 2 weeks later...
On 9/7/2024 at 7:15 AM, Fitch said:

Hi Moorcam.

I tried it and got:

"; echo $error . "

"; echo "Please go back and fix these errors.

"; die(); } // Validate required fields $required_fields = ['fname', 'sname', 'email', 'bday', 'agree', 'smsa']; foreach ($required_fields as $field) { if (!isset($_POST[$field])) { handleError('We are sorry, but there appears to be a problem with the form you submitted.'); } } // Sanitize and validate input $fname = cleanInput($_POST['fname']); $sname = cleanInput($_POST['sname']); $email = cleanInput($_POST['email']); $bday = cleanInput($_POST['bday']); $agree = isset($_POST['agree']) ? 'Yes' : 'No'; $smsa = isset($_POST['smsa']) ? 'Yes' : 'No'; $error_message = validateInput($fname, $sname, $email, $bday); if (!empty($error_message)) { handleError($error_message); } // Prepare email message $email_message = "Form details below:\n\n"; $email_message .= "First Name: $fname\n"; $email_message .= "Surname: $sname\n"; $email_message .= "Email: $email\n"; $email_message .= "Date of Birth: $bday\n"; $email_message .= "Agree to Terms: $agree\n"; $email_message .= "Agree to SMSA Rules: $smsa\n"; // Create email headers $headers = "From: $email\r\n" . "Reply-To: $email\r\n" . "X-Mailer: PHP/" . phpversion(); // Send email @mail($email_to, $email_subject, $email_message, $headers); echo "
Thank you for your application. We will be in touch with you very soon.
"; echo "
Back to Home page
"; } function cleanInput($data) { return htmlspecialchars(stripslashes(trim($data))); } function validateInput($fname, $sname, $email, $bday) { $error_message = ""; if (!filter_var($email, FILTER_VALIDATE_EMAIL)) { $error_message .= 'The Email address you entered does not appear to be valid.
'; } if (!preg_match("/^[A-Za-z .'-]+$/", $fname)) { $error_message .= 'The First Name you entered does not appear to be valid.
'; } if (!preg_match("/^[A-Za-z .'-]+$/", $sname)) { $error_message .= 'The Surname you entered does not appear to be valid.
'; } if (empty($bday)) { $error_message .= 'You did not choose a date.
'; } return $error_message; } ?> 

which is part of the PHP file isn't it?

Thanks though, at least it got to the PHP file.

Is that the actual error you got? It doesn't make sense. It just looks like php code showing on a html page.

Paste the contents of application.php

Edited by Moorcam

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.