I have an html form that has lots of fields, and I have built a PHP form handler to email the results of the form to me.
The only part I am having trouble with is, I have a list of checkboxes with an associated text field for each.
In my email, I want a list of ONLY the items that are checked, with the contents of the text box. For Example, 360 - qty 10
Here are a few of the items and the code for them:
<form action="form_handler2.php" method="POST">
<div class="one_third first">
<label for="first_name"><b>First Name</b> <span>*</span></label>
<input type="text" name="first_name" id="first_name" value="" size="22" required>
</div>
<div class="one_third">
<label for="last_name"><b>Last Name</b> <span>*</span></label>
<input type="text" name="last_name" id="last_name" value="" size="22" required>
</div>
<div class="one_third first">
<label for="phone"><b>Phone #</b> <span>*</span></label>
<input type="text" name="phone" id="phone" value="" size="22" required>
</div>
<div class="one_third">
<label for="email"><b>Email</b> <span>*</span></label>
<input type="email" name="email" id="email" value="" size="22" required>
</div>
<div class="two_thirds first">
<label for="business_name"><b>Business Name (type personal if not affiliated with a business)</b> <span>*</span></label>
<input type="text" name="business_name" id="business_name" value="" size="59" required>
</div>
<div class="two_thirds first">
<label for="address_1"><b>Address 1</b></label>
<input type="text" name="address_1" id="address_1" value="" size="59" >
</div>
<div class="two_thirds first">
<label for="address_2"><b>Address 2</b></label>
<input type="text" name="address_2" id="address_2" value="" size="59" >
</div>
<div class="one_third first">
<label for="city"><b>City</b></label>
<input type="text" name="city" id="city" value="" size="22" >
</div>
<div class="one_third">
<label for="state"><b>State</b></label>
<select name="state" id="state">
<option value="">- select -</option>
<option value="AK">AK</option>
<option value="AL">AL</option>
<option value="AR">AR</option>
<option value="AZ">AZ</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="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="MS">MS</option>
<option value="MT">MT</option>
<option value="NC">NC</option>
<option value="ND">ND</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="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="VA">VA</option>
<option value="VT">VT</option>
<option value="WA">WA</option>
<option value="WI">WI</option>
<option value="WV">WV</option>
<option value="WY">WY</option>
</select>
</div>
<div class="one_third first">
<label for="zip"><b>Zip</b></label>
<input type="text" name="zip" id="zip" value="" size="10" >
</div>
<div class="one_third first">
<label for="country"><b>Country</b></label>
<select name="country" id="country">
<option value="">- select -</option>
<option value="US">US</option>
</select>
</div>
<div class="two_thirds first">
<label for="reason"><b>Reason for Contact</b> <span>*</span></label>
Note: sample requests for businesses using Abralon pads in their current business <br>practice only. Limit one pad per grit type, max 3 pads per sample
<select name="reason" id="reason" required>
<option value="">- select -</option>
<option value="Order">Order</option>
<option value="Reorder">Re-order</option>
<option value="Sample">Sample Request</option>
<option value="Information">Information Request</option>
<option value="Feedback">Feedback/Comment</option>
<option value="Other">Other</option>
</select>
</div>
<div class="two_thirds first">
<b>Order/Sample Request - </b>Select grits and quantity. Full boxes are 20 count. <br>Orders of 20 or more qualify for lower pricing. Orders of 60 or more pads are <br>automatically upgraded to priority mail.
</div>
<div class="inline-field">
<input type="checkbox" name="grit[]" value="180">
<label for="180"> 180
<input id="180_qty" name="180_qty" type="text" placeholder="Qty" size="5" class="180_qty">
</label><br>
</div>
<div class="inline-field">
<input type="checkbox" name="grit[]" value="360">
<label for="360"> 360
<input id="360_qty" name="360_qty" type="text" placeholder="Qty" size="5" class="360_qty">
</label><br>
</div>
<div class="inline-field">
<input type="checkbox" name="grit[]" value="500">
<label for="500"> 500
<input id="500_qty" name="500_qty" type="text" placeholder="Qty" size="5" class="500_qty">
</label><br>
</div>
<div class="inline-field">
<input type="checkbox" name="grit[]" value="1000">
<label for="1000"> 1000
<input id="1000_qty" name="1000_qty" type="text" placeholder="Qty" size="5" class="1000_qty">
</label><br>
</div>
<div class="inline-field">
<input type="checkbox" name="grit[]" value="2000">
<label for="2000"> 2000
<input id="2000_qty" name="2000_qty" type="text" placeholder="Qty" size="5" class="2000_qty">
</label>
<br>
</div>
<div class="inline-field">
<input type="checkbox" name="grit[]" value="3000">
<label for="3000"> 3000
<input id="3000_qty" name="3000_qty" type="text" placeholder="Qty" size="5" class="3000_qty">
</label>
<br>
</div>
<div class="inline-field">
<input type="checkbox" name="grit[]" value="4000">
<label for="4000"> 4000
<input id="4000_qty" name="4000_qty" type="text" placeholder="Qty" size="5" class="4000_qty">
</label><br>
</div>
<div class="two_thirds first">
<label for="comment"><b>Comments/Special Instructions</b></label>
<textarea name="comment" id="comment" cols="59" rows="5"></textarea>
</div>
<br>Order will be confirmed by email with pricing. Payment information must be<br> received via phone or fax prior to shipment.
<br><br>
<b>NOTE: Fields with "*" are required</b><br><br>
<div class="inline-field">
<input type="checkbox" name="abranet_info" value="abranet_info">
<label for="abranet_info"> I would like information on Abranet pads
</label><br>
</div>
<div class="inline-field">
<input type="checkbox" name="newsletter" value="newsletter" checked>
<label for="newsletter"> Sign me up for your quarterly newsletter on Abralon and related products
</label><br>
</div> <br>
<div>
<input type="submit" name="submit" value="Submit Form">
<input type="reset" name="reset" value="Reset Form">
</div>
</form>
My php is:
<?php
$field_first_name = $_POST['first_name'];
$field_last_name = $_POST['last_name'];
$field_phone = $_POST['phone'];
$field_email = $_POST['email'];
$field_business_name = $_POST['business_name'];
$field_address_1 = $_POST['address_1'];
$field_address_2 = $_POST['address_2'];
$field_city = $_POST['city'];
$field_state = $_POST['state'];
$field_zip = $_POST['zip'];
$field_country = $_POST['country'];
$field_reason = $_POST['reason'];
$field_comment = $_POST['comment'];
$mail_to = 'xxx#xxx.com';
$subject = 'XXX - '.$field_reason;
$body_message = 'Name: '.$field_first_name.' '.$field_last_name."\n";
$body_message .= 'Business Name: '.$field_business_name."\n";
$body_message .= 'E-mail: '.$field_email."\n\n";
$body_message .= 'Phone: '.$field_phone."\n\n";
$body_message .= 'Address: '.$field_address_1."\n";
$body_message .= ' '.$field_address_2."\n";
$body_message .= ' '.$field_city.', '.$field_state.' '.$field_zip.' '.$field_country."\n\n";
$body_message .= 'Comment: '.$field_comment."\n";
$headers = 'From: '.$field_email."\r\n";
$headers .= 'Reply-To: '.$field_email."\r\n";
$mail_status = mail($mail_to, $subject, $body_message, $headers);
if ($mail_status) { ?>
<script language="javascript" type="text/javascript">
window.location = 'success.html';
</script>
<?php
}
else { ?>
<script language="javascript" type="text/javascript">
window.location = 'failure.html';
</script>
<?php
}
?>
You don't have the php for the "grit," which I assume is the part you're concerned about.
However what I think you want to do, is name each grit checkbox like
<input type="checkbox" name="grit3000" value="3000">
And then in the PHP you will want to have an if statement for each
if (isset($_POST['grit3000']) {
$body_message .= 'Grit3000 CHECKED \n';
}
Related
I am trying to create a dynamic HTML form where the fields displayed are based on inputs in the field above it. So far, I have only found resources that work in JS but I was wondering if there was a pure PHP way to do it.
To give some context: I would like to create a form for a user to set their goal. The 'How Much' and 'programme duration' fields are dependent on the 'goal type' field. Ie. if They choose a muscle building goal then it will only show 5% etc. Here is my code so far...
Much appreciated in advanced!
<?php
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
session_start();
if (isset($_SESSION['Username'])) {
?>
<html>
<head>
</head>
<body>
<h1>Please set your goal and programme type</h1>
<form method="POST" action="Set_Goal_process.php" >
<label for="Sex"><b>Sex: </b></label>
<select name="Sex" id="Sex" required>
<option value="Male">Male</option>
<option value="Female">Female</option>
</select>
<label for="Age"><b>Age: </b></label>
<input type="number" name="Age" id="Age" value="Age" required>
<label for="Height"><b>Height: </b></label>
<input type="number" name="Height" id="Height" required>
<label for="Current Weight"><b>Current Weight: </b></label>
<input type="number" name="Initial_weight" id="Initial Weight" required>
<br><br><br><br><br><br><br><br><br>
<label for="Activity level"><b>Activity level: </b></label>
<select name="Activity_level" id="Activity level" required>
<option value=1>Sedentary</option>
<option value=2>Mostly sedentary</option>
<option value=3>Lightly active</option>
<option value=4>Highly active</option>
</select>
<label for="Goal type"><b>Goal type: </b></label>
<select name="Goal_type" id="Goal type" required>
<option value=1>Fat Loss</option>
<option value=2>Maintenance</option>
<option value=3>Muscle Building</option>
</select>
<label for="How much"><b>How much: </b></label>
<select name="How_much" id="How much" default="0" required>
<option value=-10>-10%</option>
<option value=-7.5>-7.5%</option>
<option value=-5>-5%</option>
<option value=-2.5>-2.5%</option>
<option value=0 selected>0%</option>
<option value=2.5>2.5%</option>
<option value=5>5%</option>
</select>
<!-- comment make both How much and program duration conditional -->
<label for="Program Duration"><b>Program Duration: </b></label>
<select name="Program_duration" id="Program Duration" required>
<option value=4>4 weeks</option>
<option value=8>8 weeks</option>
<option value=12 selected>12 weeks</option>
</select>
<label for="Experience_level"><b>Experience level: </b></label>
<select name="Expereince_level" id="Expereince level" required>
<option value=1 selected>Beginner</option>
<option value=2>Novice</option>
<option value=3 >Intermediate</option>
<option value=4 >Advanced</option>
</select>
<label for="Sessions per week">Sessions per week:</label>
<input type="number" name="Sessions_per_week" id="Sessions per week" min="1" max="7" required>
<label for="Start date">Start date:</label>
<input type="date" name="Start date"id="Start date" >
<br><br>
<input type="submit" name="Submit" value="Get Started!"required>
</form>
</body>
</html>
<?php
}else {
session_destroy();
header("location: index.php");
}
Is there any way to write PHP code inside .twig file in WordPress? I am trying to send a mail by using the form values from a .twig template file.
page-pledgeform.twig
{% extends "base.twig" %}
{% block content %}
<body class="{{body_class}}">
<div class="wrapper">
<section id="content" role="main" class="content-wrapper">
{% block body %}
<!-- strat_body_content -->
<div class="body_content">
<div class="space_height"></div>
<div class="form_section">
<div class="container">
<div class="row">
<div class="col-sm-8 col-sm-offset-2">
<!-- Top Navigation -->
<div class="main clearfix">
<form id="nl-form" method="POST" action="" class="nl-form">
I am <input type="text" name="name" id="user_name" value="" placeholder="Name" data-subline="For example: <em>Mr. K. Roy</em>"/>
It is a long <input type="text" value="" placeholder="Country name" data-subline="For example:
<em>India</em>"/>
Gender
<select>
<option value="1" selected>Male</option>
<option value="2">Female</option>
<option value="3">Other</option>
</select>
Lorem
<select>
<option value="1" selected>O</option>
<option value="2">B</option>
<option value="3">B+</option>
<option value="4">B-</option>
<option value="2">A-</option>
</select>
.
There are many <input type="text" value="" placeholder="Address" data-subline="For example: <em>Los Angeles</em> or <em>New York</em>"/>
passages of
<select>
<option value="1" selected>Mumbai</option>
<option value="2">Delhi</option>
<option value="3">Bangalore</option>
<option value="4">Hyderabad</option>
<option value="5">Ahmedabad</option>
<option value="6">Kolkata</option>
</select>
classical Latin
<select>
<option value="1" selected>Gujarat</option>
<option value="2">Andhra Pradesh</option>
<option value="3">Tamil Nadu</option>
<option value="4">Maharashtra</option>
<option value="5">West Bengal</option>
</select>
first true
<select>
<option value="1" selected>Vijayawada</option>
<option value="2">Kanyakumari</option>
<option value="3">Rewalsar</option>
<option value="4">Dehradun</option>
<option value="2">24 parganas</option>
</select>
There are many <input type="text" value="" placeholder="Pin code" data-subline="For example: <em>700049</em>"/>
There are <input type="email" value="" placeholder="Email ID" data-subline="For example: <em>mac#gmail.com</em>"/>
Phone <input type="number" value="" placeholder="Phone Number" data-subline="For example: <em>000-123-000</em>"/>
Mobile number <input type="number" value="" placeholder="Mobile Number" data-subline="For example: <em>000-123-000</em>"/>
My information may be shared with the
<select>
<option value="1" selected>Yes</option>
<option value="2">No</option>
</select>
<div class="nl-overlay"></div>
<br><br><br>
<h4>Emergency Contact Person Details :-</h4>
I am <input type="text" name="name" value="" placeholder="Name" data-subline="For example: <em>Mr. k. Roy</em>"/>
It is a long <input type="text" value="" placeholder="Country name" data-subline="For example: <em>India</em>"/>
Gender
<select>
<option value="1" selected>Male</option>
<option value="2">Female</option>
<option value="3">Other</option>
</select>
Lorem
<select>
<option value="1" selected>O</option>
<option value="2">B</option>
<option value="3">B+</option>
<option value="4">B-</option>
<option value="2">A-</option>
</select>
.
There are many <input type="text" value="" placeholder="Address" data-subline="For example: <em>India</em>"/>
passages of
<select>
<option value="1" selected>Mumbai</option>
<option value="2">Delhi</option>
<option value="3">Bangalore</option>
<option value="4">Hyderabad</option>
<option value="5">Ahmedabad</option>
<option value="6">Kolkata</option>
</select>
classical Latin
<select>
<option value="1" selected>Gujarat</option>
<option value="2">Andhra Pradesh</option>
<option value="3">Tamil Nadu</option>
<option value="4">Maharashtra</option>
<option value="5">West Bengal</option>
</select>
first true
<select>
<option value="1" selected>Vijayawada</option>
<option value="2">Kanyakumari</option>
<option value="3">Rewalsar</option>
<option value="4">Dehradun</option>
<option value="2">24 parganas</option>
</select>
There are many <input type="text" value="" placeholder="Pin code" data-subline="For example: <em>700049</em>"/>
There are <input type="email" value="" placeholder="Email ID" data-subline="For example: <em>mac#gmail.com</em>"/>
Phone <input type="number" value="" placeholder="Phone Number" data-subline="For example: <em>000-123-000</em>"/>
Mobile number <input type="number" value="" placeholder="Mobile Number" data-subline="For example: <em>000-123-000</em>"/>
My information may be shared with the
<select>
<option value="1" selected>Yes</option>
<option value="2">No</option>
</select>
<div class="clearfix"></div>
<div class="nl-submit-wrap" style="float: right;">
<button class="nl-submit" name="submit" id="btnSubmit" type="submit">Agree & Submit</button>
</div>
<div class="clearfix"></div>
<div class="nl-overlay"></div>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
{% endblock %}
{% block extrajs %}
<script src="{{theme.link}}/js/nlform.js"></script>
<script>
var nlform = new NLForm( document.getElementById( 'nl-form' ) );
</script>
<script>
var emargency = new NLForm( document.getElementById( 'emargency' ) );
</script>
{% endblock %}
</div>
</body>
</html>
{% endblock %}
twig is not like blade, you can't write php code inside.
However, you can write your own twig extensions:
https://symfony.com/doc/current/templating/twig_extension.html
please be sure to separate your twig extension from your logic (send mail), add this functionality on a service and bridge both (service & twig extension).
I have a system which has only two transaction, Registration.php and req.php. The two transaction data are saved in the table new in my database. Registration.php is my first transacton, then req.php. This php files are form, which both has a submit button linked to add.php. The fields of my new table are devided in the two forms. The flow is that first Registration.php will be executed then req.php. My table new has a primary key named new_id and its auto increment. My problem is that, after execution of both forms, ONLY the data of Registration.php are save in the database table new and the req.php are blank. What is the problem? I need your help.
here is the Registration.php code:
<html>
<head>
<link rel="stylesheet" href="bootstrap/css/bootstrap.css"/>
<script type="text/javascript" src="jquery.js">
</script>
<script type="text/javascript" src="bootstrap/js/bootstrap.js">
</script>
<TITLE>
New Registration Form
</TITLE></head>
<body>
<center>
<br>
<p style="font-weight: bold; font-size: 30">Please Fill Out Your Information Sheet</p><p><?php
echo date('F j, Y, g:i a', time()+25200);
?></p>
<form method="POST" action="add.php">
<!--<input type="text" name="new_fname" class="Form-Control" placeholder="First Name" id="fname" required>-->
<input type="text" name="new_fname" class="Form-Control" placeholder="First Name" id="fname" required>
<input type="text" name="new_mname" class="Form-Control" placeholder="Middle Initial" id="mname" required>
<input type="text" name="new_lname" class="Form-Control" placeholder="Last Name" id="lname" required><br><br>
Select Your gender
<select name="new_gender">
<option value=""></option>
<option value="Male">Male</option>
<option value="Female">Female</option>
</select>
Select Your Status
<select name="new_status">
<option value=""></option>
<option value="New">New</option>
<option value="Old">Old</option>
<option value="Transferee">Transferee</option>
<option value="Shiftee">Shiftee</option>
</select>
Select Your Course
<select name="new_course">
<option value=""></option>
<option value="BSINFOTECH">BSINFOTECH</option>
<option value="BSIS">BSIS</option>
<option value="BSCOMTECH">BSCOMTECH</option>
</select>
<br><br>
<input type="text" name="new_age" class="Form-Control" placeholder="Age" id="age" required><br><br>
<input type="text" name="new_bp" class="Form-Control" placeholder="Birth Place" id="bp" required><br><br>
<input type="text" name="new_add" class="Form-Control" placeholder="Address" id="add" required><br><br>
<input type="text" name="new_nat" class="Form-Control" placeholder="Nationality" id="nat" required><br><br>
<input type="text" name="new_rel" class="Form-Control" placeholder="Religion" id="rel" required><br><br>
<input type="text" name="new_tel" class="Form-Control" placeholder="Tel. No." id="tel" required><br><br>
<input type="text" name="new_cel" class="Form-Control" placeholder="Cel. No." id="cel" required><br><br>
<input type="text" name="new_mail" class="Form-Control" placeholder="E-mail Address" id="mail" required><br><br>
<button onclick="parent.location='req.php'" type="submit" name="next">Next</button>
<button type="submit" class="btn" name="save" value="save">Save</button>
</form>
</body>
</html>
here is the req.php code:
<html>
<head>
<link rel="stylesheet" href="bootstrap/css/bootstrap.css"/>
<script type="text/javascript" src="jquery.js">
</script>
<script type="text/javascript" src="bootstrap/js/bootstrap.js">
</script>
<title>
REQUIRMENTS FORM
</title>
<br>
<p align="center" style="font-size: 50">REQUIRMENTS FORM</p>
</head>
<body>
<center>
<br>
<p align="center" style="font-size: 30">Registrar</p>
<form style="font-size: 20" action="add.php" method='post'>
Form 138
<br>
<select name="form1">
<option value=""</option>
<option value="Yes">Yes</option>
<option value="No">No</option>
</select>
<br>
Form 137A
<br>
<select name="form2">
<option value=""</option>
<option value="Yes">Yes</option>
<option value="No">No</option>
</select>
<br>
2 X 2 ID
<br>
<select name="picture">
<option value=""</option>
<option value="Yes">Yes</option>
<option value="No">No</option>
</select>
<br>
NSO Birth Certificate
<br>
<select name="nso">
<option value=""</option>
<option value="Yes">Yes</option>
<option value="No">No</option>
</select>
<br>
Good Moral Certificate
<br>
<select name="gmc">
<option value=""</option>
<option value="Yes">Yes</option>
<option value="No">No</option>
</select>
<p align="center" style="font-size: 30">Library</p>
Library Card
<br>
<select name="lc">
<option value=""</option>
<option value="Yes">Yes</option>
<option value="No">No</option>
</select>
<br>
<br>
<p align="center" style="font-size: 30">Cashier</p>
<p><h4>You should have paid minimum of P2000.00-2500.00</h4></p>
<input type="text" name="cashier" class="Form-Control" width="100px" placeholder="Enter amount" id="cashier" required></input>
<button type="submit" style="font-size: 20" class="btn btn-primary btn-block" name="submit" value="save">SUBMIT</button>
<button type="button" style="font-size: 20" class="btn btn-primary btn-block"><a href="newform.php?id=<?php echo $data->new_id ?>">Process Student Copy</button>
<input type="hidden" value="<?php echo $data->new_id ?>" name="id" >
</form>
</body>
</html>
here is the add.php code:
<?php
mysql_connect("localhost","root");
mysql_select_db("enrollee");
$course=$_POST['new_course'];
$gender=$_POST['new_gender'];
$gender=$_POST['new_gender'];
$status=$_POST['new_status'];
$fname=$_POST['new_fname'];
$mname=$_POST['new_mname'];
$lname=$_POST['new_lname'];
$age=$_POST['new_age'];
$bp=$_POST['new_bp'];
$add=$_POST['new_add'];
$nat=$_POST['new_nat'];
$rel=$_POST['new_rel'];
$tel=$_POST['new_tel'];
$cel=$_POST['new_cel'];
$mail=$_POST['new_mail'];
form1=$_POST['form1'];
$form2=$_POST['form2'];
$picture=$_POST['picture'];
$nso=$_POST['nso'];
$gmc=$_POST['gmc'];
$lc=$_POST['lc'];
$cashier=$_POST['cashier'];
mysql_query("INSERT INTO new(new_id,new_course,new_gender,new_status,new_fname,new_mname,new_lname,new_age,new_bp,new_add,new_nat,new_rel,new_tel,new_cel,new_mail,form1,form2,picture,nso,gmc,lc,cashier))
VALUES(NULL, '$course','$gender', '$status', '$fname','$mname','$lname','$age','$bp','$add','$nat','$rel','$tel','$cel','$mail','$form1','$form2','$picture','$nso','$gmc','$lc','$cashier')");
header("Location: read.php");
?>
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");
}
I've build a contact form on my project, but I get 500 Internet Server Error when I examine my script. I show my code below, so please give me some tips.
Thank you.
form: permission (705)
<form id="contactForm" method="POST" action="mail.php" >
<div>
<label for="name">氏名<span>必須</span></label><br />
<input type="text" size="50" name="name" id="name" class="text" class="required" value="" />
</div>
<div>
<label for="company">社名</label><br />
<input type="text" size="50" name="company" id="comany" class="text" value="" />
</div>
<div>
<label for="pref">住所<span>必須</span></label><br />
<select name="pref" size="1" id="pref">
<option value="selected">都道府県</option>
<option value="北海道">北海道</option>
<option value="青森県">青森県</option>
<option value="岩手県">岩手県</option>
<option value="宮城県">宮城県</option>
<option value="秋田県">秋田県</option>
<option value="山形県">山形県</option>
<option value="福島県">福島県</option>
<option value="茨城県">茨城県</option>
<option value="栃木県">栃木県</option>
<option value="群馬県">群馬県</option>
<option value="埼玉県">埼玉県</option>
<option value="千葉県">千葉県</option>
<option value="東京都">東京都</option>
<option value="神奈川県">神奈川県</option>
<option value="新潟県">新潟県</option>
<option value="富山県">富山県</option>
<option value="石川県">石川県</option>
<option value="福井県">福井県</option>
<option value="山梨県">山梨県</option>
<option value="長野県">長野県</option>
<option value="岐阜県">岐阜県</option>
<option value="静岡県">静岡県</option>
<option value="愛知県">愛知県</option>
<option value="三重県">三重県</option>
<option value="滋賀県">滋賀県</option>
<option value="京都府">京都府</option>
<option value="大阪府">大阪府</option>
<option value="兵庫県">兵庫県</option>
<option value="奈良県">奈良県</option>
<option value="和歌山県">和歌山県</option>
<option value="鳥取県">鳥取県</option>
<option value="島根県">島根県</option>
<option value="岡山県">岡山県</option>
<option value="広島県">広島県</option>
<option value="山口県">山口県</option>
<option value="徳島県">徳島県</option>
<option value="香川県">香川県</option>
<option value="愛媛県">愛媛県</option>
<option value="高知県">高知県</option>
<option value="福岡県">福岡県</option>
<option value="佐賀県">佐賀県</option>
<option value="長崎県">長崎県</option>
<option value="熊本県">熊本県</option>
<option value="大分県">大分県</option>
<option value="宮崎県">宮崎県</option>
<option value="鹿児島県">鹿児島県</option>
<option value="沖縄県">沖縄県</option>
</select>
</div>
<div>
<label for="city">市区町村群(番地含む)<span>必須</span></label><br />
<input type="text" size="50" name="city" id="city" class="text" value="" />
</div>
<div>
<label for="apart">アパート/マンション名(部屋番号含む)</label><br />
<input type="text" size="50" name="apart" id="apart" class="text" value="" />
</div>
<div>
<label for="email">メールアドレス<span>必須</span></label><br />
<input type="text" size="50" name="email" id="email" class="text" value="" />
</div>
<div>
<label for="tel">電話番号<span>必須</span></label><br />
<input type="text" size="50" name="tel" id="tel" class="text" value="" />
</div>
<div>
<label for="message">内容</label><br />
<textarea rows="5" cols="50" name="message" class="text" id="message">
</textarea>
</div>
<input type="submit" value="送信" name="submit" />
</form>
mail.php: permission (705)
<?php
$name = $_POST['name'];
$company = $_POST['company'];
$pref = $_POST['pref'];
$city = $_POST['city'];
$apart = $_POST['apart'];
$email = $_POST['email'];
$tel = $_POST['tel'];
$message = $_POST['message'];
$formcontent = "氏名: $name \n\n 社名: $company \n\n 住所: $pref \n $city \n $apart \n\n $email \n\n $tel \n\n $message";
$recipient = 'yawatajyuku#gmail.com';
$subject = '八幡宿っていいねに関する問い合わせ';
$mailheader ='From $email"
mail($recipient, $subject, $formcontent, $mailheader) or die("Error!");
echo 'ご送信ありがとうございます!担当からの連絡をお待ちください。'; // true -> show up thanks.
?>
This line:
$mailheader ='From $email"
Should be like this:
$mailheader = "From $email";
You have to match quotes quotes when enclosing text,
' does not match "
You also forgot the semicolon ; at the end of the line.
On your $mailheader line in mail.php, replace the single quote (') with a double quote (").
in the line:
$mailheader = 'From $email"
you start with a single apostrophe and you end with a double and there is no semi-colon at the end.