PHP email from submit and stay on page - php

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')

Related

Calling POST data from a PHP file

I have 3 php files and I want to get the month from form1.php for form3.php but the thing is, it needs to be processed in form2.php as well, how can I just get the month from form1 and display it in form3?
form1.php
<form action="form2.php" method="post">
<div class="form-title">
<p class="display-6">Salary Calculator (Part 1)</p>
</div>
<div class="form-subtitle">
<p>Employee Information</p>
</div>
<div class="form-row">
<div class="form-row-child">
<label for="inputPlaceholder4">Employee Name</label>
<select class="form-select" aria-label="Default select example" name="displayName" id="displayName">
<option selected>Select Employee</option>
<?php while($row = $result->fetch_assoc()) { ?>
<option value="<?php echo $row['displayName']; ?>"><?= $row["displayName"] ?></option>
<?php }; ?>
</select>
</div>
<div class="form-row-child">
<label for="inputPlaceholder4">Month</label>
<select class="form-select" aria-label="Default select example" name="month" id="month">
<option selected disabled>Select Month</option>
<option value="January">January</option>
<option value="Febuary">Febuary</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>
</div>
</div>
<div class="form-row">
<div class="form-row-child">
<input type="submit" class="btn btn-danger form1-btn" value="Proceed">
</div>
<div class="form-row-child">
</div>
</div>
</form>
form2.php
<form action="form3.php" method="post">
<div class="form-title">
<p class="display-6">Salary Calculator (Part 2)</p>
</div>
<div class="half-form">
<div class="half-form-left">
<div class="half-form-subtitle">
<p>Holidays</p>
</div>
<div class="half-form-child">
<label for="inputPlaceholder3">Regular (Per day)</label>
<select class="form-select" aria-label="Default select example" name="holidayReg" id="holidayReg">
<?php foreach ($regHolidays as $value) { ?>
<option value="<?php echo $value; ?>"><?= $value ?></option>
<?php }; ?>
</select>
</div>
<div class="half-form-child">
<label for="inputPlaceholder3">Special (Per day)</label>
<select class="form-select" aria-label="Default select example" name="holidaySpec" id="holidaySpec">
<?php foreach ($specHolidays as $value) { ?>
<option value="<?php echo $value; ?>"><?= $value ?></option>
<?php }; ?>
</select>
</div>
</div>
<div class="half-form-right">
<div class="half-form-subtitle">
<p>Overtime</p>
</div>
<div class="half-form-child">
<label for="inputPlaceholder3">Normal (Per hour)</label>
<input type="Placeholder" class="form-control" id="overtimeHoursNormal" placeholder="Placeholder" name="overtimeHoursNormal">
</div>
<div class="half-form-child">
<label for="inputPlaceholder3">Rest Day (Per hour)</label>
<input type="Placeholder" class="form-control" id="overtimeHoursSpecial" placeholder="Placeholder" name="overtimeHoursSpecial">
</div>
</div>
</div>
<div class="half-form">
<div class="half-form-left">
<div class="half-form-subtitle">
<p>Absences</p>
</div>
<div class="half-form-child">
<label for="inputPlaceholder3">Day/s absent</label>
<input type="Placeholder" class="form-control" id="absences" placeholder="Placeholder" name="absences">
</div>
</div>
<div class="half-form-right">
<input type="Placeholder" class="form-control" id="basePay" name="basePay" style="display: none;" value="<?php echo $vagueEmployee->getBasePay(); ?>">
<input type="Placeholder" class="form-control" id="workingHours" name="workingHours" style="display: none;" value="<?php echo $vagueEmployee->getWorkingHours(); ?>">
<input type="Placeholder" class="form-control" id="salaryPerHour" name="salaryPerHour" style="display: none;" value="<?php echo $salaryPerHour; ?>">
<input type="Placeholder" class="form-control" id="payFor13thMonth" name="payFor13thMonth" style="display: none;" value="<?php echo $payFor13thMonth; ?>">
</div>
</div>
<div class="form-row">
<div class="form-row-child">
<input type="submit" class="btn btn-danger form1-btn" value="Proceed">
</div>
<div class="form-row-child">
</div>
</div>
</form>
form3.php
<main class="main">
<div class="form-title">
<p class="display-6">Employee Salary</p>
</div>
<div class="">
<p>Pay after additions: Php <?php echo $payAfterAdditions; ?></p>
<p>Deductions</p>
<p>Philhealth: Php <?php echo $philhealth; ?></p>
<p>SSS: Php <?php echo $sss; ?></p>
<p>Total deductions: Php <?php echo $totalDeductions; ?></p>
<p>Taxable Salary: Php <?php echo $taxableSalary; ?></p>
<p>Final Salary: Php <?php echo $finalTax; ?></p>
<!-- lalabas lang kapag december -->
<p>13 month pay: </p>
<p> <?php echo $totalAbsences; ?></p>
<p> <?php echo $basePay; ?></p>
</div>
</main>
In form 2
Add the following field inside the form
<input type=hidden name=month value="<?php echo $_POST["month"]; ?>">
Then in form 3, you can use $_POST["month"] to access the month value.

