Calling POST data from a PHP file - php

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.

Related

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>

input to sql not ok with 'copy-paste'

i have a php form, that adds a 'review' to a 'guide' in an SQL database.
i finally figured out my problem, and it is when i use copy paste in the input areas.
what can cause this??
any help appreciated!!
this is the link
this is my code:
<body >
<form class="form-horizontal" method="POST" >
<div class="form-group" >
<div class="col-sm-1">
<a href="." > <img src="Pictures/Design/בחזרה לאתר.png" height="100" width="100"/> </a>
</div>
<div class="col-sm-10">
<h2>הוספת ביקורת ל: <?php if(isset($_SESSION ['name'])){echo $_SESSION ['name'];} else {echo $gname;}?></label>
</h2>
</div>
</div>
<hr>
<div class="form-group">
<div class="col-sm-12 " >
<div class="col-sm-4 " align="right">
<?php $val="uploads/guides/".$row['Picture'];?>
<image src='<?php echo $val;?>' height="130px" width="100px">
</div>
<div class="col-sm-7 " align="right">
<div><label class=" control-label" ><?php if(isset($_SESSION ['name'])){echo $_SESSION ['name'];} else {echo $gname;}?></label><label class=" control-label" >&nbsp&nbsp&nbsp:שם המדריך</label></div>
<div><label class=" control-label" ><?php if(isset($_SESSION ['attraction'])){echo $_SESSION ['attraction'];} else {echo $gattraction;}?></label><label class=" control-label" >&nbsp&nbsp&nbsp:אטרקציה</label></div>
<div><label class=" control-label" ><?php if(isset($_SESSION ['email'])){echo $_SESSION ['email'];} else {echo $gemail;}?></label><label class=" control-label" >&nbsp&nbsp&nbsp:אימייל</label></div>
<div><label class=" control-label" ><?php if(isset($_SESSION ['phone'])){echo $_SESSION ['phone'];} else {echo $gphone;}?></label><label class=" control-label" >&nbsp&nbsp&nbsp:טלפון</label></div>
</div>
</div>
</div>
<hr>
<div class="form-group">
<div class="col-sm-12 " >
<div class="col-sm-6 col-sm-offset-6" align="right">
<label class=" control-label" >שמך המלא</label>
</div>
<div class="col-sm-12">
<input type="text" class="form-control" name="name" placeholder="" />
</div>
</div>
</div>
<div class="form-group">
<div class="col-sm-12 " >
<div class="col-sm-6 col-sm-offset-6" align="right">
<label class=" control-label" >מתי השתמשת בשירותי המדריך</label>
</div>
<div class="col-sm-6 " align="right">
<select class="form-control" name="year">
<option value="בחר/י שנה">בחר/י שנה</option>
<option value="2016">2016</option>
<option value="2015">2015</option>
<option value="2014">2014</option>
<option value="2013">2013</option>
<option value="2012">2012</option>
<option value="2011">2011</option>
<option value="2010">2010</option>
<option value="2009">2009</option>
</select>
</div>
<div class="col-sm-6 " align="right">
<select class="form-control" name="month">
<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>
</div>
<div class="form-group">
<div class="col-sm-12 " >
<div class="col-sm-6 col-sm-offset-6" align="right">
<label class=" control-label" >ציון 1-5</label>
</div>
<div class="col-sm-3 col-sm-offset-9 " align="right">
<select class="form-control " name="rating">
<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>
<div class="form-group">
<div class="col-sm-12 " >
<div class="col-sm-6 col-sm-offset-6" align="right">
<label class=" control-label" >כמה שילמת ומה זה כלל</label>
</div>
<div class="col-sm-12">
<textarea class="form-control" name="pay" cols="40" rows="2"></textarea>
</div>
</div>
</div>
<div class="form-group">
<div class="col-sm-12 " >
<div class="col-sm-6 col-sm-offset-6" align="right">
<label class=" control-label" >פרטו את חוויתכם עם המדריך בהרחבה</label>
</div>
<div class="col-sm-12">
<textarea class="form-control" name="exp" cols="40" rows="5" required></textarea>
</div>
</div>
</div>
<div class="form-group">
<div class="col-sm-12 " >
</div>
</div>
<div class="form-group" >
<div class="col-sm-12 col-sm-offset-5"><button type="submit" class="btn btn-primary btn-sm" name="addreview" value="Submit Record">הוספת ביקורת</button></div>
</div>
<?php
if(isset($_POST['addreview'])){
$name = $_POST['name'];
$name = str_replace("'","''",$name);
$monthh = $_POST['month'];
$yearr = $_POST['year'];
$pay = $_POST['pay'];
$pay = str_replace("'","''",$pay);
$exp= $_POST['exp'];
$exp = str_replace("'","''",$exp);
$rating=$_POST['rating'];
$query1="INSERT INTO review (ReviewerName,ServiceMonth,ServiceYear,Rating,Payment,Experience,Guide_ID) VALUES ";
$query1.="('$name','$monthh','$yearr','$rating','$pay','$exp','$guideid')";
$result=mysqli_query($conn,$query1);
if($result){
?>
<script type="text/javascript">
window.location = "./review_added_successfully.php";
</script>
<?php
}
else{
echo "not submitted";
}
} ?>
</form>
</body>

