php form isset validation - php

i have been trying to implement isset form validation on a signup form i am developing for my site......
basically i need all fields filled in correctly or form wont $_post.....
as im posting to self (form action="") i will need my form to reload and display error messages above form if not filled correctly....
here is my form code ....
<?php
if(!isset($_POST['submit'])) {
echo '
<form action="" method="post" name="signup">
<table border="1" width="100%">
<tr><td>
<p style="text-align: right;">First Name: </p>
</td><td>
<input name="first_name" type="text" maxlength="25">
</td></tr>
<tr><td>
<p style="text-align: right;">Last Name: </p>
</td><td>
<input name="last_name" type="text" maxlength="25">
</td></tr>
<tr><td>
<p style="text-align: right;">Desired Username: </p>
</td><td>
<input name="username" type="text" maxlength="25">
</td></tr>
<tr><td>
<p style="text-align: right;">Password: </p>
</td><td>
<input name="password" type="password" maxlength="25">
</td></tr>
<tr><td>
<p style="text-align: right;">Confirm Password: </p>
</td><td>
<input name="confpassword" type="password" maxlength="25">
</td></tr>
<tr><td>
<p style="text-align: right;">Date Of Birth: </p>
</td><td>
<select name="dob_day">
<option value="000">Day</option>
<option value="01">01</option>
<option value="02">02</option>
<option value="03">03</option>
<option value="04">04</option>
<option value="05">05</option>
<option value="06">06</option>
<option value="07">07</option>
<option value="08">08</option>
<option value="09">09</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
<option value="13">13</option>
<option value="14">14</option>
<option value="15">15</option>
<option value="16">16</option>
<option value="17">17</option>
<option value="18">18</option>
<option value="19">19</option>
<option value="20">20</option>
<option value="21">21</option>
<option value="22">22</option>
<option value="23">23</option>
<option value="24">24</option>
<option value="25">25</option>
<option value="26">26</option>
<option value="27">27</option>
<option value="28">28</option>
<option value="29">29</option>
<option value="30">30</option>
<option value="31">31</option>
</select>
<select name="dob_month">
<option value="000">Month</option>
<option value="january">January</option>
<option value="february">February</option>
<option value="march">March</option>
<option value="april">April</option>
<option value="may">May</option>
<option value="june">June</option>
<option value="july">July</option>
<option value="august">August</option>
<option value="september">September</option>
<option value="october">October</option>
<option value="november">November</option>
<option value="december">December</option>
</select>
Year:
<input name="dob_year" type="text" maxlength="4" size="10" value="eg: 1964">
</td></tr>
<tr><td>
<p style="text-align: right;">Email Address: </p>
</td><td>
<input name="email" type="text" maxlength="50">
</td></tr>
<tr><td>
<p style="text-align: right;">Gender: </p>
</td><td>
Male: <input type="radio" name="gender" value="male" />
Female: <input type="radio" name="gender" value="female" />
</td></tr>
</table><p>
<center><input type="submit" name="submit" value=" Sign-Up "></center>
</font>
';}
else
{
echo "Form Submitted";
}
?>
i know this form code looks garbled, and i hate messy code, but i had to truncate it to post on here, or i would be typing 4 spaces before hundreds of code lines lol
if anyone can come up with a solution to this (would presume pretty simple but cannot figure how to code it") i will be very greatful again :D
thanks guys
:bow: STACK EXCHANGE ALL THE WAY :bow:

else
{
$accept=true;
if(!isset($_POST["value1"])){
$accept=false;
$_SESSION["error"] .= "Please fill in value1\n";
}
//.... Other values
if(!$accept){
header("Location: Current file name"); //Check if the session has the error value filled in and display it on the form.
exit;
}
echo "Form Submitted";
}
Full example:
<?php
session_start();
if(!isset($_POST['submit'])) {
echo '
<form action="" method="post" name="signup">
<table border="1" width="100%">
<tr><td colspan="2">' . $_SESSION['error'] . ' </td></tr>
<tr><td>
<p style="text-align: right;">First Name: </p>
</td><td>
<input name="first_name" type="text" maxlength="25">
</td></tr>
<tr><td>
<p style="text-align: right;">Last Name: </p>
</td><td>
<input name="last_name" type="text" maxlength="25">
</td></tr>
<tr><td>
<p style="text-align: right;">Desired Username: </p>
</td><td>
<input name="username" type="text" maxlength="25">
</td></tr>
<tr><td>
<p style="text-align: right;">Password: </p>
</td><td>
<input name="password" type="password" maxlength="25">
</td></tr>
<tr><td>
<p style="text-align: right;">Confirm Password: </p>
</td><td>
<input name="confpassword" type="password" maxlength="25">
</td></tr>
<tr><td>
<p style="text-align: right;">Date Of Birth: </p>
</td><td>
<select name="dob_day">
<option value="000">Day</option>
<option value="01">01</option>
<option value="02">02</option>
<option value="03">03</option>
<option value="04">04</option>
<option value="05">05</option>
<option value="06">06</option>
<option value="07">07</option>
<option value="08">08</option>
<option value="09">09</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
<option value="13">13</option>
<option value="14">14</option>
<option value="15">15</option>
<option value="16">16</option>
<option value="17">17</option>
<option value="18">18</option>
<option value="19">19</option>
<option value="20">20</option>
<option value="21">21</option>
<option value="22">22</option>
<option value="23">23</option>
<option value="24">24</option>
<option value="25">25</option>
<option value="26">26</option>
<option value="27">27</option>
<option value="28">28</option>
<option value="29">29</option>
<option value="30">30</option>
<option value="31">31</option>
</select>
<select name="dob_month">
<option value="000">Month</option>
<option value="january">January</option>
<option value="february">February</option>
<option value="march">March</option>
<option value="april">April</option>
<option value="may">May</option>
<option value="june">June</option>
<option value="july">July</option>
<option value="august">August</option>
<option value="september">September</option>
<option value="october">October</option>
<option value="november">November</option>
<option value="december">December</option>
</select>
Year:
<input name="dob_year" type="text" maxlength="4" size="10" value="eg: 1964">
</td></tr>
<tr><td>
<p style="text-align: right;">Email Address: </p>
</td><td>
<input name="email" type="text" maxlength="50">
</td></tr>
<tr><td>
<p style="text-align: right;">Gender: </p>
</td><td>
Male: <input type="radio" name="gender" value="male" />
Female: <input type="radio" name="gender" value="female" />
</td></tr>
</table><p>
<center><input type="submit" name="submit" value=" Sign-Up "></center>
</font>
';}
else
{
$accept=true;
if(!isset($_POST["first_name"])){
$accept=false;
$_SESSION["error"] .= "Please fill in your first name.<br />";
}
//.... Other values
if(!$accept){
header("Location: " . $_SERVER["PHP_SELF"]); //Check if the session has the error value filled in and display it on the form.
exit;
}
echo "Form Submitted";
}
?>

Form validation can be done using javascript.
HTML
<input type="submit" onclick="return validate();" />
JAVASCRIPT
<script type="text/javascript">
function validate()
{
if(document.getElementsByName('username') == "")
{
alert("Please Enter username");
return false;
}
...
}
</script>

all your code currently does it verify someone clicked the submit button, it doesnt actually verify they entered valid values. Understand that isset doesnt check that a variable has a value, just that the variable exists, which it will since all form elements will exist in the post array regardless of what, if any value is posted.
2 tips for you:
1) use a foreach loop to evaluate each element of the post array. You can create a seperate array of expected value conditions to check against in the loop. There are plenty of ready to use validation filter scripts out there you can just plug in to check that your expected value is char, int, float etc. PLEASE always validate your user input before inserting into your database or your asking for SQL injection attack.
2) use print_r($_POST) to debug your form submissions if you dont understand what exactly is being submitted....
also I find its easier to put the PHP at the top of the file and leave the html below. If you arent using PHP values to prefill out form values, there is no need to echo your html. This makes it much easier to edit your html... observe the php tags in the start and end of the else statement:
<?php
if(isset($_POST['submit'])) {
echo "Form Submitted";
}
else{ ?>
<form action="" method="post" name="signup">
<table border="1" width="100%">
<tr><td>
<p style="text-align: right;">First Name: </p>
</td><td>
<input name="first_name" type="text" maxlength="25">
</td></tr>
<tr><td>
<p style="text-align: right;">Last Name: </p>
</td><td>
<input name="last_name" type="text" maxlength="25">
</td></tr>
<tr><td>
<p style="text-align: right;">Desired Username: </p>
</td><td>
<input name="username" type="text" maxlength="25">
</td></tr>
<tr><td>
<p style="text-align: right;">Password: </p>
</td><td>
<input name="password" type="password" maxlength="25">
</td></tr>
<tr><td>
<p style="text-align: right;">Confirm Password: </p>
</td><td>
<input name="confpassword" type="password" maxlength="25">
</td></tr>
<tr><td>
<p style="text-align: right;">Date Of Birth: </p>
</td><td>
<select name="dob_day">
<option value="000">Day</option>
<option value="01">01</option>
<option value="02">02</option>
<option value="03">03</option>
<option value="04">04</option>
<option value="05">05</option>
<option value="06">06</option>
<option value="07">07</option>
<option value="08">08</option>
<option value="09">09</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
<option value="13">13</option>
<option value="14">14</option>
<option value="15">15</option>
<option value="16">16</option>
<option value="17">17</option>
<option value="18">18</option>
<option value="19">19</option>
<option value="20">20</option>
<option value="21">21</option>
<option value="22">22</option>
<option value="23">23</option>
<option value="24">24</option>
<option value="25">25</option>
<option value="26">26</option>
<option value="27">27</option>
<option value="28">28</option>
<option value="29">29</option>
<option value="30">30</option>
<option value="31">31</option>
</select>
<select name="dob_month">
<option value="000">Month</option>
<option value="january">January</option>
<option value="february">February</option>
<option value="march">March</option>
<option value="april">April</option>
<option value="may">May</option>
<option value="june">June</option>
<option value="july">July</option>
<option value="august">August</option>
<option value="september">September</option>
<option value="october">October</option>
<option value="november">November</option>
<option value="december">December</option>
</select>
Year:
<input name="dob_year" type="text" maxlength="4" size="10" value="eg: 1964">
</td></tr>
<tr><td>
<p style="text-align: right;">Email Address: </p>
</td><td>
<input name="email" type="text" maxlength="50">
</td></tr>
<tr><td>
<p style="text-align: right;">Gender: </p>
</td><td>
Male: <input type="radio" name="gender" value="male" />
Female: <input type="radio" name="gender" value="female" />
</td></tr>
</table><p>
<center><input type="submit" name="submit" value=" Sign-Up "></center>
</font>
<?php } ?>

<html>
<body>
<form action="<?php $_PHP_SELF ?>" method="GET">
Name: <input type="text" name="name" />
Age: <input type="text" name="age" />
<input type="submit" name="submit" value="submit"/>
</form>
<?php
if (isset($_GET['submit']))
{
$name = $_GET['name'];
$age = $_GET['age'];
echo "Welcome ".$name."<br />" ;
echo "You are ".$age." years old<br/>";
}
else
{
echo "enter the appropriate details";
exit();
}
?>
</body>
</html>

<html>
<body>
if
(isset($_GET['actie']) && $_GET['actie']== "registreren") {
//registreerformulier
echo "<form method='post' action='".$_SERVER['PHP_SELF']."?actie=aanmaken'>
Voornaam <input name='voornaam' type='text' /> <br />
Familienaam <input name='familienaam' type='text' /> <br />
Wachtwoord <input name='wachtwoord' type='password' /> <br />
Wachtwoord-controle <input name='wachtwoordControle' type='password' /> <br />
<input name='submit' type='submit' value='Maak gebruiker aan' />
</form>";
</body>
</html>

Related

Trying to display a div using PHP

Good morning,
I’m trying to display a div containing a form using PHP. I’m not using JavaScript because my teacher has told me to use PHP instead. I have two buttons and I’m using isset to determine which one is clicked. The functions execute and echo the correct identifying text, (“This is form X”), but the actual forms don’t display.
Initially, in CSS, the forms are displayed like so:
.parent .copyarea #formHELP {
display: none;
}
.parent .copyarea #formFEEDBACK {
display: none;
}
In HTML, they are the same. Class parent. Class copyarea. ID formFEEDBACK and formHELP. In PHP, this is the function I’m using:
<?php
echo "<h1> Hello PHP. </h1>";
if(isset($_GET['formHELPbutton'])) {
echo "Hello Form Help.";
echo "<div id='formHELP' style='display: block'>";
}
if(isset($_GET['formFEEDBACKbutton'])) {
echo "Hello Form Feedback.";
echo "<div id='formFEEDBACK' style='display: block'>";
}
?>
And like I mentioned, I"m getting the “Hello Form X”, so the function is working, but my echo div line is off somehow.
Please advise?
Thank you!
Edit: This is the entire content of the PHP echo statement, with the div inside:
if(isset($_GET['formHELPbutton'])) {
echo "Hello Form Help.";
echo '
<div id="formHELP">
<article>
<h1>Help Request Form</h1>
<form name="formHELP" action="http://cdlwebsysdev.esc-atsystems.net//WSD/form-to-email.php" onsubmit="return validateHELPForm()" method="post">
<p>Please take a moment to fill out and submit this help form. <br /></p>
<p>
<label for="FromAddressH">*Enter your email (required).</label>
<input type="text" id="FromAddressH" name="FromAddressH" minlength="5" maxlength="40" size="30"><br /><br />
<label for="telnumberH">Enter your telephone number.</label>
<input type="text" id="telnumberH" name="telnumberH" minlength="10" maxlength="20" size="30"><br /><br />
<label for="firstnameH">*Enter your first name (required).</label>
<input type="text" id="firstnameH" name="firstnameH" minlength="2" maxlength="20" size="20"><br /><br />
<label for="lastnameH">*Enter your last name (required).</label>
<input type="text" id="lastnameH" name="lastnameH" minlength="2" maxlength="30" size="30"><br /><br />
Your Mailing Address:
<br /><br />
<label for="streetH">Enter your street.</label>
<input type="text" id="streetH" name="streetH" minlength="2" maxlength="50" size="50"><br /><br />
<label for="cityH">Enter your city.</label>
<input type="text" id="cityH" name="cityH" minlength="2" maxlength="50" size="50"><br /><br />
<label for="stateH">Enter your state.</label>
<select id="stateH" name="stateH">
<option value="AL">AL</option>
<option value="AK">AK</option>
<option value="AR">AR</option>
<option value="AS">AS</option>
<option value="AZ">AZ</option>
<option value="CA">CA</option>
<option value="CO">CO</option>
<option value="CT">CT</option>
<option value="DC">DC</option>
<option value="DE">DE</option>
<option value="FL">FL</option>
<option value="GA">GA</option>
<option value="GU">GU</option>
<option value="HI">HI</option>
<option value="IA">IA</option>
<option value="ID">ID</option>
<option value="IL">IL</option>
<option value="IN">IN</option>
<option value="KS">KS</option>
<option value="KY">KY</option>
<option value="LA">LA</option>
<option value="MA">MA</option>
<option value="MD">MD</option>
<option value="ME">ME</option>
<option value="MI">MI</option>
<option value="MN">MN</option>
<option value="MO">MO</option>
<option value="MP">MP</option>
<option value="MS">MS</option>
<option value="MT">MT</option>
<option value="NC">NC</option>
<option value="NE">NE</option>
<option value="NH">NH</option>
<option value="NJ">NJ</option>
<option value="NM">NM</option>
<option value="NV">NV</option>
<option value="NY">NY</option>
<option value="ND">ND</option>
<option value="OH">OH</option>
<option value="OK">OK</option>
<option value="OR">OR</option>
<option value="PA">PA</option>
<option value="PR">PR</option>
<option value="RI">RI</option>
<option value="SC">SC</option>
<option value="SD">SD</option>
<option value="TN">TN</option>
<option value="TX">TX</option>
<option value="UT">UT</option>
<option value="UM">UM</option>
<option value="VT">VT</option>
<option value="VA">VA</option>
<option value="VI">VI</option>
<option value="WA">WA</option>
<option value="WI">WI</option>
<option value="WV">WV</option>
<option value="WY">WY</option>
</select> <br /> <br />
<label for="postcodeH">Enter your postal code.</label>
Postal Code:
<input type="text" id="postcodeH" name="postcodeH" minlength="2" maxlength="10" size="10"><br /><br />
<label for="countryH">Enter your country code.</label>
Country Code:
<input type="text" id="countryH" name="countryH" minlength="2" maxlength="3" size="3"><br /><br />
<label for="helpH">*Please tell me what you require help with (required):</label>
<textarea name="helpH" id="helpH" rows="10" cols="80"></textarea> <br /> <br />
<br /> <br />
<div class="form-group options">
How would you like to be contacted? (Both boxes can be checked) :
<label for="contactphoneH">Phone</label>
<input type="checkbox" id="contactphoneH" name="contactphoneH">
<label for="contactemailH"> Email</label>
<input type="checkbox" id="contactemailH" name="contactemailH">
<br>
</div>
<br /> <br />
<input type="hidden" name="ToAddress" value="markholley4#gmail.com" /> <!-- TODO Change to todd.wolfe#esc.edu when final version published. -->
<input type="hidden" name="CCAddress" value="markholley4#gmail.com" />
<input type="hidden" name="Subject" value="WSD: Module 3 Assignment - Web Form for Mark Holley" />
<button type="submit" value="SubmitH">Submit</button>
<button type="reset" value="ResetH">Reset</button>
<br /> <br />
</form>
</article>
</div>';
Your Div elements needs a opening div tag( like you already have) but you are missing the closing one. Also if a div has no content, it won't have any width or height, so you won't see anything, you can test the code below, just added some color to the background so you can see the div.
`
if(isset($_GET['formHELPbutton'])) {
echo 'Hello Form Help.';
echo '<div id="formHELP" style="display:block; width:500px; height:500px; background-color:red">test form help </div>';
}
if(isset($_GET['formFEEDBACKbutton'])) {
echo 'Hello Form Feedback.';
echo '<div id="formFEEDBACK" style="display:block; width:500px; height:500px; background-color:red"> test form feedback </div>';
}
`
<div id="formHELP" style="display:block; width:500px; height:500px; background-color:red">test form help </div>

How to Block date & time if others user already chose that date & time

Right now i am developing a booking vehicle system using html,php,sql. I dont know how to describe my question but let me give a situation example.
user 1: want to book vehicle on 11 may 2017 # 0930 and the admin already approved this user form.
user 2: want to book vehicle at the same date & time as user 1 and here is the problem. How to block others user from proceed the booking if that date & time already have a user?
Hope you guys can help me, thank you!
this is my coding for date & time. it is in form for user to book and i want to make it once they click submit if that date & time already booked will pop up msg like 'already booked'.
<link rel="stylesheet" type="text/css" href="tcal.css" />
<script type="text/javascript" src="tcal.js"></script>
<script>
function myFunction() {
alert("Permohonan anda akan diproses. Sila jangan tutup paparan sehingga selesai.");
}
</script>
<form action="processform.php" method="post" enctype="multipart/form-data">
<table width="100%" align="center" cellpadding="2" cellspacing="4" bgcolor="#FFFFFF">
<br>
<br>
<tr bgcolor="#e2e8ef">
<td colspan="3" class="font12bold"> BUTIRAN PERJALANAN</td>
</tr>
<tr class="font12">
<td> Date to Depart <b class="icon_required" style="color:#FF0000">*</b></td>
<td align="center">:</td>
<td>
<input type="text" name="departDate" class="tcal" value="" />
<font class="font12gray">[dd-mm-yyyy]</font></td>
</tr>
<tr class="font12">
<td> Time to Depart <b class="icon_required" style="color:#FF0000">*</b></td>
<td align="center">:</td>
<td>
<select name="timeDepart">
<option value="-">-Sila Pilih-</option>
<option value="01:00" >1:00</option>
<option value="01:30" >1:30</option>
<option value="02:00" >2:00</option>
<option value="02:30" >2:30</option>
<option value="03:00" >3:00</option>
<option value="03:30" >3:30</option>
<option value="04:00" >4:00</option>
<option value="04:30" >4:30</option>
<option value="05:00" >5:00</option>
<option value="05:30" >5:30</option>
<option value="06:00" >6:00</option>
<option value="06:30" >6:30</option>
<option value="07:00" >7:00</option>
<option value="07:30" >7:30</option>
<option value="08:00" >8:00</option>
<option value="08:30" >8:30</option>
<option value="09:00" >9:00</option>
<option value="09:30" >9:30</option>
<option value="10:00" >10:00</option>
<option value="10:30" >10:30</option>
<option value="11:00" >11:00</option>
<option value="11:30" >11:30</option>
<option value="12:00" >12:00</option>
<option value="12:30" >12:30</option>
</select>
<select name="waktuDepart">
<option value="" > - </option>
<option value="Pagi" > Pagi</option>
<option value="Tengahari" >Tengahari</option>
<option value="Petang" >Petang</option>
<option value="Malam" >Malam</option>
</select>
</td>
</tr>
<tr class="font12">
<td> Date to Return <b class="icon_required" style="color:#FF0000">*</b></td>
<td align="center">:</td>
<td><input type="text" name="returnDate" class="tcal" value="" />
<font class="font12gray">[dd-mm-yyyy]</font></td>
</tr>
<tr class="font12">
<td> Time to Return <b class="icon_required" style="color:#FF0000">*</b></td>
<td align="center">:</td>
<td><select name="returnTime">
<option value="-">-Sila Pilih-</option>
<option value="01:00" >1:00</option>
<option value="01:30" >1:30</option>
<option value="02:00" >2:00</option>
<option value="02:30" >2:30</option>
<option value="03:00" >3:00</option>
<option value="03:30" >3:30</option>
<option value="04:00" >4:00</option>
<option value="04:30" >4:30</option>
<option value="05:00" >5:00</option>
<option value="05:30" >5:30</option>
<option value="06:00" >6:00</option>
<option value="06:30" >6:30</option>
<option value="07:00" >7:00</option>
<option value="07:30" >7:30</option>
<option value="08:00" >8:00</option>
<option value="08:30" >8:30</option>
<option value="09:00" >9:00</option>
<option value="09:30" >9:30</option>
<option value="10:00" >10:00</option>
<option value="10:30" >10:30</option>
<option value="11:00" >11:00</option>
<option value="11:30" >11:30</option>
<option value="12:00" >12:00</option>
<option value="12:30" >12:30</option>
</select>
<select name="waktuReturn">
<option value="" >- </option>
<option value="Pagi" >Pagi</option>
<option value="Tengahari" >Tengahari</option>
<option value="Petang" >Petang</option>
<option value="Malam" >Malam</option>
</select>
</td>
</tr>
</table>
<center><input type="submit" name="submit" value="Hantar" style="cursor:pointer" onclick="myFunction()"> [ kembali ]<br></center>
</td></tr></table>
</form>

How should I make the php script for a contact form from multiple select dependencies

Before anyone yells Repost, there aren't many cases like mine that I've seen.I have a contact form that has the possibility to have a main Select option, a sub-Select option and then a sub-Select option of that one. Overall, There are 27 options to choose from and I think I could make the php give me all 27 of those and then do a "yes they selected this one but not that one" type of report, but I digress.How do I have the php script for my contact form send only what is selected from a possible three-tiered select menu? EDIT: I'm totally willing to use something other than PHP to help facilitate this, I just need help with the PHP script as well.Edit: To be clear, I'm try to create and populate a php script, not valdiate the form/check that all required sections are filled out.Code
<form action="sending.php" method="POST" enctype="multipart/form-data">
<input type="hidden" name="action" value="submit">
Name:<br>
<input name="name" type="text" value="" size="30"/><br>
Email:<br>
<input name="email" type="text" value="" size="30"/><br>
Service:<br>
<select name="service" id="service" class="service">
<option>Select a Service</option>
<option value="screen" data-target="devices" id="screen">Screen Replacement</option>
<option value="comp" data-target="comp" id="comp">Computer Work</option>
<option value="misc" data-target="misc" id="misc">Miscellaneous</option>
</select>
<div style="display:none" id="service-devices">
<select name="devices" id="devices" class="devices">
<option>Select a Device</option>
<option value="iphone" data-target="iphones" id="iphone">iPhone</option>
<option value="ipad" data-target="ipads" id="ipad">iPad</option>
<!--<option value="watch" id="watch">Apple Watch</option> -->
<option value="android" id="android">Android</option>
</select>
<div style="display:none" id="devices-iphones">
<select name="iphone" id="iphone" class="iphone">
<!--<option value="iphone6s" id="iphone6s">iPhone 6S</option> -->
<!--<option value="iphone6splus" id="iphone6splus">iPhone 6S Plus</option>-->
<option>Select a Model</option>
<option value="iphone6" id="iphone6">iPhone 6</option>
<option value="iphone6plus" id="iphone6plus">iPhone 6 Plus</option>
<option value="iphone5s" id="iphone5s">iPhone 5S</option>
<option value="iphone5c" id="iphone5c">iPhone 5C</option>
<option value="iphone5" id="iphone5">iPhone 5</option>
<option value="iphone4s" id="iphone4s">iPhone 4S</option>
<option value="iphone4" id="iphone4">iPhone 4</option>
</select>
</div>
<div style="display:none" id="devices-ipads">
<select name="ipad" id="ipad" class="ipad">
<option>Select a Model</option>
<option value="ipadmini3" id="ipadmini3">iPad Mini 3</option>
<option value="ipadmini2" id="ipadmini2">iPad Mini 2</option>
<option value="ipadair" id="ipadair">iPad Air</option>
<option value="ipad4" id="ipad4">iPad 4</option>
<option value="ipad3" id="ipad3">iPad 3</option>
<option value="ipadmini" id="ipadmini">iPad Mini</option>
<option value="ipad2" id="ipad2">iPad 2</option>
</select>
</div>
</div>
<div style="display:none" id="service-comp">
<select name="compwork" id="compwork" class="compwork">
<option value="desktopcreation" id="desktopcreation">Desktop Creation</option>
<option value="desktopbuild" id="desktopbuild">Desktop Build</option>
<option value="hardwareupgrades" id="hardwareupgrades">Hardware Upgrades</option>
<option value="datarecovery" id="datarecovery">Data Recovery/Transfer</option>
<option value="spywareremoval" id="spywareremoval">Spyware/Adware Removal</option>
<option value="virusremoval" id="virusremoval">Virus Removal</option>
</select>
</div>
<div style="display:none" id="service-misc">
<select name="miscellaneous" id="miscellaneous" class="miscellaneous">
<option value="networksecurity" id="networksecurity">Network Security</option>
<!--<option value="webdesign" id="webdesign">Website Design</option>-->
</select>
</div><br>
Message:<br>
<textarea name="message" rows="7" cols="30"></textarea><br>
<input type="submit" value="Submit Request"/>
</form>
I assume that you do have jquery to display the relevant select boxes upon selection of devices etc... I have made a few changes in your html form, like adding id="form" in your form tag. Also added value="" for options like "Please select Service".. Here is the code. Hope this helps.. Refer to this as well..
Jquery form submit to check empty fields
<form id="form" action="sending.php" method="POST" enctype="multipart/form-data">
<input type="hidden" name="action" value="submit">
Name:<br>
<input name="name" type="text" value="" size="30"/><br>
Email:<br>
<input name="email" type="text" value="" size="30"/><br>
Service:<br>
<select name="service" id="service" class="service">
<option value="">Select a Service</option>
<option value="screen" data-target="devices" id="screen">Screen Replacement</option>
<option value="comp" data-target="comp" id="comp">Computer Work</option>
<option value="misc" data-target="misc" id="misc">Miscellaneous</option>
</select>
<div style="display:none" id="service-devices">
<select name="devices" id="devices" class="devices">
<option value="">Select a Device</option>
<option value="iphone" data-target="iphones" id="iphone">iPhone</option>
<option value="ipad" data-target="ipads" id="ipad">iPad</option>
<!--<option value="watch" id="watch">Apple Watch</option> -->
<option value="android" id="android">Android</option>
</select>
<div style="display:none" id="devices-iphones">
<select name="iphone" id="iphone" class="iphone">
<!--<option value="iphone6s" id="iphone6s">iPhone 6S</option> -->
<!--<option value="iphone6splus" id="iphone6splus">iPhone 6S Plus</option>-->
<option value="">Select a Model</option>
<option value="iphone6" id="iphone6">iPhone 6</option>
<option value="iphone6plus" id="iphone6plus">iPhone 6 Plus</option>
<option value="iphone5s" id="iphone5s">iPhone 5S</option>
<option value="iphone5c" id="iphone5c">iPhone 5C</option>
<option value="iphone5" id="iphone5">iPhone 5</option>
<option value="iphone4s" id="iphone4s">iPhone 4S</option>
<option value="iphone4" id="iphone4">iPhone 4</option>
</select>
</div>
<div style="display:none" id="devices-ipads">
<select name="ipad" id="ipad" class="ipad">
<option value="">Select a Model</option>
<option value="ipadmini3" id="ipadmini3">iPad Mini 3</option>
<option value="ipadmini2" id="ipadmini2">iPad Mini 2</option>
<option value="ipadair" id="ipadair">iPad Air</option>
<option value="ipad4" id="ipad4">iPad 4</option>
<option value="ipad3" id="ipad3">iPad 3</option>
<option value="ipadmini" id="ipadmini">iPad Mini</option>
<option value="ipad2" id="ipad2">iPad 2</option>
</select>
</div>
</div>
<div style="display:none" id="service-comp">
<select name="compwork" id="compwork" class="compwork">
<option value="desktopcreation" id="desktopcreation">Desktop Creation</option>
<option value="desktopbuild" id="desktopbuild">Desktop Build</option>
<option value="hardwareupgrades" id="hardwareupgrades">Hardware Upgrades</option>
<option value="datarecovery" id="datarecovery">Data Recovery/Transfer</option>
<option value="spywareremoval" id="spywareremoval">Spyware/Adware Removal</option>
<option value="virusremoval" id="virusremoval">Virus Removal</option>
</select>
</div>
<div style="display:none" id="service-misc">
<select name="miscellaneous" id="miscellaneous" class="miscellaneous">
<option value="networksecurity" id="networksecurity">Network Security</option>
<!--<option value="webdesign" id="webdesign">Website Design</option>-->
</select>
</div><br>
Message:<br>
<textarea name="message" rows="7" cols="30"></textarea><br>
<input type="submit" value="Submit Request"/>
<script src="js/jquery-1.10.2.min.js"></script>
<script>
$(document).ready(function() {
$('select').change(function(){
var boxid = $(this).children('option:selected').attr('data-target');
alert(boxid);
if(boxid == "devices") {
var divId = "service-" + boxid;
}
document.getElementById(divId).style.display = "block";
});
$("form").submit(function(){
// $(':input[value=""]').attr('disabled', true);
$("input[type='text'],select,input[type='password'],textarea",this).each(function() {
if($(this).val().trim() == "") {
$(this).attr('disabled', true);
}
})
});
});
</script>

Getting Option Value with PHP

Below is a snippet of the code I have created on a form page. The form inputs display the correct variables for $adjustedGrossIncome, $personalExemptions and the calculation for Tax Due Before Refundable Credits, but when I try to echo $birthYear the php dies. Any hints what I'm doing wrong?
<?php
$filingStatus = $_Post['filingStatus'];
$birthYear = $_Post['birthYear'];
$dependents = $_Post['dependents'];
$children = $_POST['children'];
$exemptions = $_POST['exemptions'];
$income = $_POST['income'];
$investments = $_POST['investments'];
$retirement = $_POST['retirement'];
$property = $_POST['property'];
$adjustedGrossIncome = $income + $investments + $retirement;
$personalExemptions = ($exemptions * 3950);
?>
<form id="form1" name="form1" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<fieldset style="width:500px;">
<legend>Filing Status</legend>
<p>
<label>
<input type="radio" name="filingStatus" value="married" id="filingStatus" />
Married filing jointly</label>
<br />
<label>
<input type="radio" name="filingStatus" value="single" id="filingStatus" />
Single or Head of Household</label>
</p>
</fieldset>
<p>
<label>Birth Year
<select name="birthYear" id="birthYear">
<option>Select Year</option>
<option value="1923">1923</option>
<option value="1924">1924</option>
<option value="1925">1925</option>
<option value="1926">1926</option>
<option value="1927">1927</option>
<option value="1928">1928</option>
<option value="1929">1929</option>
<option value="1930">1930</option>
<option value="1931">1931</option>
<option value="1932">1932</option>
<option value="1933">1933</option>
<option value="1934">1934</option>
<option value="1935">1935</option>
<option value="1936">1936</option>
<option value="1937">1937</option>
<option value="1938">1938</option>
<option value="1939">1939</option>
<option value="1940">1940</option>
<option value="1941">1941</option>
<option value="1942">1942</option>
<option value="1943">1943</option>
<option value="1944">1944</option>
<option value="1945">1945</option>
<option value="1946">1946</option>
<option value="1947">1947</option>
<option value="1948">1948</option>
<option value="1949">1949</option>
<option value="1950">1950</option>
<option value="1951">1951</option>
<option value="1952">1952</option>
<option value="1953">1953</option>
<option value="1954">1954</option>
<option value="1955">1955</option>
<option value="1956">1956</option>
<option value="1957">1957</option>
<option value="1958">1958</option>
<option value="1959">1959</option>
<option value="1960">1960</option>
<option value="1961">1961</option>
<option value="1962">1962</option>
<option value="1963">1963</option>
<option value="1964">1964</option>
<option value="1965">1965</option>
<option value="1966">1966</option>
<option value="1967">1967</option>
<option value="1968">1968</option>
<option value="1969">1969</option>
<option value="1970">1970</option>
<option value="1971">1971</option>
<option value="1972">1972</option>
<option value="1973">1973</option>
<option value="1974">1974</option>
<option value="1975">1975</option>
<option value="1976">1976</option>
<option value="1977">1977</option>
<option value="1978">1978</option>
<option value="1979">1979</option>
<option value="1980">1980</option>
<option value="1981">1981</option>
<option value="1982">1982</option>
<option value="1983">1983</option>
<option value="1984">1984</option>
<option value="1985">1985</option>
<option value="1986">1986</option>
<option value="1987">1987</option>
<option value="1988">1988</option>
<option value="1989">1989</option>
<option value="1990">1990</option>
<option value="1991">1991</option>
<option value="1992">1992</option>
</select>
</label>
</p>
<p>
<label>Number of Dependents (not including taxpayer and spouse if applicable
<input type="text" name="dependents" id="dependents" />
</label>
</p>
<p>
<label>Number of Children under 18
<input type="text" name="children" id="children" />
</label>
</p>
<p>
<label>Total number of exemptions
<input type="text" name="exemptions" id="exemptions" />
</label>
</p>
<p>
<label>Total Wages/Salary
<input type="text" name="income" id="income" />
</label>
</p>
<p>
<label>Investment income (interest, dividends, capital gains)
<input type="text" name="investments" id="investments" />
</label>
</p>
<p>
<label>Retirement income (pension, IRA, 401(k), etc.)
<input type="text" name="retirement" id="retirement" />
</label>
</p>
<p>
<label>Annual property taxes paid on primary residence and/or annual rent
<input type="text" name="property" id="property" />
</label>
</p>
<p>
<input type="submit" name="submit" id="submit" value="Calculate Net Tax Liability for 2013" />
<input type="reset" name="reset" id="reset" value="Reset Form" onClick="window.location.reload()" />
</p>
</form>
<p>Adjusted Gross Income: $<?php echo($adjustedGrossIncome); ?></p>
<p>Personal Exemptions: $<?php echo($personalExemptions); ?></p>
<p>Tax Due Before Refundable Credits: $<?php echo(($adjustedGrossIncome - $personalExemptions) * .0425); ?></p>
<p><?php echo($birthYear); ?></p>
Change all $_Post to uppercase $_POST
This is known as a superglobal and must be in uppercase.
More on superglobals can be found on the PHP.net Web site
http://php.net/manual/en/language.variables.superglobals.php

PHP form to email

I have created a form on our website for an online submission of claims for our work. I have two pages associated with the form. I have a back end .php page with a thank you for submission and the code to POST an e-mail to our business address. When the form is filled out, and then submitted, we are not recieving an e-mail. I am pretty new to coding and this is my first attempt at creating a form. I thought I had the necessary code and .php to do this. I would really appreciate any input on how to make this form come through in an e-mail. My form page appears as such:
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<!-- InstanceBegin template="Templates/main_page.dwt" codeOutsideHTMLIsLocked="false" -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<!-- InstanceBeginEditable name="doctitle" -->
<title>Assignment Submission</title>
<!--[if lte IE 9]>
<style type="text/css" title="ie-style-css">
/* lte IE 9 style*/
</style>
<![endif]-->
<!-- InstanceEndEditable -->
<link href="stylesheets/reset.css" rel="stylesheet" type="text/css" />
<link href="stylesheets/index.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="scripts/browser-compatibility.js"></script>
<!-- InstanceBeginEditable name="head" -->
<!-- InstanceEndEditable -->
<script type="text/javascript" src="http://cdn.wibiya.com/Toolbars/dir_1424/Toolbar_1424727/Loader_1424727.js"></script>
</head>
<body>
<noscript>
Web Toolbar by Wibiya
</noscript>
<div class="main_wrapper cf">
<div class="header cf">
<div class="logo_holder cf"></div>
<div class="nav_holder cf">
<ul class="hmenubar cf">
<li>Home </li>
<li>About </li>
<li>Services </li>
<li>coverage </li>
<li>submit an assignment </li>
<li>Resources </li>
<li>Contact </li>
<script type="text/javascript" src="scripts/menu_selection.js"></script>
</ul>
</div>
</div>
<div class="content cf"> <!-- InstanceBeginEditable name="ContentRegion" -->
<div class="column_1">
<h2 class="about">Assignment Submission Form</h2>
<h2 class="service_text"><font color="#FF0000">PLEASE BE AWARE WE ARE EXPERIENCING DIFFICULTIES WITH OUR ONLINE SUBMISSION FORM. PLEASE CONTACT US TO PROVIDE US WITH AN ASSIGNMENT AT THIS TIME. (xxx) xxx-xxxx. Thank you.</font><br />
Please complete as many fields as possible and click submit at the bottom of the page. We will contact you with a confirmation. If you do not hear from us within 2 hours of submission, please contact us. </h2>
<form id="new_assignment" name="Assignment Form" method="post" action="result.php" class="assign_form">
<hr />
<h1 class="revtitle" style="color: rgb(157, 72, 61); text-align: left;">Client Information</h1>
<hr />
<p class="paragraph2">
<label>Company Name:</label>
<input name="company" type="text" required="required" form="new_assignment" tabindex="1" style="width:225px" />
<br/>
<label>Adjuster:</label>
<input name="adj" type="text" required="required" form="new_assignment" tabindex="2" style="width:200px" />
<label>E-mail:</label>
<input name="email" type="email" required="required" form="new_assignment" tabindex="3" style="width:250px" />
<br/>
<label>Phone Number:</label>
<input name="adj_phone_number" type="tel" required="required" form="new_assignment" tabindex="4" style="width:100px" />
<label>Extension:</label>
<input name="ext" type="text" form="new_assignment" tabindex="5" style="width:40px" />
<label>Fax Number:</label>
<input name="fax" type="tel" form="new_assignment" tabindex="6" style="width:100px" />
</p>
<hr />
<div class="claim_info">
<h1 class="revtitle" style="color: rgb(157, 72, 61); text-align: left;">Claim Information</h1>
<hr />
<p class="paragraph2">
<label>Assignment Type:</label>
<select name="assign_type" form="new_assignment" tabindex="7" title="Assignment Type">
<option value="auto" selected="selected">Automobile</option>
<option value="rec">Recreational</option>
<option value="heavy">Heavy Equipment</option>
<option value="property">Minor Property</option>
<option value="audit">Estimate Audit</option>
<option value="scene_invest">Scene Investigation</option>
<option value="arb">Arbitration</option>
<option value="DRP">DRP Quality Control Inspection</option>
<option value="photos">Photos Only</option>
</select>
<label>Type of Loss:</label>
<select name="loss_type" form="new_assignment" tabindex="8" title="Loss Type">
<option value="coll">Collision</option>
<option value="comp">Comprehensive</option>
<option value="other">Other</option>
</select>
<br/>
<label>Claim #:</label>
<input name="claim_#" type="text" required="required" form="new_assignment" tabindex="9" style="width:225px" />
<label>Policy #:</label>
<input name="policy_#" type="text" form="new_assignment" tabindex="10" style="width:150px" />
<br/>
<label>Deductible: </label>
<input name="deductible" type="text" form="new_assignment" tabindex="11" style="width:100px" />
<label>Date of Loss: </label>
<input name="dol" type="date" form="new_assignment" tabindex="12" style="width:150px" />
<br />
</p>
<div class="insd_info">
<label>Insured:</label>
<input name="insured" type="text" required="required" form="new_assignment" tabindex="13" style="width:200px" />
<br/>
<label>Address:</label>
<input name="insd_address" type="text" form="new_assignment" tabindex="14" style="width:275px" />
<br/>
<label>City:</label>
<input name="insd_city" type="text" form="new_assignment" tabindex="15" style="width:120px" />
<label>State:</label>
<select name="insd_state" form="new_assignment" tabindex="16" title="Insured State">
<option value="AL">AL</option>
<option value="AK">AK</option>
<option value="AZ">AZ</option>
<option value="AR">AR</option>
<option value="CA">CA</option>
<option value="CO">CO</option>
<option value="CT">CT</option>
<option value="DE">DE</option>
<option value="FL">FL</option>
<option value="GA">GA</option>
<option value="HI">HI</option>
<option value="ID">ID</option>
<option value="IL">IL</option>
<option value="IN">IN</option>
<option value="IA">IA</option>
<option value="KS">KS</option>
<option value="KY">KY</option>
<option value="LA">LA</option>
<option value="ME">ME</option>
<option value="MD">MD</option>
<option value="MA">MA</option>
<option value="MI" selected="selected">MI</option>
<option value="MN">MN</option>
<option value="MS">MS</option>
<option value="MO">MO</option>
<option value="MT">MT</option>
<option value="NE">NE</option>
<option value="NV">NV</option>
<option value="NH">NH</option>
<option value="NJ">NJ</option>
<option value="NM">NM</option>
<option value="NY">NY</option>
<option value="NC">NC</option>
<option value="ND">ND</option>
<option value="OH">OH</option>
<option value="OK">OK</option>
<option value="OR">OR</option>
<option value="PA">PA</option>
<option value="RI">RI</option>
<option value="SC">SC</option>
<option value="SD">SD</option>
<option value="TN">TN</option>
<option value="TX">TX</option>
<option value="UT">UT</option>
<option value="VT">VT</option>
<option value="VA">VA</option>
<option value="WA">WA</option>
<option value="WV">WV</option>
<option value="WI">WI</option>
<option value="WY">WY</option>
</select>
<br/>
<label>Zip Code:</label>
<input name="insd_ZIP" type="text" form="new_assignment" tabindex="17" style="width:130px" />
<br/>
<label>Home Phone:</label>
<input name="insd_home" type="tel" form="new_assignment" tabindex="18" style="width:140px" />
<br/>
<label>Work Phone:</label>
<input name="insd_work" type="tel" form="new_assignment" tabindex="19" style="width:140px" />
<br/>
<label>Mobile Phone:</label>
<input name="insd_mobile" type="tel" form="new_assignment" tabindex="20" style="width:140px" />
<br/>
<label>Other Phone:</label>
<input name="insd_other" type="tel" form="new_assignment" tabindex="21" style="width:140px " />
<br/>
</div>
<div class="claimant_info ">
<label>Claimant:</label>
<input name="claimant " type="text " required="required " form="new_assignment " tabindex="22" style="width:200px " />
<br/>
<label>Address:</label>
<input name="claimant_address " type="text " form="new_assignment " tabindex="23" style="width:275px " />
<br/>
<label>City:</label>
<input name="claimant_city " type="text " form="new_assignment " tabindex="24" style="width:120px " />
<label>State:</label>
<select name="claimant_state " form="new_assignment " tabindex="25" title="Claimant State ">
<option value="AL ">AL</option>
<option value="AK ">AK</option>
<option value="AZ ">AZ</option>
<option value="AR ">AR</option>
<option value="CA ">CA</option>
<option value="CO ">CO</option>
<option value="CT ">CT</option>
<option value="DE ">DE</option>
<option value="FL ">FL</option>
<option value="GA ">GA</option>
<option value="HI ">HI</option>
<option value="ID ">ID</option>
<option value="IL ">IL</option>
<option value="IN ">IN</option>
<option value="IA ">IA</option>
<option value="KS ">KS</option>
<option value="KY ">KY</option>
<option value="LA ">LA</option>
<option value="ME ">ME</option>
<option value="MD ">MD</option>
<option value="MA ">MA</option>
<option value="MI " selected="selected">MI</option>
<option value="MN ">MN</option>
<option value="MS ">MS</option>
<option value="MO ">MO</option>
<option value="MT ">MT</option>
<option value="NE ">NE</option>
<option value="NV ">NV</option>
<option value="NH ">NH</option>
<option value="NJ ">NJ</option>
<option value="NM ">NM</option>
<option value="NY ">NY</option>
<option value="NC ">NC</option>
<option value="ND ">ND</option>
<option value="OH ">OH</option>
<option value="OK ">OK</option>
<option value="OR ">OR</option>
<option value="PA ">PA</option>
<option value="RI ">RI</option>
<option value="SC ">SC</option>
<option value="SD ">SD</option>
<option value="TN ">TN</option>
<option value="TX ">TX</option>
<option value="UT ">UT</option>
<option value="VT ">VT</option>
<option value="VA ">VA</option>
<option value="WA ">WA</option>
<option value="WV ">WV</option>
<option value="WI ">WI</option>
<option value="WY ">WY</option>
</select>
<br/>
<label>Zip Code:</label>
<input name="claimant_ZIP " type="text " form="new_assignment " tabindex="26" style="width:130px " />
<br/>
<label>Home Phone:</label>
<input name="claimant_home " type="tel " form="new_assignment " tabindex="27" style="width:140px " />
<br/>
<label>Work Phone:</label>
<input name="claimant_work " type="tel " form="new_assignment " tabindex="28" style="width:140px " />
<br/>
<label>Mobile Phone:</label>
<input name="claimant_mobile " type="tel " form="new_assignment " tabindex="29" style="width:140px " />
<br/>
<label>Other Phone:</label>
<input name="claimant_other" type="tel" form="new_assignment" tabindex="30" style="width:140px" />
</div>
</div>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br />
<hr />
<h1 class="revtitle" style="color: rgb(157, 72, 61); text-align: left;">Vehicle Information</h1>
<hr />
<p class="paragraph2">
<label>Owner of vehicle to be inspected: </label>
<select name="owner_type" form="new_assingments" tabindex="31" style="width:160px">
<option value="insd" selected="selected">Insured</option>
<option value="clmt">Claimant</option>
</select>
<br />
<label>Year: </label>
<input name="veh_year" type="text" for="new_assignment" tabindex="32" style="width:80px" />
<label>Make: </label>
<input name="veh_make" type="text" form="new_assignment" tabindex="33" style="width:100px" />
<label>Model: </label>
<input name="veh_model" type="text" form "new_assigment" tabindex="34" style="width:100px" />
<label>Color: </label>
<input name="veh_color" type="text" form="new_assignment" tabindex="35" style="width:100px" />
<br/>
<label>VIN: </label>
<input name="veh_VIN" type="text" form="new_assignment" tabindex="36" style="width:200px" />
<label>License Plate: </label>
<input name="lic_plate" type="text" form="new_assignment" tabindex="37" style="width:100px" />
<label>State:</label>
<select name="license_state " form="new_assignment " tabindex="38" title="License State ">
<option value="AL ">AL</option>
<option value="AK ">AK</option>
<option value="AZ ">AZ</option>
<option value="AR ">AR</option>
<option value="CA ">CA</option>
<option value="CO ">CO</option>
<option value="CT ">CT</option>
<option value="DE ">DE</option>
<option value="FL ">FL</option>
<option value="GA ">GA</option>
<option value="HI ">HI</option>
<option value="ID ">ID</option>
<option value="IL ">IL</option>
<option value="IN ">IN</option>
<option value="IA ">IA</option>
<option value="KS ">KS</option>
<option value="KY ">KY</option>
<option value="LA ">LA</option>
<option value="ME ">ME</option>
<option value="MD ">MD</option>
<option value="MA ">MA</option>
<option value="MI ">MI</option>
<option value="MN ">MN</option>
<option value="MS ">MS</option>
<option value="MO ">MO</option>
<option value="MT ">MT</option>
<option value="NE ">NE</option>
<option value="NV ">NV</option>
<option value="NH ">NH</option>
<option value="NJ ">NJ</option>
<option value="NM ">NM</option>
<option value="NY ">NY</option>
<option value="NC ">NC</option>
<option value="ND ">ND</option>
<option value="OH ">OH</option>
<option value="OK ">OK</option>
<option value="OR ">OR</option>
<option value="PA ">PA</option>
<option value="RI ">RI</option>
<option value="SC ">SC</option>
<option value="SD ">SD</option>
<option value="TN ">TN</option>
<option value="TX ">TX</option>
<option value="UT ">UT</option>
<option value="VT ">VT</option>
<option value="VA ">VA</option>
<option value="WA ">WA</option>
<option value="WV ">WV</option>
<option value="WI ">WI</option>
<option value="WY ">WY</option>
</select>
<br/>
<label>Description of Loss: </label>
<textarea name="desc_of_loss" id="desc_of_loss" form="new_assignment" tabindex="39" style="width:500px"></textarea>
<br />
<label>Description of Damage: </label>
<textarea name="desc_of_dmg" id="desc_of_dmg" form="new_assignment" tabindex="40" style="width:500px"></textarea>
<br />
</p>
<hr />
<h1 class="revtitle" style="color: rgb(157, 72, 61); text-align: left;">Vehicle Location</h1>
<hr />
<p class="paragraph2">
<label>Location Name: </label>
<input name="location_name" type="text" form="new_assignment" style="width:250px" tabindex="41" value="With Owner" />
<br />
<label>Address: </label>
<input name="location_address" type="text" form="new_assignment" style="width:300px" tabindex="42" value="(same as owner above)" />
<br />
<label>City:</label>
<input name="insd_city" type="text" form="new_assignment" tabindex="43" style="width:120px" />
<label>State:</label>
<select name="insd_state" form="new_assignment" tabindex="44" title="Insured State">
<option value="AL">AL</option>
<option value="AK">AK</option>
<option value="AZ">AZ</option>
<option value="AR">AR</option>
<option value="CA">CA</option>
<option value="CO">CO</option>
<option value="CT">CT</option>
<option value="DE">DE</option>
<option value="FL">FL</option>
<option value="GA">GA</option>
<option value="HI">HI</option>
<option value="ID">ID</option>
<option value="IL">IL</option>
<option value="IN">IN</option>
<option value="IA">IA</option>
<option value="KS">KS</option>
<option value="KY">KY</option>
<option value="LA">LA</option>
<option value="ME">ME</option>
<option value="MD">MD</option>
<option value="MA">MA</option>
<option value="MI" selected="selected">MI</option>
<option value="MN">MN</option>
<option value="MS">MS</option>
<option value="MO">MO</option>
<option value="MT">MT</option>
<option value="NE">NE</option>
<option value="NV">NV</option>
<option value="NH">NH</option>
<option value="NJ">NJ</option>
<option value="NM">NM</option>
<option value="NY">NY</option>
<option value="NC">NC</option>
<option value="ND">ND</option>
<option value="OH">OH</option>
<option value="OK">OK</option>
<option value="OR">OR</option>
<option value="PA">PA</option>
<option value="RI">RI</option>
<option value="SC">SC</option>
<option value="SD">SD</option>
<option value="TN">TN</option>
<option value="TX">TX</option>
<option value="UT">UT</option>
<option value="VT">VT</option>
<option value="VA">VA</option>
<option value="WA">WA</option>
<option value="WV">WV</option>
<option value="WI">WI</option>
<option value="WY">WY</option>
</select>
<br/>
<label>Zip Code: </label>
<input name="insd_ZIP" type="text" form="new_assignment" tabindex="45" style="width:130px" />
<label>Contact: </label>
<input name="location_contact" type="text" form="new_assignment" tabindex="46" style="width:150px" />
<br/>
</p>
<hr />
<input type="reset" class="button" />
<input name="submit" type="submit" class="button" form="new_assignment" formaction="/result.php" formenctype="multipart/form-data" formmethod="POST" value="Submit" />
<p></p>
<div class="important" id="important">
<label>Trojan</label>
<input type="text" name="trojan" id="trojan" />
</div>
</form>
</div>
<!-- InstanceEndEditable --> </div>
<div class="footer cf">
<p class="rights">LMC Insurance Services, INC - 2013 All Rights Reserved | <a class="privacy" href="/privacy_policy.html" target="_self">Privacy Policy</a> </p>
</div>
</div>
</body>
<!-- InstanceEnd -->
</html>
And my .php results page appears as:
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>Submission</title>
</head>
<body>
<?PHP
//checks if bot
if($_POST['trojan']!='');
die("Changed field");
$adj = $_POST['adj'];
$company = $_POST['company'];
$email = $_POST['email'];
$adj_phone = $_POST['adj_phone_number'];
$ext = $_POST['ext'];
//Sending Email to form owner
$header = "From: $email\n"
. "Relpy-To: $email\n";
$subject = "New Assignment from Website";
$email_to = "office#example.com";
$message = "We recieved a new assignment from $adj \n"
. "They can be reached at $adj_phone $ext \n"
. "Their e-mail address is $email \n";
mail($email_to,$subject,$message,$header);
?>
<h1>Thank you for your submission!</h1>
<p>Your information has been sent, and our office will contact you to verify the assignment and confirm any special instructions.</p>
<p>We thank you for utilizing our services. We hope to complete your assignment in a timely manner.</p>
</body>
</html>
Any and all help is greatly appreciated.
remove the ; from
if($_POST['trojan']!='');
^
here
because I think this following statement is executed every time as that semicolon make the following line independent of that if statement
die("Changed field");
I haven't checked the code in detail, but the most likely problem is that the server is not set up to send mail.
Check
a) php settings for mail (you can do this by running phpinfo(); but usually these are set up correctly out of the box.
b) Check server mail application is installed and configured, eg Exim, Sendmail, etc.
Setting up a server to send (but not receive) mail is fairly easy. Eg on a Debian server you would run something like
sudo apt-get install exim4
And then follow instructions to configure it to send mail.
A few things to check:
Is your mail server properly configured?
Can you send test email successfully?
Do you have any other control in place to test whether the infrastructure overall works, rather than just the one script that is not currently working?
Also consider using a library such as PHPMailer (http://phpmailer.worxware.com/). It offers much more flexibility when it comes to configuring your mail server.
At your if statement:
if($_POST['trojan'] != '');
die("Changed field");
Should be:
if($_POST['trojan'] != ''){
die("Changed field");
}

Categories