How to use Cron job to delay variables that will be posted into the Database for some minute

I have a form in my laravel script, I want to know how to use cron job to delay the form once it is submitted. I want it to make it submit to the database after Five minutes.
Here is the HTML code to the form, I want it to post to the cron jobs first before it is sent to the database after 5 minutes.
<html>
<form method="post" action="{{action('SomeController#withdrawal')}}">
<!--............................... collapse one -->
<div class="card">
<div class="card-header bg-{{$bgmenu}}" id="headingOne" data-toggle="collapse" data-target="#collapseOne" aria-expanded="true" aria-controls="collapseOne">
<div class="span-icon">
<div class="fa fa-clone"> Trade</div>
</div>
<div class="span-mode"></div>
</div>
<div id="collapseOne" class="collapse show" aria-labelledby="headingOne" data-parent="#accordion">
<div class="card-body bg-{{$bg}} shadow">
<div class="form-group">
<h5 class="text-{{$text}}">Symbol</h5>
<select type="text" id="symbol" name="symbol" placeholder="Symbol" required>
<option value="BCH/BTC">BCH/BTC</option>
<option value="XLM/USD">XLM/USD</option>
<option value="XRP/BTC">XRP/BTC</option>
<option value="XRP/EUR">XRP/EUR</option>
<option value="XRP/USD">XRP/USD</option>
<option value="ZEC/BTC">ZEC/BTC</option>
<option value="ZRX/BTC">ZRX/BTC</option>
<option value="ZRX/EUR">ZRX/EUR</option>
<option value="ZRX/USD">ZRX/USD</option>
</select>
</div>
<div class="form-group">
<h5 class="text-{{$text}}">Interval</h5>
<select type="text" id="time" name="time" value="{{Auth::user()->intv}}" class="form-control text-{{$text}} bg-{{$bg}}" placeholder="Interval" required>
<option value="1-Minute">1 min</option>
<option value="3-Minutes">3 min</option>
<option value="5-Minutes">5 min</option>
<option value="15-Minutes">15 min</option>
</select>
</div>
<div class="form-group">
<h5 class="text-{{$text}}">Amount</h5>
<input type="text" value="{{Auth::user()->buy}}" class="form-control text-{{$text}} bg-{{$bg}}" placeholder="100.00" name="amount" required>
</div>
<div class="form-group">
<h5 class="text-{{$text}}">Strike Rate</h5>
<select type="text" id="trade" name="trade" class="form-control text-{{$text}} bg-{{$bg}}" placeholder="Interval" required>
<option>Choose One....</option>
<option value="High_Sell">High Sell</option>
<option value="Highest_Sell">Highest Sell</option>
</select>
</div>
</div>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
</html>

Where does this form redirect?