PHP email from submit and stay on page

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

Making proper foreach HTML in PHP?

I have this php code
<div class="form-group box">
<div class="col-lg-7">
<?php
foreach ($results as $row) {
echo '<select class="form-control" required name="article[]">
<option value="'.$row->articles_id.'">'.$row->article_name.'</option>';
$sql="SELECT * FROM articles WHERE article_active = 1";
$query = $this->db->query($sql);
$articles = $query->result();
foreach ($articles as $row){
echo'
<option value="'.$row->articles_id.'">'.$row->article_name.'</option>';
}
echo'</select>';
}
?>
</div>
<div class="col-lg-3">
<?php foreach ($results as $row) {
echo '<input class="form-control kolicina" type="text" value="'.$row->order_qty.'" name="qty[]" '.$disabled.' required/>'; }
?>
</div>
<div class="col-lg-2">
<?php foreach ($results as $row) {
echo'<button type="button" class="btn btn-danger button-remove">Remove</button>';
}
?>
</div>
</div>
When display this i got this HTML code
<div class="col-lg-7">
<select class="form-control" required="" name="article[]">
<option value="10">Cipiripi</option>
<option value="8">Koka Kola</option>
<option value="10">Cipiripi</option>
</select>
<select class="form-control" required="" name="article[]">
<option value="8">Koka Kola</option>
<option value="8">Koka Kola</option>
<option value="10">Cipiripi</option>
</select>
</div>
<div class="col-lg-3">
<input class="form-control kolicina" value="44" name="qty[]" required="" type="text">
<input class="form-control kolicina" value="44" name="qty[]" required="" type="text">
</div>
<div class="col-lg-2">
<button type="button" class="btn btn-danger button-remove">Remove</button>
<button type="button" class="btn btn-danger button-remove">Remove</button>
</div>
I have tried a lot ways with loop, to get proper code, this is example hos html should look?
<div class="form-group box">
<div class="col-lg-7">
<select class="form-control" required="" name="article[]">
<option value="10">Cipiripi</option>
<option value="8">Koka Kola</option>
<option value="10">Cipiripi</option>
</select>
</div>
<div class="col-lg-3">
<input class="form-control kolicina" value="44" name="qty[]" required="" type="text">
</div>
<div class="col-lg-2">
<button type="button" class="btn btn-danger button-remove">Remove</button>
</div>
</div>
<div class="form-group box">
<div class="col-lg-7">
<select class="form-control" required="" name="article[]">
<option value="8">Koka Kola</option>
<option value="8">Koka Kola</option>
<option value="10">Cipiripi</option>
</select>
</div>
<div class="col-lg-3">
<input class="form-control kolicina" value="44" name="qty[]" required="" type="text">
</div>
<div class="col-lg-2">
<button type="button" class="btn btn-danger button-remove">Remove</button>
</div>
</div>
What i need that loops goes in different wrapper, not in in same col?
This is working fiddle how it has to look
http://jsfiddle.net/ckqth4a7/
And this is what i have now
http://jsfiddle.net/q0njhgfk/
No, just ditch that inner foreach loops inside just build it by the whole row.
Something like:
<?php foreach($results as $row): ?> <!-- loop this as a whole row -->
<div class="form-group box">
<div class="col-lg-7">
<select class="form-control" required="" name="article[]">
<?php
// this is the only loop for the options inside the select
$sql = "SELECT * FROM articles WHERE article_active = 1";
$query = $this->db->query($sql);
$articles = $query->result();
?>
<?php foreach($articles as $article): ?>
<option value="<?php echo $article->articles_id; ?>"><?php echo $article->article_name; ?></option>
<?php endforeach; ?>
</select>
</div>
<div class="col-lg-3">
<input class="form-control kolicina" value="<?php echo $row->order_qty; ?>" name="qty[]" required="" type="text">
</div>
<div class="col-lg-2">
<button type="button" class="btn btn-danger button-remove">Remove</button>
</div>
</div>
<?php endforeach; ?>
Or maybe, if the query is just standing there and will not be dynamic take it off the parent loop.
<?php
// take this outside, its always the same anyway, so that it queries only once
// this is the only loop for the options inside the select
$sql = "SELECT * FROM articles WHERE article_active = 1";
$query = $this->db->query($sql);
$articles = $query->result();
?>
<?php foreach($results as $row): ?> <!-- loop this as a whole row -->
<div class="form-group box">
<div class="col-lg-7">
<select class="form-control" required="" name="article[]">
<?php foreach($articles as $article): ?>
<option value="<?php echo $article->articles_id; ?>"><?php echo $article->article_name; ?></option>
<?php endforeach; ?>
</select>
</div>
<div class="col-lg-3">
<input class="form-control kolicina" value="<?php echo $row->order_qty; ?>" name="qty[]" required="" type="text">
</div>
<div class="col-lg-2">
<button type="button" class="btn btn-danger button-remove">Remove</button>
</div>
</div>
<?php endforeach; ?>

Categories