This question already has answers here:
Reference - What does this error mean in PHP?
(38 answers)
PHP mail function doesn't complete sending of e-mail
(31 answers)
Closed 3 years ago.
My form throws an error in PHP when submitting form data via email. Not sure what I did wrong/am missing.
Form:
<div class="row">
<div class="col">
<form id="msform" action="submit.php" method="post" data-autosubmit>
<!-- Step 1 -->
<fieldset>
<h2 class="fs-title">Step 1</h2>
<h3 class="fs-subtitle">Tell us about your device.</h3>
<div class="form-group">
<label for="brand">Brand</label>
<select class="form-control" id="brand" name="brand" required>
<option value="" selected data-default>- Device Brand -</option>
<option value="Apple">Apple</option>
<option value="Samsung">Samsung</option>
</select>
</div>
<div class="form-group">
<label for="model">Model</label>
<select class="form-control" id="model" name="model" required>
<option value="" selected data-default>- Device Model -</option>
<option value="iPhone 8">iPhone 8</option>
<option value="iPhone X">iPhone X</option>
<option value="Galaxy S8">Galaxy S8</option>
<option valaue="Galaxy S9">Galaxy S9</option>
<option value="Galaxy S10">Galaxy S10</option>
</select>
</div>
<div class="form-group">
<label for="variant">Storage</label>
<select class="form-control" id="variant" name="variant" required>
<option value="" selected data-default>- Storage Size -</option>
<option value="iPhone 8 - 64GB">iPhone 8 - 64GB</option>
<option value="iPhone 8 - 256GB">iPhone 8 - 256GB</option>
<option value="iPhone X - 64GB">iPhone X - 64GB</option>
<option value="iPhone X - 256GB">iPhone X - 256GB</option>
<option value="Galaxy S8 - 64GB">Galaxy S8 - 64GB</option>
<option valaue="Galaxy S9 - 64GB">Galaxy S9 - 64GB</option>
<option value="Galaxy S10 - 128GB">Galaxy S10 - 128GB</option>
</select>
</div>
<input type="button" name="next" class="next action-button" value="Next" />
</fieldset>
<!--Step 1 End-->
<!--Step 2-->
<fieldset>
<h2 class="fs-title">Step 2</h2>
<h3 class="fs-subtitle">Now we need to know more about your device's condition.</h3>
<div class="form-group">
<label for="screen">How is your device's <b>screen</b>?</label>
<select class="image-picker form-control" id="screen" name="screen" required>
<option value="0" data-img-src="">Flawless, no scratches!</option>
<option value="1" data-img-src="">1-2 light scratches</option>
<option value="2" data-img-src="">3 or more scratches</option>
<option value="3" data-img-src="">Cracked or damaged</option>
</select>
</div>
<div class="form-group">
<label for="body">How is your device's <b>housing</b>?</label>
<select class="form-control" id="body" name="body" required>
<option value="0">Flawless, no scratches or bends!</option>
<option value="1">1-2 light scratches</option>
<option value="2">3 or more scratches</option>
<option value="3">Bent or severely damaged</option>
</select>
</div>
<div class="form-group">
<label for="power">Is your device able to <b>power on</b>?</label>
<select class="form-control" id="power" name="power" required>
<option value="0">Yes</option>
<option value="1">No</option>
</select>
</div>
<input type="button" name="previous" class="previous action-button-previous" value="Previous" />
<input type="button" name="next" class="next action-button" value="Next" />
</fieldset>
<!--Step 2 End-->
<!--Step 3-->
<fieldset>
<h2 class="fs-title">Step 3</h2>
<h3 class="fs-subtitle">Just a little more information needed, almost there!</h3>
<div class="form-group">
<label for="battery">Does your device have a faulty battery?</label>
<select class="form-control" id="battery" name="battery" required>
<option value="0">Yes</option>
<option value="1">No</option>
</select>
</div>
<div class="form-group">
<label for="charge">Is your device able to <b>charge</b>?</label>
<select class="form-control" id="charge" name="charge" required>
<option value="0">Yes</option>
<option value="1">No</option>
</select>
</div>
<div class="form-group">
<label for="calls">Is your device able to <b>make and receive calls</b>?</label>
<select class="form-control" id="calls" name="calls">
<option value="0">Yes</option>
<option value="1">No</option>
</select>
</div>
<div class="form-group">
<label for="fcamera">Does your <b>front camera work</b>?</label>
<select class="form-control" id="fcamera" name="fcamera">
<option value="0">Yes</option>
<option value="1">No</option>
</select>
</div>
<div class="form-group">
<label for="rcamera">Does your <b>rear camera work</b>?</label>
<select class="form-control" id="rcamera" name="rcamera">
<option value="0">Yes</option>
<option value="1">No</option>
</select>
</div>
<div class="form-group">
<label for="water">Is your device <b>water damaged</b>?</label>
<select class="form-control" id="water" name="water">
<option value="0">Yes</option>
<option value="1">No</option>
</select>
</div>
<div class="form-group">
<label for="wifi">Is your device able to connect using WiFi?</label>
<select class="form-control" id="wifi" name="wifi">
<option value="0">Yes</option>
<option value="1">No</option>
</select>
</div>
<input type="button" name="previous" class="previous action-button-previous" value="Previous" />
<input type="button" name="next" class="next action-button" value="Next" onclick="getFinalPrice();" />
</fieldset>
<!--End Step 3-->
<!--Final-->
<fieldset>
<h2 class="fs-title">Value</h2>
<h3 class="fs-subtitle">Here's how much we can offer for your device.</h3>
<h2 id="finalValue"></h2>
<hr>
<h3 class="fs-subtitle">If you're happy with our offer, please fill in your contact details below and we'll arrange for free a pickup of your device.</h3>
<div class="form-group">
<label for="firstname">Name</label>
<input type="text" class="form-control" placeholder="Full Name" name="name" required>
</div>
<div class="form-group">
<label for="email">Email</label>
<input type="email" class="form-control" placeholder="example#example.com" name="email" required>
</div>
<div class="form-group">
<label for="number">Phone Number</label>
<input type="number" class="form-control" placeholder="91234567" name="number" required>
<small id="numberHelp" class="form-text text-muted">We'll never share your email and phone number with anyone else.</small>
</div>
<input type="button" name="previous" class="previous action-button-previous" value="Previous" />
<input type="submit" name="submit" class="submit action-button" value="Submit" />
</fieldset>
<!--Final End-->
</form>
</div>
</div>
<!-- /.MultiStep Form -->
</body>
</html>
PHP Script:
<?php
$name = $_POST['name'];
$number = $_POST['number'];
$email = $_POST['email'];
$brand = $_POST['brand'];
$model = $_POST['model'];
$variant = $_POST['variant'];
$screen = $_POST['screen'];
$body = $_POST['body'];
$power = $_POST['power'];
$battery = $_POST['battery'];
$charge = $_POST['charge'];
$calls = $_POST['calls'];
$fcamera = $_POST['fcamera'];
$rcamera = $_POST['rcamera'];
$water = $_POST['water'];
$wifi = $_POST['wifi'];
$formcontent = "From: $name \n Contact: $number \n Device Brand: $brand \n Device Model: $model \n Device Variant: $variant \n How is your device's screen? $screen \n How is your device's housing? $body \n Is your device able to power on? $power \n Does your device have a fault battery? $battery \n Is your device able to charge? $charge \n Does your front camera work? $fcamera \n Does your rear camera work? $rcamera \n Is your device water damaged? $water \n Is your device able to connect using WiFi? $wifi";
$recipient = "example#example.com";
$subject = "Buyback Request";
$mailheader = "From: $email \r\n";
mail($recipient, $subject, $formcontent, $mailheader) or die("Error!");
echo "Thank you! We'll be in contact soon. You'll now be redirected back to our main webpage.";
/* Redirect browser */
header("Location: https://example.com");
/* Make sure that code below does not get executed when we redirect. */
exit;
?>
I gave the input options all a name value so that PHP knows where to find the data. Not sure if this is the correct way of doing it.
Currently, the form always throws an error on submission.
All help is appreciated, thank you!
Related
I have developed a website in CodeIgniter 4 framework. One particular page has a form that doesn't submit but validates HTML input controls that have required attributes. I have tried everything but could not find the exact bug. Following is the live URL of that page:
https://spcollegedumka.ac.in/index.php/feedback/send
<form method="post" id="feedbackForm">
<div class="mb-2">
<label class="form-label">Who you are?</label>
<select name="category" class="form-control form-control-sm" required="">
<option value="" selected="" disabled="">---- Select ----</option>
<option value="Student">Student</option>
<option value="Parent">Parent</option>
<option value="Guest">Guest</option>
</select>
</div>
<div class="mb-2">
<label class="form-label">Your Name</label>
<input type="text" name="name" class="form-control form-control-sm" required="">
</div>
<div class="mb-2">
<label class="form-label">Roll No. (students only)</label>
<input type="text" name="roll" class="form-control form-control-sm">
</div>
<div class="mb-2">
<label class="form-label">Select Faculty</label>
<select name="faculty" class="form-control form-control-sm" required="">
<option value="" selected="" disabled="">---- Select ----</option>
<option value="1">Faculty of Humanities</option>
<option value="2">Faculty of Social Science</option>
<option value="3">Faculty of Commerce</option>
<option value="4">Faculty of Science</option>
<option value="100">Not Applicable (For Parent/Guest)</option>
</select>
</div>
<div class="row">
<div class="col-md-6">
<div class="mb-2">
<label class="form-label">Mobile No.</label>
<input type="text" name="mobile" class="form-control form-control-sm" required="">
</div>
</div>
<div class="col-md-6">
<div class="mb-4">
<label class="form-label">Email Address</label>
<input type="email" name="email" class="form-control form-control-sm" required="">
</div>
</div>
</div>
<button type="submit" value="submit" class="btn btn-sm">SUBMIT & GO NEXT</button>
</form>
i dont know wht u mean, but try to read attribut required
required="true"
or
required
https://www.w3schools.com/tags/att_input_required.asp
I have made form using HTML n CSS and also linked action to my PHP file index_handler.php just don't understand where is the mistake that a strange white screen appears when I press submit
<form action="index_handler.php" class="appointment-form ftco-animate" method="post" name="form">
<div class="d-md-flex">
<div class="form-group">
<input type="text" class="form-control" name="name" placeholder="Full Name ">
</div>
<div class="form-group ml-md-4">
<input type="text" class="form-control" name="m_name" placeholder="Mother's Name">
</div>
<div class="form-group ml-md-4">
<input type="email" class="form-control" name="email" placeholder="Email ID">
</div>
</div>
<div class="d-md-flex">
<div class="form-group">
<div class="form-field">
<div class="select-wrap">
<div class="icon"><span class="ion-ios-arrow-down"></span></div>
<select name="course" id="" class="form-control">
<option value="text" style="color:black" >Select Course</option>
<option value="text" style="color:black" >Regular Classroom Programme</option>
<option value="text" style="color:black" >Distance Learning Programme</option>
<option value="text" style="color:black" >Online Learning Programme</option>
<option value="text" style="color:black" >School Integrated Programme</option>
<option value="text" style="color:black" >Crash Course Programme</option>
<option value="text" style="color:black" >Summer Course Programme</option>
<option value="text" style="color:black" >Edu-Nexus Programme</option>
</select>
</div>
</div>
</div>
<div class="form-group">
<div class="form-field">
<div class="select-wrap">
<div class="icon"><span class="ion-ios-arrow-down"></span></div>
<select name="board" id="" class="form-control">
<option value="text" style="color:black" > Board</option>
<option value="text" style="color:black" >CBSE</option>
<option value="text" style="color:black" >CHSE(STATE)</option>
<option value="text" style="color:black" >ICSE</option>
</select>
</div>
</div>
</div>
<div class="form-group">
<div class="form-field">
<div class="select-wrap">
<div class="icon"><span class="ion-ios-arrow-down"></span></div>
<select name="class" id="" class="form-control">
<option value="text" style="color:black" > Class</option>
<option value="text" style="color:black" >VI</option>
<option value="text" style="color:black" >VII</option>
<option value="text" style="color:black" >VIII</option>
<option value="text" style="color:black" >IX</option>
<option value="text" style="color:black" >X</option>
<option value="text" style="color:black" >XI</option>
<option value="text" style="color:black" >XII</option>
<option value="text" style="color:black" >XIII</option>
<option value="text" style="color:black" >Others</option>
</select>
</div>
</div>
</div>
</div>
<div class="d-md-flex">
<div class="form-group">
<textarea name="address" id="" cols="30" rows="2" class="form-control" placeholder="Address"></textarea>
</div>
<div class="form-group ml-md-4">
<input type="tel" name="phone" class="form-control" placeholder="Phone">
</div>
<div class="form-group ml-md-4">
<input type="submit" value="Request A Quote" class="btn btn-secondary py-3 px-4">
</div>
</div>
</form>
so here is my PHP file i.e, index_handler.php
<?php
if(isset($_POST['submit'])){
$name=$_POST['name'];
$email=$_POST['email'];
$m_name=$_POST['m_name'];
$course=$_POST['course'];
$board=$_POST['board'];
$class=$_POST['class'];
$address=$_POST['address'];
$phone=$_POST['phone'];
$to='rajkishore.panda2000#gmail.com';
$subject='Form Submission';
$message="Name :".$name."\n"."Mother's Name :".$m_name."\n"."Course :".$course."\n"."Board :".$board."\n"."Class :".$class."\n"."Phone :".$phone."\n"."Address:"."\n\n".$address;
$headers="From: ".$email;
if(mail($to, $subject, $message, $headers)){
echo "<h1>Sent Successfully! Thank you"." ".$name.", We will contact you shortly!</h1>";
}
else{
echo "<h1>Something went wrong!</h1>";
}
}
?>
You need give submit button name, because your php is
isset($_POST['submit'])
to fix your problem, change your code
<input type="submit" value="Request A Quote" class="btn btn-secondary py-3 px-4">
to
<input type="submit" name="submit" value="Request A Quote" class="btn btn-secondary py-3 px-4">
Hey just Add name="submit" and that's it
change this code
<div class="form-group ml-md-4">
<input type="submit" value="Request A Quote" class="btn btn-secondary py-3 px-4">
</div>
To be
<div class="form-group ml-md-4">
<input type="submit" name="submit" value="Request A Quote" class="btn btn-secondary py-3 px-4">
</div>
I have been trying to process the inputs of a web form which submits to itself. Everything works fine except for chrome android browser. The code works well when accessed through browsers on PC and other mobile browsers like UC Browser. But miserably fails in chrome android. The submit button and "post" requests are not set on the first run. And more strangely the same code works on same chrome browser when reloaded. help will be greatly appreciated.
This is the code supposed to catch the values submitted
?php
require_once('connect_db.php');
require_once('functions.php');
$timezone = "Asia/Kolkata";
date_default_timezone_set($timezone);
if($_SERVER['REQUEST_METHOD'] == 'POST') {
$name = $mysqli->real_escape_string($_REQUEST['name']);
$gender = $mysqli->real_escape_string($_REQUEST['gender']);
$dob = $mysqli->real_escape_string($_REQUEST['dob']);
// And Some more Variables managed here
}
?>
And here is the html form part
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" data-toggle="validator">
<div class="form-group">
<label for="name" class="control-label">Name:</label>
<input class="form-control" onfocusout="this.value = this.value.toUpperCase();" autofocus="autofocus" id="name" placeholder="Name" data-error="Enter Your Name" name="name" required="" type="text">
<div class="help-block with-errors"></div>
</div>
<div class="form-group w3ls-opt">
<label for="Gender" class="control-label">Gender</label> <label class="w3layouts"> <input name="gender" id="gender1" value="male" checked="checked" type="radio">Male
</label> <label class="w3layouts label2"> <input name="gender" id="gender2" value="female" type="radio">Female </label> <label class="w3layouts"> <input name="gender" id="gender3" value="other" type="radio">Other
</label>
<div class="help-block with-errors"></div>
</div>
<div class="form-group">
<label for="dob" class="control-label">Date of Birth</label>
<input class="form-control" id="dob" placeholder="dd/mm/yyyy" name="dob" required="" max="31/05/1995" data-error="Enter Your Date of Birth in dd/mm/yyyy format" type="text" pattern="\d{1,2}/\d{1,2}/\d{4}">
<div class="help-block with-errors"></div>
</div>
<div class="form-group">
<label for="inputEmail" class="control-label">Email:</label> <input class="form-control" style="text-transform:lowercase" id="inputEmail" placeholder="Email" data-error="Enter a valid Email" name="email" required="" type="email">
<div class="help-block with-errors"></div>
</div>
<div class="form-group">
<label for="parent" class="control-label">Name
of Father/Parent/Guardian/Husband</label> <input class="form-control" id="father" placeholder="Name of Father" name="father" onfocusout="this.value = this.value.toUpperCase();" required="" data-error="Enter Your Parent's Name" type="text">
<div class="help-block with-errors"></div>
</div>
<div class="form-group">
<label for="mother" class="control-label">Name
of Mother</label> <input class="form-control" onfocusout="this.value = this.value.toUpperCase();" id="mother" placeholder="Name of Mother" name="mother" required="" data-error="Enter Your Mother's Name" type="text">
<div class="help-block with-errors"></div>
</div>
<div class="form-group">
<label class="control-label" for="address1">Address</label>
<textarea class="form-control" rows="3" id="address1" onfocusout="this.value = this.value.toUpperCase();" name="address1" data-error="Enter Address" required=""></textarea>
<div class="help-block with-errors"></div>
</div>
<div class="form-group"> <label class="control-label" for="address2">Address</label>
<textarea class="form-control" rows="3" id="address2" onfocusout="this.value = this.value.toUpperCase();" name="address2" data-error="Enter Address" required="" readonly="readonly">
OTTATHARA
KODUP PO
PIN:676504</textarea>
</div>
<div class="form-group">
<label for="Phone" class="control-label">Phone:</label> <input class="form-control" name="phone" id="Phone" placeholder="Phone" data-error="Enter a valid Phone Number" required="" min="0000000000" max="99999999999" type="number">
<div class="help-block with-errors"></div>
</div>
<div class="form-group">
<label class="control-label" for="address">Course
Presently Studying</label>
<select class="form-control" id="course" name="course" required="">
<option value="" selected="selected">Select</option>
<option value="hsc">+2</option>
<option value="vhsc">VHSC</option>
<option value="diploma">Diploma</option>
<option value="graduation">Graduation</option>
<option value="professional">Professional Degree</option>
<option value="bed">B.Ed</option>
<option value="pg">Postgraduation</option>
<option value="mphil">M Phil</option>
<option value="research">Research</option>
<option value="certificate">Certificate Course</option>
<option value="others">Others</option>
</select>
<div class="help-block with-errors"></div>
</div>
<div class="form-group">
<label for="course_details" class="control-label">Deatils of Course(Group/Main/Branch):</label> <input class="form-control" onfocusout="this.value = this.value.toUpperCase();" placeholder="Course Details" name="course_details" id="course_details" required="" type="text">
<div class="help-block with-errors" required=""></div>
</div>
<div class="form-group">
<label for="institution" class="control-label">Name of Institution:</label> <input class="form-control" onfocusout="this.value = this.value.toUpperCase();" id="institution" placeholder="Institution" name="institution" required="" type="text">
<div class="help-block with-errors"></div>
</div>
<div class="form-group">
<label class="control-label" for="duration_year">Course Duration(Year)</label>
<select class="form-control" id="duration_year" name="duration_year">
<option value="" selected="selected">Select</option>
<option value="0">0</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
</select>
<div class="help-block with-errors"></div>
</div>
<div class="form-group">
<label class="control-label" for="duration_year">Course Duration(Month)</label>
<select class="form-control" id="duration_month" name="duration_month">
<option value="" selected="selected">Select</option>
<option value="0">0</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
<option value="11">11</option>
</select>
<div class="help-block with-errors"></div>
</div>
<div class="form-group">
<label class="control-label" for="financial status">Financial Status</label>
<select class="form-control" id="finance" name="finance">
<option value="" selected="selected">Select</option>
<option value="apl">APL</option>
<option value="bpl">BPL</option>
<option value="finance_not_say">Prefer not to Specify</option>
</select>
<div class="help-block with-errors"></div>
</div>
<div class="form-group">
<label class="control-label" for="if_working">Are you Working Now?</label>
<select class="form-control" id="if_working" name="if_working" required="" onchange="change_work_option(this)">
<option value="" selected="selected">Select</option>
<option value="yes">Yes</option>
<option value="no">No</option>
</select>
<div class="help-block with-errors"></div>
</div>
<div class="form-group">
<label class="control-label" for="working_type">If working, details of employment</label>
<select class="form-control" id="working_type" name="working_type" disabled>
<option value="select" selected="selected">Select</option>
<option value="government">Government</option>
<option value="private">Private</option>
<option value="self employed">Self Employed</option>
<option value="others">Others</option>
</select>
<div class="help-block with-errors"></div>
</div>
<div class="form-group"> <label for="interest" class="control-label">Interests</label> <input onfocusout="this.value = this.value.toUpperCase();" class="form-control" id="interests" placeholder="Interests" name="interest" type="text"> </div>
<div class="form-group"> <label for="aspiration" class="control-label">Career Aspirations</label> <input onfocusout="this.value = this.value.toUpperCase();" class="form-control" id="aspiration" placeholder="Aspiration" name="aspiration" type="text"> </div>
<div class="form-group"> <input class="btn btn-primary btn-lg btn-block" id ="submit" name="submit" value="submit" type="submit">
</div>
</form>
Edited..
After posting above question I have been making a number of trail and errors and found that error is not with my form or code. Even so simple a form like given below fails. But when I reload it works..I read something about a bug in Chrome. Any solution or hack?
here is the simple form i tried in vain last
<html><body>
<?php echo $_POST["name"]." echoing"; ?>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" name="student_form" method="post" accept-charset="utf-8">
<input type="text" name="name" />
<input type="submit">
</form>
</body>
Thank you for your support. This is not exactly an answer to the cause of the issue, but simply how I managed to get out of it and set my form working. :)
As U guys pointed out, it should nt be a bug in chrome android( it could be more disastrous in that case). And when I tried many "deductive" debugging and trial and error I found something which may lead to clutch to the root of the error.
1. It works fine when I tested on another web host
2. In my erroneous host cum browser, when the form is submitted the url returned carries a strange get parameter Www.xxxx.com/?i=1
Since I had to solve the problem immediately, I manned a function in the controller file to reload the uri if the browser is android chrome and it is tab is "fresh" using
isset($_SERVER['HTTP_CACHE_CONTROL']) &&
($_SERVER['HTTP_CACHE_CONTROL'] === 'max-age=0' || $_SERVER['HTTP_CACHE_CONTROL'] == 'no-cache')
and it worked. But would be glad to know any insights u could share
Below is the code I'm using for my form. At the moment, when the form is submitted the message is shown on a separate page. I just want a message above the current form as appose to on a new page.
<div class="main_box">
<div class="clear"></div>
<div class="clear"></div>
<?php
$action=$_REQUEST['action'];
if ($action=="") /* display the contact form */
{
?>
<form action="" method="POST" enctype="multipart/form-data">
<input type="hidden" name="action" value="submit">
<div class="main_col">
<div class="main_col_left"><strong>BUSINESS NAME:</strong></div>
<div class="main_col_right">
<input type="text" name="business" id="business" value="" />
</div>
</div>
<div class="main_col">
<div class="main_col_left"><strong>EMAIL ADDRESS:</strong></div>
<div class="main_col_right">
<input type="text" name="email" id="email" value="" />
</div>
</div>
<div class="main_col">
<div class="main_col_left"><strong>PROPERTY PURCHASE PRICE:</strong><span><strong>£</strong></span></div>
<div class="main_col_right">
<input type="text" name="pur_price" id="pur_price" value="" />
</div>
</div>
<div class="main_col">
<div class="main_col_left"><strong>REFURB COST:</strong><span><strong>£</strong></span></div>
<div class="main_col_right">
<input type="text" name="refurb" id="refurb" value="" />
</div>
</div>
<div class="main_col">
<div class="main_col_left"><strong>Property Type :</strong></div>
<div class="main_col_right">
<select name="select2" id="select2" onchange="propType(this.value);">
<option value="">Select Property Type</option>
<option value="0.3">Car Showroom</option>
<option value="0.4">Care/Nursing Home</option>
<option value="0.25">Dental Surgery</option>
<option value="0.3">Department Store</option>
<option value="0.3">Distribution Centre</option>
<option value="0.3">FHL Apartment</option>
<option value="0.3">FHL House</option>
<option value="0.3">FHL Villa</option>
<option value="0.3">Hotel/B&B </option>
<option value="0.25">Industrial</option>
<option value="0.3">Industrial with Office</option>
<option value="0.3">Medical Centre</option>
<option value="0.25">Multi-Storey Car Park</option>
<option value="0.35">Nursery</option>
<option value="0.25">Office</option>
<option value="0.25">Office with Residential</option>
<option value="0.3">Petrol Station</option>
<option value="0.3">Public House</option>
<option value="0.3">Research Facility</option>
<option value="0.3">Restaurant</option>
<option value="0.25">Retail Warehouse</option>
<option value="0.3">Retail Shop</option>
<option value="0.3">Retail Shop & Office</option>
<option value="0.3">Shopping Centre</option>
<option value="0.3">Sports Centres</option>
<option value="0.3">Students Residence</option>
<option value="0.3">Theatre</option>
<option value="0.3">OTHER</option>
</select>
</div>
</div>
<div class="main_col" style="display:none">
<div class="main_col_left"><strong>AVERAGE CLAIM RATE :</strong><span><strong>£</strong></span></div>
<div class="main_col_right">
<input type="text" name="avg_claim_rate" id="avg_claim_rate" value="" />
</div>
</div>
<div class="main_col">
<div class="main_col_left"><strong>AMOUNT CLAIMABLE :</strong><span><strong>£</strong></span></div>
<div class="main_col_right">
<input type="text" name="amount_claim" id="amount_claim" value="" />
</div>
</div>
<div class="main_col">
<div class="main_col_left"><strong> YOUR TAX RATE :</strong></div>
<div class="main_col_right">
<select name="tax_rate" id="tax_rate">
<option value=".24">24%</option>
<option value=".4">40%</option>
</select>
</div>
</div>
<div class="clear"></div>
<hr />
<div class="clear"></div>
<div class="main_col">
<div class="main_col_left"><strong>CLIENT TAX BENEFIT :</strong><span><strong>£</strong></span></div>
<div class="main_col_right"><input type="text" name="client_benefit" id="client_benefit" value="" /></div>
</div>
<div class="main_col">
<div class="main_col_left"><strong>INSTANT CASH RECLAIM:</strong><span><strong>£</strong></span></div>
<div class="main_col_right"><input type="text" name="cash_reclaim" id="cash_reclaim" value="" /></div>
</div>
<div class="main_col">
<div class="main_col_left"><strong>FUTURE TAX RELIEF :</strong><span><strong>£</strong></span></div>
<div class="main_col_right"><!--<span id="future_tax_rel"></span>--> <input type="text" name="future_tax_rel" id="future_tax_rel" value="" /></div>
</div>
<div class="clear"></div>
<hr />
<div class="clear"></div>
<p style="line-height:20px;">Note : These figures are estimates and the final figures may very depending upon the property and full circusstances</p>
<div class="clear"></div>
<div class="clear"></div>
<div class="main_col">
<div class="main_col_left"> </div>
<div class="main_col_right">
<button onclick="calculate();">Calculate</button>
</div>
</div>
</form>
<?php
}
else /* send the submitted data */
{
$name=$_REQUEST['business'];
$email=$_REQUEST['email'];
$pur_price=$_REQUEST['pur_price'];
$refurb=$_REQUEST['refurb'];
$select2=$_REQUEST['select2'];
$select=$_REQUEST['select'];
if (($name=="")||($email==""))
{
echo "Please enter business name & email";
}
else{
$from="Business : $name\r\nEmail : $email\r\nPurchase Price : $pur_price\r\nRefurb Cost : $refurb";
$subject="CTA Associates Calculator ";
mail("test#test.com", $subject, $from);
}
}
?>
<button onclick="reset();">Reset</button>
<div class="clear"></div>
<div class="clear"></div>
</div>
you can use something like this
<?php
if(isset($_GET['status']))
echo "success";
?>
end in the end of your code add header('Location:page.php?status')
Currently I have created a form on a PHP form that posts to the send PHP code. All of the textareas/fields ETC work fine. The issue I have is that I have 3 file fields. The aim is to add 3 file attachments to the email. I just cant work out how to do it.
(Attachment areas at the bottom of the form)
<form method="post" action="quote_send.php">
<form class="form-light mt-20" role="form">
<div class="form-group">
<label>Title</label><br />
<select name="Title">
<option value="Mr">Mr</option>
<option value="Mrs">Mrs</option>
<option value="Miss">Miss</option>
<option value="Ms">Ms</option>
</select>
</div> <div class="row">
<div class="col-md-6">
<div class="form-group">
<label>Forename</label>
<input type="text" class="form-control" name="forename" placeholder="Your Forename">
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label>Surname</label>
<input type="text" class="form-control" name="surname" placeholder="Your Surname">
</div>
</div>
</div>
<!----CONTACT DETAILS------>
<h3>Your Contact Details</h3>
<div class="row">
<div class="col-md-6">
<div class="form-group">
<label>Email Address</label>
<input type="text" class="form-control" name="visitormail" placeholder="Your Email Address">
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label>Contact Number</label>
<input type="text" class="form-control" name="number" placeholder="Your Contact Number">
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label>Address Line 1</label>
<input type="text" class="form-control" name="address1" placeholder="Address Line 1">
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label>Address Line 2</label>
<input type="text" class="form-control" name="address2" placeholder="Address Line 2">
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label>City</label>
<input type="text" class="form-control" name="city" placeholder="City">
</div>
</div>
<div class="col-md-2">
<div class="form-group">
<label>Post Code</label>
<input type="text" class="form-control" name="pcode" placeholder="Post Code">
</div>
</div>
</div>
<!----SITE DETAILS----->
<h3>Site Contact Details</h3>
<div class="form-group">
<label>Title</label><br />
<select name="siteTitle">
<option value="Mr">Mr</option>
<option value="Mrs">Mrs</option>
<option value="Miss">Miss</option>
<option value="Ms">Ms</option>
</select>
</div>
<div class="row">
<div class="col-md-6">
<div class="form-group">
<label>Site Contact Forename</label>
<input type="text" class="form-control" name="scforename" placeholder="Site Contact Forename">
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label>Site Contact Surname</label>
<input type="text" class="form-control" name="scsurname" placeholder="Site Contact Surname">
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label>Email Address</label>
<input type="text" class="form-control" name="scvisitormail" placeholder="Site Email Address">
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label>Contact Number</label>
<input type="text" class="form-control" name="scnumber" placeholder="Site Contact Number">
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label>Address Line 1</label>
<input type="text" class="form-control" name="scaddress1" placeholder="Site Address Line 1">
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label>Address Line 2</label>
<input type="text" class="form-control" name="scaddress2" placeholder="Site Address Line 2">
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label>City</label>
<input type="text" class="form-control" name="sccity" placeholder="City">
</div>
</div>
<div class="col-md-2">
<div class="form-group">
<label>Post Code</label>
<input type="text" class="form-control" name="scpcode" placeholder="Post Code">
</div>
</div>
</div>
<!----SITE DETAILS----->
<h3>Site Details</h3>
<div class="row">
<div class="col-md-2">
<div class="form-group">
<label>Number of Domestic Plots</label><br />
<select name="numdp">
<option value="0">0</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5+">5+</option>
</select></div></div>
<div class="col-md-2">
<div class="form-group">
<label>Number of Commercial Plots</label><br />
<select name="numcp">
<option value="0">0</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5+">5+</option>
</select>
</div></div>
<div class="col-md-2">
<div class="form-group">
<label>Is The Site Visit Required?</label><br />
<select name="sitevisitr">
<option value="Yes">Yes</option>
<option value="No">No</option>
</select>
</div></div>
<div class="col-md-3">
<div class="form-group">
<label>Is The Site a Brownfield/Regeneration?</label><br />
<select name="brownregen">
<option value="Brownfield">Brownfield</option>
<option value="Regeneration">Regeneration</option>
</select>
</div></div>
<div class="col-md-3">
<div class="form-group">
<label>Is The Site Contaminated?</label><br />
<select name="contam">
<option value="Yes">Yes</option>
<option value="No">No</option>
</select>
</div></div>
<div class="col-md-2">
<div class="form-group">
<label>Property Type</label><br />
<select name="proptype">
<option value="Commercial">Commercial</option>
<option value="Flat">Flat</option>
<option value="Detached">Detached</option>
<option value="Semi-Detached">Semi-Detached</option>
<option value="Terraced">Terraced</option>
</select>
</div></div>
<div class="col-md-2">
<div class="form-group">
<label>Rooms In The Property</label><br />
<select name="nrooms">
<option value="N/A">N/A</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10+">10+</option>
</select>
</div></div>
<div class="col-md-2">
<div class="form-group">
<label>Do You Have A Gas Supplier? *</label><br />
<select name="gsupplier">
<option value="Yes">Yes</option>
<option value="No">No</option>
</select>
</div></div>
<div class="col-md-3">
<div class="form-group">
<label>If Yes. Who Is Your Gas Supplier?</label>
<input type="text" class="form-control" name="gsuppliername" placeholder="Gas Supplier">
</div>
</div>
<div class="col-md-3">
<div class="form-group">
<label>Who Will Be Carrying Out The Excavation?</label><br />
<select name="erxcav">
<option value="MDL">MDL</option>
<option value="Customer">Customer</option>
</select>
</div></div>
<br /><p> * NOTE: If you do not have a gas supplier in place, you will need to obtain one before any works can be carried out. You can find a gas supplier here.</p>
<div class="col-md-2">
<div class="form-group">
<label>What Service Do You Require?</label><br />
<select name="servicer">
<option value="Gas Connection(s)">Gas Connection(s)</option>
<option value="Gas Disconnection(s)">Gas Disconnection(s)</option>
<option value="Meter Fitting / Exchange">Meter Fitting / Exchange</option>
<option value="Directional Drilling">Directional Drilling</option>
<option value="Outlet Pipework">Outlet Pipework</option>
</select>
</div></div>
<div class="col-md-3">
<div class="form-group">
<label>What Is Your Hourly Load? (KWh)</label>
<input type="text" class="form-control" name="hourl" placeholder="Hourly Load (KWh)">
</div>
</div>
<div class="col-md-3">
<div class="form-group">
<label>What Is Your Annual Load? (KWh)</label>
<input type="text" class="form-control" name="annl" placeholder="Annual Load? (KWh)">
</div>
</div> <br /><br /><br /><br />
<p> * NOTE: We require specific documents so we can proceed with your quote. These documents can be seen in the upload section below</p>
<div class="col-md-4">
<div class="form-group">
<label>Scaled Site Location Plan</label>
<input name="sslp" type="file">
</div></div>
<div class="col-md-4">
<div class="form-group">
<label>Domestic Property Schedule</label>
<input name="dps" type="file">
</div></div>
<div class="col-md-4">
<div class="form-group">
<label>Site Boundary Drawing</label>
<input name="sbd" type="file">
</div></div>
<p> * NOTE: We require specific documents so we can proceed with your quote. These documents can be seen in the upload section below</p>
<div class="col-md-6">
<div class="form-group">
<label>Is There Any Other Information You Think Would Help Us?</label><br />
<textarea class="form-control" name="notes" placeholder="Write you message here..." style="height:100px;"></textarea>
</div></div>
</div>
<br / >
<button type="submit" class="btn btn-two">SUBMIT</button>
</form>
THE PHP send code.-----------------------
<?php
$Title = $_POST['Title'];
$forename = $_POST['forename'];
$surname = $_POST['surname'];
$visitormail = $_POST['visitormail'];
$number = $_POST['number'];
$address1 = $_POST['address1'];
$address2 = $_POST['address2'];
$city = $_POST['city'];
$pcode = $_POST['pcode'];
$siteTitle = $_POST['siteTitle'];
$scforename = $_POST['scforename'];
$scsurname = $_POST['scsurname'];
$scvisitormail = $_POST['scvisitormail'];
$scnumber = $_POST['scnumber'];
$scaddress1 = $_POST['scaddress1'];
$scaddress2 = $_POST['scaddress2'];
$sccity = $_POST['sccity'];
$scpcode = $_POST['scpcode'];
$numdp = $_POST['numdp'];
$numcp = $_POST['numcp'];
$sitevisitr = $_POST['sitevisitr'];
$brownregen = $_POST['brownregen'];
$contam = $_POST['contam'];
$proptype = $_POST['proptype'];
$nrooms = $_POST['nrooms'];
$gsupplier = $_POST['gsupplier'];
$gsuppliername = $_POST['gsuppliername'];
$erxcav = $_POST['erxcav'];
$servicer = $_POST['servicer'];
$hourl = $_POST['hourl'];
$annl = $_POST['annl'];
$notes = $_POST['notes'];
$attn = $_POST['attn'];
$sslp = $_POST['sslp'];
$dps = $_POST['dps'];
$sbd = $_FILES['sbd'];
if (eregi('http:', $notes)) {
die ("Do NOT try that! ! ");
}
if(!$visitormail == "" && (!strstr($visitormail,"#") || !strstr($visitormail,".")))
{
echo "<h2>Use Back - Enter valid e-mail</h2>\n";
$badinput = "<h2>Feedback was NOT submitted</h2>\n";
echo $badinput;
die ("Go back! ! ");
}
if(empty($forename) || empty($visitormail) || empty($notes )) {
echo "<h2>You have missed out required fields, please go back to them and fill them in</h2>\n";
die ("Use back! ! ");
}
$todayis = date("l, F j, Y, g:i a") ;
$attn = $attn ;
$subject = "New $servicer Quote Request";
$notes = stripcslashes($notes);
$message = "Section 1 - Customer Details \n
Customer Title: $Title
Customer Forname: $forename
Customer Surname: $surname
Customer Email: $visitormail
Customer Contact Number: $number
Contact Postal Address:\n $address1 \n $address2 \n $city \n $pcode \n
Section 2 - Site Contact Details \n
Site Contact Title: $siteTitle
Site Contact Forname: $scforename
Site Contact Surname: $scsurname
Site Contact Email Address: $scvisitormail
Site Contact Number: $scnumber
Site Current Postal Address:\n $scaddress1 \n $scaddress2 \n $sccity \n $scpcode \n
Section 3 - Site Work Details \n
Number of Domestic Plots: $numdp
Number of Commercial Plots: $numcp
Site Visit Required: $sitevisitr
Site a Brownfield/Regeneration: $brownregen
Site Contaminated: $contam
Property Type: $proptype
Number of Rooms in The Property: $nrooms
Gas Supplier Organised: $gsupplier
Gas Supplier Name: $gsuppliername
Who Will Be Carrying Out The Excavation: $erxcav
Service Rquired: $servicer
Hourly Load: $hourl
Annual Load: $annl
Extra Information: $notes
Attached Files: $sslp \n $dps \n $sbd
Please reply to this email within 24 hours to maximise our chances of turning enquiries in to sales.
";
$_FILES ="$sbd";
$from = "From: $visitormail\r\n";
mail("ash.manterfield#btinternet.com", $subject, $message, $from, $_FILES);
?>
</span>Thank you <?php echo $visitor ?> for contacting us regarding <?php echo $attn ?>.
Any help would be appreciated I've tried a few approaches and cant work out how to do it.