I am new to posting on this site and PHP...I am trying to jump in on this site and make some updates. I don't see any redirect after the form is submitted. I was going to add an action, but don't want to cause and error. Can someone please lead me in the right direction. Any help is appreciated. Here is the code:
<!DOCTYPE html>
<html lang="en">
<head>
<?php $this->load->view('includes/meta'); ?>
<script>
function varifyForm(){
if(document.getElementById('terms').checked == false){
alert('Please Accept Terms and Conditions');
return false;
}else if(document.getElementById('privacy').checked == false){
alert('Please Accept Privacy Policy');
return false;
}else{
return true;
}
}
</script>
</head>
<body>
<!--------------------------------HEADER------------------------------------------->
<?php $this->load->view('includes/header'); ?>
<!--------------------------------HEADER------------------------------------------->
<!--------------------------------BODY------------------------------------------->
<div class="body">
<div class="container">
<div class="full" style="margin:15px 0;">
<h2 align="center">Registration – Member</h2>
<div class="col-md-12">
<form method="post" class="col-md-6 col-md-offset-3" onSubmit="return varifyForm()">
<?php
if( $this->session->flashdata('error_msg') != ''){
?>
<p style="font-weight:bold; color:#F00;"><?php echo $this->session->flashdata('error_msg'); ?></p>
<?php
}
?>
<?php
if( $this->session->flashdata('success_msg') != ''){
?>
<p style="font-weight:bold; color:#0F0;"><?php echo $this->session->flashdata('success_msg'); ?></p>
<?php
}
?>
<div class="row">
<div class="col-sm-4">
<div class="form-group">
<label for="">First Name:</label>
<input type="text" class="form-control" id="" name="terms[first_name]" value="<?php if($this->session->flashdata('first_name') != ''){ _e($this->session->flashdata('first_name')); } ?>" required>
</div>
</div>
<div class="col-sm-4">
<div class="form-group">
<label for="">Last Name:</label>
<input type="text" class="form-control" id="" name="terms[last_name]" value="<?php if($this->session->flashdata('last_name') != ''){ _e($this->session->flashdata('last_name')); } ?>" required>
</div>
</div>
<div class="col-md-4">
<div class="form-group">
<label for="">Cell Phone No:</label>
<input type="tel" class="form-control" id="" name="terms[phone_no]" value="<?php if($this->session->flashdata('phone_no') != ''){ _e($this->session->flashdata('phone_no')); } ?>" required>
</div>
</div>
</div>
<div class="row">
<div class="col-sm-4">
<div class="form-group">
<label for="">Email:</label>
<input type="email" class="form-control" id="" name="terms[email]" value="<?php if($this->session->flashdata('email') != ''){ _e($this->session->flashdata('email')); } ?>" required>
</div>
</div>
<div class="col-sm-4">
<div class="form-group">
<label for="">Password:</label>
<input type="password" class="form-control" id="" name="password" value="" required>
</div>
</div>
<div class="col-sm-4">
<div class="form-group">
<label for="">Confirm Password:</label>
<input type="password" class="form-control" id="" name="confirm_password" value="" required>
</div>
</div>
</div>
<div class="row">
<div class="col-sm-4">
<div class="form-group">
<label for="">Address:</label>
<textarea class="form-control" name="terms[address]"><?php if($this->session->flashdata('address') != ''){ _e($this->session->flashdata('address')); } ?></textarea>
</div>
</div>
<div class="col-sm-4">
<div class="form-group">
<label for="">City:</label>
<input type="text" class="form-control" id="" name="terms[city]" value="<?php if($this->session->flashdata('city') != ''){ _e($this->session->flashdata('city')); } ?>" required>
</div>
</div>
<div class="col-sm-4">
<div class="form-group">
<label for="">State:</label>
<select name="terms[state]" class="form-control" >
<option value="" selected="selected">State / Province</option>
<option value="Alabama">Alabama</option>
<option value="Alaska">Alaska</option>
<option value="Arizona">Arizona</option>
<option value="Arkansas">Arkansas</option>
<option value="California">California</option>
<option value="Colorado">Colorado</option>
<option value="Connecticut">Connecticut</option>
<option value="Delaware">Delaware</option>
<option value="District of Columbia">District of Columbia</option>
<option value="Florida">Florida</option>
<option value="Georgia">Georgia</option>
<option value="Hawaii">Hawaii</option>
<option value="Idaho">Idaho</option>
<option value="Illinois">Illinois</option>
<option value="Indiana">Indiana</option>
<option value="Iowa">Iowa</option>
<option value="Kansas">Kansas</option>
<option value="Kentucky">Kentucky</option>
<option value="Louisiana">Louisiana</option>
<option value="Maine">Maine</option>
<option value="Maryland">Maryland</option>
<option value="Massachusetts">Massachusetts</option>
<option value="Michigan">Michigan</option>
<option value="Minnesota">Minnesota</option>
<option value="Mississippi">Mississippi</option>
<option value="Missouri">Missouri</option>
<option value="Montana">Montana</option>
<option value="Nebraska">Nebraska</option>
<option value="Nevada">Nevada</option>
<option value="New Hampshire">New Hampshire</option>
<option value="New Jersey">New Jersey</option>
<option value="New Mexico">New Mexico</option>
<option value="New York">New York</option>
<option value="North Carolina">North Carolina</option>
<option value="North Dakota">North Dakota</option>
<option value="Ohio">Ohio</option>
<option value="Oklahoma">Oklahoma</option>
<option value="Oregon">Oregon</option>
<option value="Pennsylvania">Pennsylvania</option>
<option value="Rhode Island">Rhode Island</option>
<option value="South Carolina">South Carolina</option>
<option value="South Dakota">South Dakota</option>
<option value="Tennessee">Tennessee</option>
<option value="Texas">Texas</option>
<option value="Utah">Utah</option>
<option value="Vermont">Vermont</option>
<option value="Virginia">Virginia</option>
<option value="Washington">Washington</option>
<option value="West Virginia">West Virginia</option>
<option value="Wisconsin">Wisconsin</option>
<option value="Wyoming">Wyoming</option>
<option value="Armed Forces Americas">Armed Forces Americas</option>
<option value="Armed Forces Europe">Armed Forces Europe</option>
<option value="Armed Forces Pacific">Armed Forces Pacific</option>
</select>
</div>
</div>
</div>
<div class="row">
<div class="col-sm-4">
<div class="form-group">
<label for="">Zip Code:</label>
<input type="text" class="form-control" id="" name="terms[zip]" value="<?php if($this->session->flashdata('zip') != ''){ _e($this->session->flashdata('zip')); } ?>" required>
</div>
</div>
<div class="col-sm-4">
<div class="form-group">
<label for="">Your Cause:</label>
<select name="terms[cause]" class="form-control" required>
<option value="">Select A User</option>
<?php
foreach($causes as $value){
$cause_name = $value['nonprofit_name'];
?>
<option value="<?php _e($value['user_id']); ?>" <?php if($this->session->flashdata('cause') != '' AND $this->session->flashdata('cause') == $value['user_id']){ ?> selected <?php } ?>><?php _e($cause_name); ?></option>
<?php
}
?>
</select>
</div>
</div>
<div class="col-md-4">
<div class="form-group">
<label for="">How did you hear about this website ?:</label>
<textarea class="form-control" name="terms[about]"><?php if($this->session->flashdata('about') != ''){ _e($this->session->flashdata('about')); } ?></textarea>
</div>
</div>
</div>
<div class="form-group">
<label for="">Terms and Conditions:</label><br>
<input type="checkbox" id="terms"> I agree to the Terms and Conditions
</div>
<div class="form-group">
<label for="">Privacy Policy:</label><br>
<input type="checkbox" id="privacy"> I agree to the Privacy Policy
</div>
<button type="submit" name="btnSignUp" value="signup" class="btn btn-primary"><p style="margin:0;">NEXT</p></button>
</form>
</div>
</div>
</div>
</div>
<!--------------------------------BODY------------------------------------------->
<!--------------------------------FOOTER------------------------------------------->
<?php $this->load->view('includes/footer'); ?>
<!--------------------------------FOOTER------------------------------------------->
<!-- container / end -->
<!--------------------------------JQUERY------------------------------------------->
<script src="<?php echo base_url(); ?>assets/js/jquery.js"></script>
<!-- Bootstrap Core JavaScript -->
<script src="<?php echo base_url(); ?>assets/js/bootstrap.min.js"></script>
<script src="<?php echo base_url(); ?>assets/js/wow.min.js"></script>
<script>
new WOW().init();
</script>
</body>
</html>

