I'm developing a kind of simple form for a side project I am doing.
It's based on a very simple contact form.
I have a very similar one working here
But the one here doesn't appear to be working
https://crgdev.com/BrandAddition/
Code below (very new to the site so probably doing something wrong)
<?php
if(isset($_POST['email'])) {
// EDIT THE 2 LINES BELOW AS REQUIRED
$email_to = "chris@crgdev.com";
$email_subject = "New Starter - ";
function died($error) {
// your error code can go here
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['first_name']) ||
!isset($_POST['last_name']) ||
!isset($_POST['email']) ||
!isset($_POST['accessrequirements'])) {
died('We are sorry, but there appears to be a problem with the form you submitted.');
}
$first_name = $_POST['first_name']; // required
$last_name = $_POST['last_name']; // required
$email_from = $_POST['email']; // required
$accessrequirements = $_POST['accessrequirements']; // required
$error_message = "";
$email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/';
if(!preg_match($email_exp,$email_from)) {
$error_message .= 'The Email Address you entered does not appear to be valid.<br />';
}
$string_exp = "/^[A-Za-z .'-]+$/";
if(!preg_match($string_exp,$first_name)) {
$error_message .= 'The First Name you entered does not appear to be valid.<br />';
}
if(!preg_match($string_exp,$last_name)) {
$error_message .= 'The Last Name you entered does not appear to be valid.<br />';
}
if(strlen($accessrequirements) < 2) {
$error_message .= 'The Comments you entered do not appear to be valid.<br />';
}
if(strlen($error_message) > 0) {
died($error_message);
}
$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 .= "First Name: ".clean_string($first_name)."\n";
$email_message .= "Last Name: ".clean_string($last_name)."\n";
$email_message .= "Start Date: ".clean_string($start_date)."\n";
$email_message .= "Job Title: ".clean_string($job_title)."\n";
$email_message .= "Team Leader: ".clean_string($team_leader)."\n";
$email_message .= "Location: ".clean_string($location)."\n";
$email_message .= "Access Requirements: ".clean_string($accessrequirements)."\n";
$email_message .= "Email/Phone Access: ".clean_string($emailaccess)."\n";
$email_message .= "Other Requirements: ".clean_string($otherrequirements)."\n";
$email_message .= "Subitted by: ".clean_string($email_from)."\n";
// create email headers
$headers = 'From: '.$email_from."\r\n".
'Reply-To: '.$email_from."\r\n" .
'X-Mailer: PHP/' . phpversion();
@mail($email_to, $email_subject, $email_message, $headers);
?>
<!-- include your own success html here -->
Thank you for submitting your New STarter Form. We will be in touch with you regarding any updates.
<html>
<p>Go back to <a href="https://brandaddition.com">Brand Addition/a></p>
</html>
<style>
body {
font-size: larger;
text-align: center;
}
</style>
<?php
}
?>
<body>
<div class="fixedwidth">
<div id="brandlogo"><img src="brandadditionlogo.png"</div>
<h1>New Starter Form</h1>
<div id="formdiv">
<form name="newstarterform" method="post" action="send_form_email.php">
<table id="formtable">
<tr>
<td><input type="text" name="first_name" placeholder="First Name" maxlength="50"></td>
</tr>
<tr>
<td><input type="text" name="last_name" placeholder="Last Name" maxlength="50"></td>
</tr>
<tr>
<td>Start Date: <input type="date" name="start_date" placeholder="Start Date" maxlength="50"></td>
</tr>
<tr>
<td><input type="text" name="job_title" placeholder="Job Title" maxlength="50"></td>
</tr>
<tr>
<td><input type="text" name="team_leader" placeholder="Team Leader" maxlength="50"></td>
</tr>
<tr>
<td> Location:
<select name="location">
<option value="Manchester">Manchester</option>
<option value="London">London</option>
<option value="Ireland">Ireland</option>
</select>
</td>
</tr>
<tr>
<td>
<p class="pagepara"><span class="bold">List the access requirements needed, this should include</span><br><br>
• Level of oasis access or which user we should copy to set the oasis access level<br>
• Corporate programs that the user should have access to<br>
• Any specific applications that the employee would need access to<br>
• Which share drive folders should the employee have access to<br>
</p>
<textarea name="accessrequirements" placeholder="Access Requirements" maxlength="1000" cols="50" rows="10"></textarea>
</td>
</tr>
<tr>
<td>
<p class="pagepara"><span class="bold">List the email and telephone groups that the user should receive<br> communications from</span><br><br>
</p>
<textarea name="emailaccess" placeholder="Email/Phone Access" maxlength="1000" cols="50" rows="10"></textarea>
</td>
</tr>
<tr>
<td>
<input type="checkbox" name="desktop computer">Desktop Computer
<input type="checkbox" name="laptop">Laptop <br>
<input type="checkbox" name="mobile phone">Mobile phone
<input type="checkbox" name="remote access">Remote Access<br><br>
<textarea name="otherrequirements" placeholder="Other requirements not mentioned above?" maxlength="1000" cols="50" rows="10"></textarea>
</td>
</tr>
<tr>
<td>
<p class="bold">Enter your email below for communications</p>
<input type="email" name="submitter">
</td>
</tr>
<tr>
<td style="padding: 40px 0px 80px 0px">
<input type="submit" value="Submit">
</td>
</tr>
</table>
</form>
</div>
<div id="blueline"></div>
</div>
</body>