Add A File Attachment to A PHP Email Form Send

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.

Checked Checkbox Not Working?

I have an HTML form that posts to a PHP script. Everything is working except the checkbox. When it is checked, the value is not being posted.
HTML:
<input name="test" id="checkbox-02" type="checkbox" value="1" />
PHP:
if(!isset($_POST['test'])) {
$eventRepeat="No";
}
if(isset($_POST['test'])) {
$eventRepeat="Yes";
}
When this code runs, $eventRepeat always comes out as "No." I tried using the command "print_r($_POST)" and all inputs are posted except the checkbox, even when it is checked.
Any ideas what could cause this? I do have jQuery running so when it is checked two divs appear. Could that somehow be interfering? Here's the jQuery:
$(document).ready(function () {
$('#checkbox-02').change(function () {
if (!this.checked)
// ^
$('#repeatUntilDIV').fadeIn('slow');
$('#repeatFrequencyDIV').fadeIn('slow');
});
});
For reference, here is the full code:
<form class="cmxform form-horizontal tasi-form" id="commentForm" role="form" action="" method="post">
<div class="form-group">
<label for="inputEventTitle" class="col-lg-2 control-label">Event Title</label>
<div class="col-lg-10">
<input type="text" class="form-control" id="inputEventTitle" name="inputEventTitle" placeholder="Event Title" required>
</div>
</div>
<div class="form-group">
<label for="inputEventDescription" class="col-lg-2 control-label">Description</label>
<div class="col-lg-10">
<input type="text" class="form-control" id="inputEventTitle" name="inputEventDescription" placeholder="Event Description" required>
</div>
</div>
<div class="form-group">
<label for="inputEventStartTime" class="col-lg-2 control-label">Start Time</label>
<div class="col-lg-10">
<select name="inputEventStartTime" class="form-control" id="dp1" required>
<option label="Start Time">
<option value="12:00AM">12:00AM</option>
<option value="12:15AM">12:15AM</option>
<option value="12:30AM">12:30AM</option>
<option value="12:45AM">12:45AM</option>
<option value="1:00AM">1:00AM</option>
</select>
</div>
</div>
<div class="form-group">
<label for="inputEventEndTime" class="col-lg-2 control-label">End Time</label>
<div class="col-lg-10">
<select name="inputEventEndTime" class="form-control" id="dp1" required>
<option label="End Time">
<option value="1:00AM">1:00AM</option>
<option value="1:15AM">1:15AM</option>
<option value="1:30AM">1:30AM</option>
<option value="1:45AM">1:45AM</option>
<option value="2:00AM">2:00AM</option>
</select> </div>
</div>
<div class="form-group">
<label class="control-label col-sm-2">Date</label>
<div class="col-sm-6">
<input id="dp1" name="inputEventDate" type="text" size="16" class="form-control" required>
</div>
</div>
<div class="form-group">
<label for="inputEventDate" class="col-lg-2 control-label">Repeat?</label>
<div class="col-lg-10 checkboxes">
<label class="label_check" for="checkbox-02"> </label>
<input name="test" id="checkbox-02" type="checkbox" value="1" /> Yes, I want to repeat this event.
</div>
</div>
<div class="form-group" id="repeatUntilDIV" style="display:none;">
<label for="inputEventEndDate" class="col-lg-2 control-label">Repeat Until</label>
<div class="col-lg-10">
<input name="inputEventEndDate" id="eventEndDate" type="text" placeholder="End Date" class="form-control">
</div>
</div>
<div class="form-group" id="repeatFrequencyDIV" style="display:none;">
<label for="inputEventFrequency" class="col-lg-2 control-label">Repeat Every</label>
<div class="col-lg-10">
<select name="inputEventFrequency" class="form-control" id="dp1">
<option label="Repeat Every">
<option value="1">Repeat Every Day</option>
<option value="2">Repeat Every Other Day</option>
<option value="7">Repeat Every Week</option>
<option value="14">Repeat Every Other Week</option>
<option value="30">Repeat Every Month</option>
</select>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-primary" data-dismiss="modal">Cancel</button>
<input type="submit" name="addPrimaryEvent" class="btn btn-success" value="Submit" />
</form>
I get this from var_dump($_POST):
array(8) {
["inputEventTitle"]=>
string(5) "Title"
["inputEventDescription"]=>
string(11) "Description"
["inputEventStartTime"]=>
string(6) "2:00AM"
["inputEventEndTime"]=>
string(6) "3:00AM"
["inputEventDate"]=>
string(10) "05-26-2014"
["inputEventEndDate"]=>
string(10) "05-29-2014"
["inputEventFrequency"]=>
string(1) "1"
["addPrimaryEvent"]=>
string(6) "Submit"
}
Very unclear why this would not work. But I noticed inconsistencies & imbalance in the HTML tags as well as an empty action="" which is not HTML5 valid. For more details, see this great answer over here.
So I have set it to #. You might want to actually change that to the full filename or path to the PHP script such as action="form.php". Or you could leave it out altogether like this:
<form class="cmxform form-horizontal tasi-form" id="commentForm" role="form" action="#" method="post">
But I prefer to be explicit & recommend the action="form.php" way of handling things. Here is your cleaned up HTML form:
<form class="cmxform form-horizontal tasi-form" id="commentForm" role="form" action="#" method="post">
<div class="form-group">
<label for="inputEventTitle" class="col-lg-2 control-label">Event Title</label>
<div class="col-lg-10">
<input type="text" class="form-control" id="inputEventTitle" name="inputEventTitle" placeholder="Event Title" required="" />
</div>
</div>
<div class="form-group">
<label for="inputEventDescription" class="col-lg-2 control-label">Description</label>
<div class="col-lg-10">
<input type="text" class="form-control" id="inputEventTitle" name="inputEventDescription" placeholder="Event Description" required="" />
</div>
</div>
<div class="form-group">
<label for="inputEventStartTime" class="col-lg-2 control-label">Start Time</label>
<div class="col-lg-10">
<select name="inputEventStartTime" class="form-control" id="dp1" required="">
<option value="12:00AM">
12:00AM
</option>
<option value="12:15AM">
12:15AM
</option>
<option value="12:30AM">
12:30AM
</option>
<option value="12:45AM">
12:45AM
</option>
<option value="1:00AM">
1:00AM
</option>
</select>
</div>
</div>
<div class="form-group">
<label for="inputEventEndTime" class="col-lg-2 control-label">End Time</label>
<div class="col-lg-10">
<select name="inputEventEndTime" class="form-control" id="dp1" required="">
<option value="1:00AM">
1:00AM
</option>
<option value="1:15AM">
1:15AM
</option>
<option value="1:30AM">
1:30AM
</option>
<option value="1:45AM">
1:45AM
</option>
<option value="2:00AM">
2:00AM
</option>
</select>
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2">Date</label>
<div class="col-sm-6">
<input id="dp1" name="inputEventDate" type="text" size="16" class="form-control" required="" />
</div>
</div>
<div class="form-group">
<label for="inputEventDate" class="col-lg-2 control-label">Repeat?</label>
<div class="col-lg-10 checkboxes">
<input name="test" id="checkbox-02" type="checkbox" value="1" /> Yes, I want to repeat this event.
</div>
</div>
<div class="form-group" id="repeatUntilDIV" style="display:none;">
<label for="inputEventEndDate" class="col-lg-2 control-label">Repeat Until</label>
<div class="col-lg-10">
<input name="inputEventEndDate" id="eventEndDate" type="text" placeholder="End Date" class="form-control" />
</div>
</div>
<div class="form-group" id="repeatFrequencyDIV" style="display:none;">
<label for="inputEventFrequency" class="col-lg-2 control-label">Repeat Every</label>
<div class="col-lg-10">
<select name="inputEventFrequency" class="form-control" id="dp1">
<option value="1">
Repeat Every Day
</option>
<option value="2">
Repeat Every Other Day
</option>
<option value="7">
Repeat Every Week
</option>
<option value="14">
Repeat Every Other Week
</option>
<option value="30">
Repeat Every Month
</option>
</select>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-primary" data-dismiss="modal">Cancel</button> <input type="submit" name="addPrimaryEvent" class="btn btn-success" value="Submit" />
</div>
</form>

Categories