PHP, HTML, MySql Form refuses to post - php

I have made many forms but for some unknown reason I cannot get this one to work. I hit submit and it just stays on the same page and all the inputs just go empty. Maybe a fresh pair of eyes would see something I do not. I have tried putting the PHP in a separate file, double/triple checked the input statement and everything else and just can't see it whatever it is.
This is the table:
CREATE TABLE `store_orders` (
`id` int(11) NOT NULL,
`order_date` varchar(70) NOT NULL,
`order_first_name` varchar(50) NOT NULL,
`order_last_name` varchar(50) NOT NULL,
`order_address` varchar(255) NOT NULL,
`order_city` varchar(50) NOT NULL,
`order_state` char(50) NOT NULL,
`order_zip` varchar(10) NOT NULL,
`order_tel` varchar(25) NOT NULL,
`order_email` varchar(100) NOT NULL,
`cc_type` varchar(30) NOT NULL,
`cc_number` int(16) NOT NULL,
`cc_expmonth` int(2) NOT NULL,
`cc_expyear` int(2) NOT NULL,
`cc_cvc` int(3) NOT NULL
)
Here's the PHP at the top of the page:
<?php
session_start();
//connect to database
$con = mysqli_connect("localhost", $username, #pw, $db);
$error = false;
if (isset($_POST['checkout'])) {
$datetime = mysqli_real_escape_string($con, $_POST['order_date']);
$fname = mysqli_real_escape_string($con, $_POST['order_first_name']);
$lname = mysqli_real_escape_string($con, $_POST['order_last_name']);
$address = mysqli_real_escape_string($con, $_POST['order_address']);
$city = mysqli_real_escape_string($con, $_POST['order_city']);
$state = mysqli_real_escape_string($con, $_POST['order_state']);
$zip = mysqli_real_escape_string($con, $_POST['order_zip']);
$phone = mysqli_real_escape_string($con, $_POST['order_tel']);
$email = mysqli_real_escape_string($con, $_POST['order_email']);
$cardtype = mysqli_real_escape_string($con, $_POST['cc_type']);
$cardnumber = mysqli_real_escape_string($con, $_POST['cc_number']);
$cardmonth = mysqli_real_escape_string($con, $_POST['cc_expmonth']);
$cardyear = mysqli_real_escape_string($con, $_POST['cc_expyear']);
$cardcvc = mysqli_real_escape_string($con, $_POST['cc_cvc']);
$fname = stripslashes($fname);
$lname = stripslashes($lname);
$address = stripslashes($address);
$city = stripslashes($city);
$zip = stripslashes($zip);
$phone = stripslashes($phone);
$email = stripslashes($email);
$cardtype = stripslashes($cardtype);
$cardnumber = stripslashes($cardnumber);
$cardmonth = stripslashes($cardmonth);
$cardmonth = stripslashes($cardmonth);
$cardyear = stripslashes($cardyear);
$cardcvc = stripslashes($cardcvc);
if (!preg_match("/^[a-zA-Z ]+$/",$fname)) { /* name can contain only alpha characters and space */
$error = true;
$name_error = "Name must contain only letters"; }
if (!preg_match("/^[a-zA-Z ]+$/",$lname)) { /* name can contain only alpha characters and space */
$error = true;
$name_error = "Name must contain only letters"; }
if (!preg_match("/^[a-zA-Z-0-9 ]+$/",$address)) { /* letters and numbers */
$error = true;
$user_name_error = "Address can contain only letters and numbers"; }
if (!preg_match("/^[a-zA-Z-0-9 ]+$/",$city)) { /* letters and numbers */
$error = true;
$user_name_error = "City can contain only letters and numbers"; }
if(!filter_var($email,FILTER_VALIDATE_EMAIL)) { /* will accept only email addresses */
$error = true;
$email_error = "Please Enter Valid Email ID"; }
if (!$error) {
if(mysqli_query($con, "INSERT INTO store_orders(order_date, order_first_name, order_last_name, order_address, order_city , order_state, order_zip, order_tel, order_email, cc_type, cc_number, cc_expmonth, cc_expyear, cc_cvc ) VALUES('".$datetime."','".$fname."','".$lname."','".$address."','".$city."','".$state."','".$zip."','".$phone."','".$email."','".$cardtype."','".$cardnumber."','".$cardmonth."','".$cardyear."','".$cardcvc."')"));
header('Location: checkout-view.php');
} else {
$errormsg = "Error completing form...Please try again!"; /* if register is not successful */
}
}
?>
This is the form... on the same page...
<!doctype html>
<html>
<!-- InstanceBegin template="/Templates/index.dwt" codeOutsideHTMLIsLocked="false" -->
<head>
</head>
<body style="background-color: #f9ecf2;">
<div class="container">
<div class="col-md-8 col-sm-8 grad" style="background-color: ; margin-right: 0px; margin-left: 0px; border-bottom-style: solid; border-bottom-color: #4d004d; border-bottom-width: 1px; padding-left: 0px;">
<!-- begin middle column -->
<!-- InstanceBeginEditable name="EditRegion3" -->
<div style='width: 85%; margin-left: auto; margin-right: auto;'>
<br>
<br>
<br>
<form role="form" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" name="checkout">
<table width="100%" border="0" class="responsive">
<tr>
<td align="right" valign="top" width="30%" style="padding-left: 15px; padding-right: 10px; padding-top: 10px;">
<b5 style="text-align: right; line-height: 80%; font-size: 16pt; color: black;">Date - Time</b5>
</td>
<td>
<b3 style="font-size: 12pt;">
<input name="order_date" id="order_date" type="text" value="<?php echo date('m/d/y');?>" />
</b3>
</td>
</tr>
<tr>
<td align="right" valign="top" width="30%" style="padding-left: 15px; padding-right: 10px; padding-top: 10px;">
<b5 style="text-align: right; line-height: 80%; font-size: 16pt; color: black;">First Name:</b5>
</td>
<td>
<b3 style="font-size: 12pt;">
<input name="order_first_name" id="order_first_name" type="text" size="50" maxlength="50" required="required" />
</b3>
</td>
</tr>
<tr>
<td align="right" valign="top" width="30%" style="padding-left: 15px; padding-right: 10px; padding-top: 10px;">
<b5 style="text-align: right; line-height: 80%; font-size: 16pt; color: black;">Last Name:</b5>
</td>
<td>
<b3 style="font-size: 12pt;">
<input name="order_last_name" id="order_last_name" type="text" size="50" maxlength="40" required="required" />
</b3>
</td>
</tr>
<tr>
<td align="right" valign="top" width="30%" style="padding-left: 15px; padding-right: 10px; padding-top: 10px;">
<b5 style="text-align: right; line-height: 80%; font-size: 16pt; color: black;">Address:</b5>
</td>
<td>
<b3 style="font-size: 12pt;">
<input name="order_address" id="order_address" type="text" size="50" maxlength="255" required="required" />
</b3>
</td>
</tr>
<tr>
<td align="right" valign="top" width="30%" style="padding-left: 15px; padding-right: 10px; padding-top: 10px;">
<b5 style="text-align: right; line-height: 80%; font-size: 16pt; color: black;">City:</b5>
</td>
<td>
<b3 style="font-size: 12pt;">
<input name="order_city" id="order_city" type="text" size="50" maxlength="50" required="required" />
</b3>
</td>
</tr>
<tr>
<td align="right" valign="top" width="30%" style="padding-left: 15px; padding-right: 10px; padding-top: 10px;">
<b5 style="text-align: right; line-height: 80%; font-size: 16pt; color: black;">Select State:</b5>
</td>
<td style=" padding-top: 5px;">
<b3 style="font-size: 12pt;">
<select name="order_state" id="order_state">
<option value="AL">Alabama</option>
<option value="AK">Alaska</option>
<option value="AZ">Arizona</option>
<option value="AR">Arkansas</option>
<option value="CA">California</option>
<option value="CO">Colorado</option>
<option value="CT">Connecticut</option>
<option value="DE">Delaware</option>
<option value="DC">District of Columbia</option>
<option value="FL">Florida</option>
<option value="GA">Georgia</option>
<option value="HI">Hawaii</option>
<option value="ID">Idaho</option>
<option value="IL">Illinois</option>
<option value="IN">Indiana</option>
<option value="IA">Iowa</option>
<option value="KS">Kansas</option>
<option value="KY">Kentucky</option>
<option value="LA">Louisiana</option>
<option value="ME">Maine</option>
<option value="MD">Maryland</option>
<option value="MA">Massachusetts</option>
<option value="MI">Michigan</option>
<option value="MN">Minnesota</option>
<option value="MS">Mississippi</option>
<option value="MO">Missouri</option>
<option value="MT">Montana</option>
<option value="NE">Nebraska</option>
<option value="NV">Nevada</option>
<option value="NH">New Hampshire</option>
<option value="NJ">New Jersey</option>
<option value="NM">New Mexico</option>
<option value="NY">New York</option>
<option value="NC">North Carolina</option>
<option value="ND">North Dakota</option>
<option value="OH">Ohio</option>
<option value="OK">Oklahoma</option>
<option value="OR">Oregon</option>
<option value="PA">Pennsylvania</option>
<option value="RI">Rhode Island</option>
<option value="SC">South Carolina</option>
<option value="SD">South Dakota</option>
<option value="TN">Tennessee</option>
<option value="TX">Texas</option>
<option value="UT">Utah</option>
<option value="VT">Vermont</option>
<option value="VA">Virginia</option>
<option value="WA">Washington</option>
<option value="WV">West Virginia</option>
<option value="WI">Wisconsin</option>
<option value="WY">Wyoming</option>
</select>
</b3>
</td>
</tr>
<tr>
<td align="right" valign="top" style="padding-left: 15px; padding-right: 10px; padding-top: 10px;">
<b5 style="text-align: right; line-height: 80%; font-size: 16pt; color: black;">Zip Code:</b5>
</td>
<td style=" padding-top: 5px;">
<b3 style="font-size: 12pt;">
<input name="order_zip" id="order_zip" type="text" size="50" maxlength="10" required="required" />
</b3>
</td>
</tr>
<tr>
<td align="right" valign="top" style="padding-left: 15px; padding-right: 10px; padding-top: 10px;">
<b5 style="text-align: right; line-height: 80%; font-size: 16pt; color: black;">Phone:</b5>
</td>
<td style=" padding-top: 5px;">
<b3 style="font-size: 12pt;">
<input name="order_tel" id="order_tel" type="text" size="50" maxlength="25" required="required" />
</b3>
</td>
</tr>
<tr>
<td align="right" valign="top" style="padding-left: 15px; padding-right: 10px; padding-top: 10px;">
<b5 style="text-align: right; line-height: 80%; font-size: 16pt; color: black;">Email Address:</b5>
</td>
<td style=" padding-top: 5px;">
<b3 style="font-size: 12pt;">
<input name="order_email" type="email" id="order_email" size="50" maxlength="100" required="required" />
</b3>
</td>
</tr>
<tr>
<td align="right" valign="top" style="padding-left: 15px; padding-right: 10px; padding-top: 10px;">
<b5 style="text-align: right; line-height: 80%; font-size: 16pt; color: black;">Select Card Type:</b5>
</td>
<td style=" padding-top: 5px; font-size: 24pt; color: #4d004d">
<p>
<b5>
<img src="img/cc-mastercard.png" width="75" height="49" alt="" />
<input type="radio" name="cc_type" value="Mastercard">
<img src="img/cc-visa.png" width="75" height="49" alt="" />
<input type="radio" name="cc_type" value="Visa">
<img src="img/cc-american-express.png" width="75" height="49" alt="" />
<input type="radio" name="cc_type" value="American Express">
<img src="img/cc-paypal.png" width="75" height="49" alt="" />
<input type="radio" name="cc_type" value="PayPal">
</b5>
</p>
</td>
</tr>
<tr>
<td align="right" valign="top" style="padding-left: 15px; padding-right: 10px; padding-top: 10px;">
<b5 style="text-align: right; line-height: 80%; font-size: 16pt; color: black;">Card Number:</b5>
</td>
<td style=" padding-top: 5px;">
<b3 style="font-size: 12pt;">
<input name="cc_number" type="integer" id="cc_number" size="50" maxlength="16" required="required" />
</b3>
</td>
</tr>
<tr>
<td align="right" valign="top" style="padding-left: 15px; padding-right: 10px; padding-top: 10px;">
<b5 style="text-align: right; line-height: 80%; font-size: 16pt; color: black;">Expiration:</b5>
</td>
<td style=" padding-top: 5px;">
<b3 style="font-size: 12pt;">
<input name="cc_expmonth" type="integer" id="cc_expmonth" size="2" maxlength="2" required="required" /><span Style='font-size: 18pt; color: #4d004d'><b3>&nbsp/&nbsp</span>
</b3>
<input name="cc_expyear" type="integer" id="cc_expyear" size="2" maxlength="2" required="required" />
</b3>
</td>
</tr>
<tr>
<td align="right" valign="top" style="padding-left: 15px; padding-right: 10px; padding-top: 10px;">
<b5 style="text-align: right; line-height: 80%; font-size: 16pt; color: black;">CVC Code:</b5>
</td>
<td style=" padding-top: 5px;">
<b3 style="font-size: 12pt;">
<input name="cc_cvc" type="integer" id="cc_cvc" size="3" maxlength="3" required="required" />
</b3>
</td>
</tr>
<tr>
<td align="right" valign="top" style="padding-left: 15px; padding-right: 10px; padding-top: 10px;"></td>
<td style=" padding-top: 5px;">
<b5 style="font-size: 12pt;">
<input name="submit" type="submit" value="Submit" /><span>&nbsp&nbsp&nbsp</span>
<input name="reset" type="reset" value="Reset" />
</b5>
</td>
</tr>
</table>
</form>
</div>
<br>
<br>
<br>
<!-- InstanceEndEditable -->
</div>
<!-- end middle column -->
</body>
<!-- InstanceEnd -->
</html>
The connection is right. I've got about an hour to turn this assignment in so, at midnight (EST), the semester is over. Good thing I made 100's on everything else this Fall...... I have made countless forms over the past year or more and never had a problem.....

Change the name of the submit button to "checkout" and remove the name="checkout" from the form.

Related

Dynamically adding select2 to DOM which gets data from DB

I have a HTML table where user can choose products from MySql db.
I have a "add new row" possibility where new row is added to DOM.
Once I add new row, select-2 is no longer functioning in this new row - I beleive it is a problem, that it is searching for input only in first example of select-2 dropdown. How can I show dropdown for each instance?
Code:
<table id="add_new" style="width: 100%; margin-top:40px;" class="col-12 col-lg-12 col-md-12 col-sm-12 col-xl-12">
<thead>
<tr>
<th style="text-align:left; font-size: 10px; color:#8f8f8f; padding-bottom: 15px; width: 10%;">
Zap. št.: </th>
<th style="text-align:left; font-size: 10px; color:#8f8f8f; padding-bottom: 15px; width: 50%;">
Naziv artikla </th>
<th style="text-align:left; font-size: 10px; color:#8f8f8f; padding-bottom: 15px; width: 20%;">
Količina </th>
<th style="text-align:right; font-size: 10px; color:#8f8f8f; padding-bottom: 15px; width: 20%;">
EM (kos/m/colli,...) </th>
</tr>
</thead>
<tbody>
<tr id="mainsection">
<td> <p href="#" id="count" style="font-size: 13px; text-decoration: none; line-height: 1; color:#909090; margin-top:0px; margin-bottom:0;">
1</p> </td>
<td contenteditable style="padding-top:0px; padding-bottom:5px;">
<h4 style="font-size: 16px; line-height: 1; margin-bottom:0; color:#303030; font-weight:500; margin-top: 10px;">
<select class="form-control select2-multiple" id="dd_artikli" data-width="100%">
<option value="">Select country</option>
<?php
if (count($itemRecords_artikli) > 0) {
foreach ($itemRecords_artikli as $ct) {
?>
<option value="<?php echo $ct['id']; ?>">
<?php echo $ct['name']; ?>
</option>
<?php
}
}
?>
</select>
</h4>
</td>
<td contenteditable> <p href="#" style="font-size: 13px; text-decoration: none; line-height: 1; color:#909090; margin-top:0px; margin-bottom:0;"> </p> </td>
<td contenteditable style="padding-top:0px; padding-bottom:0; text-align: right;"> <p style="font-size: 13px; line-height: 1; color:#303030; margin-bottom:0; margin-top:0; vertical-align:top; white-space:nowrap;"> </p> </td>
</tr>
</tbody>
</table>
<script>
var number = 1;
document.getElementById("newsectionbtn").onclick = function() {
var container = document.getElementById("add_new");
var section = document.getElementById("mainsection");
var count = document.getElementById('count');
number++;
count.textContent = number.toString();
container.appendChild(section.cloneNode(true));
}
</script>
<
?php
/*
#Author: Sanjay Kumar
#Project: PHP MySQLi How To Use Select2 for Multiple Select Tutorial
#Email: onlinewebtutorhub#gmail.com
#Website: https://onlinewebtutorblog.com/
*/
// Include the database configuration file
require 'dbconfig.php';
$countrySelect = $conn->prepare("SELECT * FROM artikli");
$countrySelect->execute();
$countries = $countrySelect->get_result();
$itemRecords_artikli = array();
while ($item = $countries->fetch_assoc()) {
extract($item);
$itemDetails = array(
"id" => $id,
"name" => $naziv
);
array_push($itemRecords_artikli, $itemDetails);
}
?>
After drop-down bind run this command.
jQuery('#dd_artikli').select2();
Or use the jquery ready function.
$(document).ready(function() { jQuery('#dd_artikli').select2(); });

data is not submitted to database using php mysql

I am using php and MySQL. When I submit the form data is not stored in the database table 'plantation_journal_nursery_details'. I am badly stuck here. Can anyone please advice me that how can I solve this problem?? Thanks in advance guys. codes are given below :
create_journal.php
<form action="data_fetch.php" action="post">
<div class="row">
<div class="col-sm-4">
<h4 style="font-size: 16px;padding-left: 15px;"><b>Nursery Location:</b></h4><br>
<div align="right" style="padding-right: 10px;">
<label style="font-weight:300;font-size: 15px">Location:</label>
<input type="text" name="location" id="location" style="width:50%;height: 30px; margin-left: 10px; border-radius: 5px;"><br>
<label style="font-weight:300;font-size: 15px">Area:</label>
<input type="text" name="area1" id="area1" style="width:50%;height: 30px; margin-left: 10px; border-radius: 5px;"><br>
<label style="font-weight:300;font-size: 15px">type of Nursey:</label>
<select name="type_of_nursery" id="type_of_nursery" style="width:50%;height: 30px; margin-left: 10px; border-radius: 5px;">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
</select><br><br>
<label style="font-weight:300;font-size: 15px">Centranl Nursery Name:</label>
<select name="central_nursery_name" id="central_nursery_name" style="width:40%;height: 30px; margin-left: 10px; border-radius: 5px;">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
</select><br><br>
<label style="font-weight:300;font-size: 15px">State Nursery Name:</label>
<input type="text" name="state_nursery_name" id="state_nursery_name" style="width:50%;height: 30px; margin-left: 10px; border-radius: 5px;"><br>
</div>
</div>
<div class="col-sm-4">
<h4 style="font-size: 16px;padding-left: 15px;"><b>Size of Each Bed:</b></h4><br>
<div align="right" style="padding-right: 10px;">
<label style="font-weight:300;font-size: 15px">Mother Bed Size:</label>
<input type="text" name="mother_bed_size" id="mother_bed_size" style="width:50%;height: 30px; margin-left: 10px; border-radius: 5px;"><br>
<label style="font-weight:300;font-size: 15px">Quantity:</label>
<input type="text" name="quantity_m" id="quantity_m" style="width:50%;height: 30px; margin-left: 10px; border-radius: 5px;"><br><br><br>
<label style="font-weight:300;font-size: 15px">Source of Seed:</label>
<select name="source_of_seed" id="source_of_seed" style="width:50%;height: 30px; margin-left: 10px; border-radius: 5px;">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
</select><br><br>
</div>
</div>
<div class="col-sm-4">
<div align="right" style="padding-right: 10px; padding-top: 40px">
<label style="font-weight:300;font-size: 15px">Polypot Bed Size:</label>
<input type="text" name="polypot_bed_size" id="polypot_bed_size" style="width:42%;height: 30px; margin-left: 4px; border-radius: 5px;"><br>
<label style="font-weight:300;font-size: 15px">Quantity:</label>
<input type="text" name="quantity_p" id="quantity_p" style="width:42%;height: 30px; margin-left: 4px; border-radius: 5px;"><br><br>
<label style="font-weight:300;font-size: 15px">Hycopot Bed Size:</label>
<input type="text" name="hycopot_bed_size" id="hycopot_bed_size" style="width:42%;height: 30px; margin-left: 4px; border-radius: 5px;"><br>
<label style="font-weight:300;font-size: 15px">Quantity:</label>
<input type="text" name="quantity_h" id="quantity_h" style="width:42%;height: 30px; margin-left: 4px; border-radius: 5px;"><br>
</div>
</div>
</div>
<div class="row">
<div align="right" style="padding-right: 10px;">
<input class="btn btn-info" type="submit" name="submit16" value="Add" onclick="move7()">
</div>
</div>
</form>
data_fetch.php
<?php
$con=mysqli_connect("localhost","root","","forestdb");
if(isset($_POST['submit16'])){
$location=$_POST['location'];
$area1=$_POST['area1'];
$type_of_nursery=$_POST['type_of_nursery'];
$central_nursery_name=$_POST['central_nursery_name'];
$state_nursery_name=$_POST['state_nursery_name'];
$mother_bed_size=$_POST['mother_bed_size'];
$quantity_m=$_POST['quantity_m'];
$source_of_seed=$_POST['source_of_seed'];
$polypot_bed_size=$_POST['polypot_bed_size'];
$quantity_p=$_POST['quantity_p'];
$hycopot_bed_size=$_POST['hycopot_bed_size'];
$quantity_h=$_POST['quantity_h'];
$query="SELECT plantation_journal_no from plantation_journal_basic_details where plantation_journal_no=(select max(plantation_journal_no) from plantation_journal_basic_details);";
$res=mysqli_query($con,$query);
$row=mysqli_fetch_assoc($res);
$plantation_journal_no=$row['plantation_journal_no'];
$sql="INSERT INTO `plantation_journal_nursery_details`(`plantation_journal_no`, `location`, `area`, `type_of_nursery`, `central_nursery_name`, `state_nursery_name`, `mother_bed_size`, `quantity`, `source_of_seed`, `polypot_bed_size`, `quantity_p`, `hycopot_bed_size`, `quantity_h`) VALUES ('$plantation_journal_no','$location','$area1','$type_of_nursery','$central_nursery_name','$central_nursery_name','$mother_bed_size','$quantity_m','$source_of_seed','$polypot_bed_size','$quantity_p','$hycopot_bed_size','$quantity_h');";
$result=mysqli_query($con,$sql);
if($result){
echo "<script>alert('data submitted.');</script>";
header("Location:create_journal.php");
}
}
?>
Your insert query, before you edited your question, contained ...
...VALUES ('$plantation_journal_no',$configurarion','$slope','$water_table_in_...
Notice that your single quotes aren't matched. You should have
...VALUES ('$plantation_journal_no','$configurarion','$slope','$water_table_in_...
If you had checked for an error in your query you would have found this problem immediately. Code like this would have helped.
if($result){
echo "<script>alert('data submitted.');</script>";
header("Location:create_journal.php");
}
else {
die $mysqli->error;
}
Pro tip: Format your code so you don't have to scroll horizontally to see entire queries. It's far easier to examine your queries and find mistakes that way. You can use php's heredoc syntax for string constants to do that.
This is how it looks.
$sql= <<<INSERTQUERY
INSERT INTO `plantation_journal_nursery_details`
(`plantation_journal_no`, `location`, `area`, `type_of_nursery`,
`central_nursery_name`, `state_nursery_name`, `mother_bed_size`,
`quantity`, `source_of_seed`, `polypot_bed_size`, `quantity_p`,
`hycopot_bed_size`, `quantity_h`)
VALUES
('$plantation_journal_no','$location','$area1','$type_of_nursery',
'$central_nursery_name','$central_nursery_name','$mother_bed_size',
'$quantity_m','$source_of_seed','$polypot_bed_size','$quantity_p',
'$hycopot_bed_size','$quantity_h');
INSERTQUERY;

Object not found XAMPP PHP error

I am trying to run a php file using xampp but I'm getting the Object not found error, I watched some videos where people say create another folder and run it under that but that is not working for me! look at the screenshot below and please if you could help me understand why this isn't working
enter image description here
Please note even if i use another file such as footer.php i get the same error.
here is the code for mens.php i didnt include it in the screenshot
<?php
session_start();
//unset($_SESSION['basket']);
?>
<!DOCTYPE html>
<html>
<head>
<!-- External Stylesheet -->
<link rel="stylesheet" href="style.css" type="text/css" />
<title>Mens</title>
</head>
<body>
<div class="bar">Sale Now On!</div>
<div id="outer">
<?php
include('header.php');
?>
<!-- All content will be wrapped insisde this container -->
<div id="container">
<!-- Page -->
<h2>Mens Clothing</h2>
<table width="100%" cellpadding="0" cellspacing="0">
<tr class="headings">
<th style="width: 20%;">Photo</th>
<th style="width: 30%;">Desciption</th>
<th style="width: 10%;">Size</th>
<th style="width: 10%;">Price</th>
<th style="width: 10%;">Qty</th>
<th style="width: 20%;">Action</th>
</tr>
<form action="addtocart.php" method="post" name="addtocart">
<tr class="datarow">
<td style="width: 20%; text-align: center; border-left:dotted
1px #333; border-bottom: dotted 1px #333; border-right:dotted 1px #333;">
<img src="img/suit.jpg" width="112px" />
</td>
<td style="width: 30%; text-align: center; border-bottom:
dotted 1px #333; border-right:dotted 1px #333;">Contempary Hugo Boss
Suit</td>
<input type="hidden" name="itemdesc" value="Contempary Hugo Boss
Suit" />
<input type="hidden" name="sku" value="100" />
<input type="hidden" name="pic" value="suit.jpg" />
<td style="width: 10%; text-align: center; border-bottom: dotted
1px #333; border-right:dotted 1px #333;">
<select name="size">
<option value="S">Small</option>
<option value="M">Medium</option>
<option value="L">Large</option>
</select>
</td>
<td style="width: 10%; text-align: center; border-bottom:
dotted 1px #333; border-right:dotted 1px #333;">£500.00</td>
<input type="hidden" name="price" value="500.00" />
<td style="width: 10%; text-align: center; border-bottom: dotted
1px #333; border-right:dotted 1px #333;">
<select name="qty">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
</select>
</td>
<td style="width: 20%; text-align: center; border-bottom: dotted
1px #333; border-right:dotted 1px #333;">
<input type="submit" name="submit" value="Add to Basket" />
</td>
</tr>
</form>
<form action="addtocart.php" method="post" name="addtocart">
<tr class="datarow">
<td style="width: 20%; text-align: center; border-left:dotted
1px #333; border-bottom: dotted 1px #333; border-right:dotted 1px #333;">
<img src="img/suit1.jpg" width="112px" />
</td>
<td style="width: 30%; text-align: center; border-bottom:
dotted 1px #333; border-right:dotted 1px #333;">Wool Hugo Boss Suit</td>
<input type="hidden" name="itemdesc" value="Wool Hugo Boss Suit"
/>
<input type="hidden" name="sku" value="101" />
<input type="hidden" name="pic" value="suit1.jpg" />
<td style="width: 10%; text-align: center; border-bottom: dotted
1px #333; border-right:dotted 1px #333;">
<select name="size">
<option value="S">Small</option>
<option value="M">Medium</option>
<option value="L">Large</option>
</select>
</td>
<td style="width: 10%; text-align: center; border-bottom:
dotted 1px #333; border-right:dotted 1px #333;">£450.00</td>
<input type="hidden" name="price" value="450.00" />
<td style="width: 10%; text-align: center; border-bottom: dotted
1px #333; border-right:dotted 1px #333;">
<select name="qty">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
</select>
</td>
<td style="width: 20%; text-align: center; border-bottom: dotted
1px #333; border-right:dotted 1px #333;">
<input type="submit" name="submit" value="Add to Basket" />
</td>
</tr>
</form>
</table>
</div>
</div>
<?php
include('footer.php');
?>
</body>
</html>
A file called ._mens.php Is NOT the same as a file called mens.php
As you are using the url localhost/example/mens.php then the file needs to be called mens.php

updating filtered mysql rows in php

I'm trying to update different rows from mysql that they filtered by some record . in this code first the user should enter two input : classnumber and level .
records that they have this fields will show in table then the user should be able to update this records information . but the problem is all of records are in one table in mysql so their id is different I mean for example the first record that match with two inputs id is 2 and then the next one is 5 and next one 6 and ....
with this kind of situation how should I change the code below ?
<form id="searchform" method="post" dir="rtl" action="">
level :<input name="level" style="margin-top:5px; margin-left:6px;font-family: Tahoma,Geneva,sans-serif; font-size: 12px; margin-top: 5px; padding: 5px; width: 50px;" type="text" id="level" />
classnumber :<input name="classnum" style="margin-top:5px; margin-left:6px;font-family: Tahoma,Geneva,sans-serif; font-size: 12px; margin-top: 5px; padding: 5px; width: 50px;" type="text" id="classnum" />
<input style="margin-top:10px; margin-left:120px; font-size: 14px; padding: 5px 14px;" type="submit" value="جستجو" name="enter" />
</form>
<?php
if(isset($_POST['enter'])){
$sql="SELECT * FROM `".$tbl_name."` where classnum='".$_REQUEST['classnum']."' and level='".$_REQUEST['level']."' ";
$result=mysql_query($sql,$link);
$count=mysql_num_rows($result);
}
?>
<div class="cleaner h30"></div>
<br>
<form name="form1" action="" method="POST">
<center>
<div>
<div align="center" width = 615>
<table class="stats" cellspacing="0" width="615" border="1">
<tr>
<th width="20" scope="col" >Id</th>
<th width="60" scope="col">Name</th>
<th width="60" scope="col">Last Name</th>
<th width="42" scope="col">Midterm</th>
<th width="54" scope="col">Class mark</th>
<th width="42" scope="col">Final Quiz</th>
<th width="54" scope="col">State</th>
<th width="54" scope="col">Details</th>
</tr>
<?php
while($rows=mysql_fetch_array($result)){
$id[]=$rows['id'];
?>
<tr>
<td align="center">
<input name="id[]" type="text" id="id" value="<? echo $rows['id']; ?>" style=" font-family: Tahoma,Geneva,sans-serif; font-size: 12px; padding: 5px; width: 10px;"></td>
<td align="center"><input style=" font-family: Tahoma,Geneva,sans-serif; font-size: 12px; padding: 5px; width: 60px;" type="text" name="name[]" id="name" value= "<? echo $rows['name']; ?>" /></td>
<td align="center"><input style=" font-family: Tahoma,Geneva,sans-serif; font-size: 12px; padding: 5px; width: 60px;" type="text" name="lastname[]" id="lastname" value= "<? echo $rows['lastname']; ?>" /></td>
<td align="center"><input style=" font-family: Tahoma,Geneva,sans-serif; font-size: 12px; padding: 5px; width: 50px;" type="text" name="midmark[]" id="midmark" /></td>
<td align="center"><input style=" font-family: Tahoma,Geneva,sans-serif; font-size: 12px; padding: 5px; width: 50px;" type="text" name="classmark[]" id="classmark" /></td>
<td align="center"><input style=" font-family: Tahoma,Geneva,sans-serif; font-size: 12px; padding: 5px; width: 50px;" type="text" name="finalmark[]" id="finalmark" /></td>
<td align="center"><input style=" font-family: Tahoma,Geneva,sans-serif; font-size: 12px; padding: 5px; width: 50px;" type="text" name="state[]" id="state" /></td>
<td align="center"><input style=" font-family: Tahoma,Geneva,sans-serif; font-size: 12px; padding: 5px; width: 50px;" type="text" name="details[]" id="details" /></td>
</tr>
<?php
}
?>
</table>
</div>
</div>
</center>
<input style="margin-top:10px; float:right; margin-right:175px; font-size: 14px; padding: 5px 14px;" type="submit" value="ثبت" name="Submit" />
</form>
<?php
// Check if button name "Submit" is active, do this
if(isset($_POST['Submit']))
{
for($i=0;$i<$count;$i++)
{
$sql1=mysql_query(" UPDATE `".$tbl_name."` SET midmark='".$_REQUEST['midmark'][$i]."' , classmark='".$_REQUEST['classmark'][$i]."' , finalmark='".$_REQUEST['finalmark'][$i]."' , state='".$_REQUEST['state'][$i]."' , details='".$_REQUEST['details'][$i]."' WHERE id='".$_REQUEST['id'][$i]."' "); $result1=mysql_query($sql1);
}
}
if($result1){
header("location:results.php");
}
mysql_close();
?>

html submit button

i have this code
file search.php
<html>
<head>
<script src="http://code.jquery.com/jquery-1.8.3.js"></script>
<script src="http://code.jquery.com/ui/1.9.2/jquery-ui.js"></script>
<script>
</script>
<?php
if(isset($_POST['bt_submit'])){
header('Location: accueil.php?region=');
}
?>
<style>
body {
background-image: url(../images/paper_03.png);
}
form {
background-image: url(../images/paper_02.png);
}
</style>
</head>
<body>
<form name="search" method="post" >
<form name="map" style="position: relative; top:10px; left:300px; width: 400px; height: 130px;">
jjjjjjjjjjjjjjjjj
</form>
<form name="advanced" style="position: relative; top:10px; left:300px; width: 400px; height: 130px;" action="blabla.php">
<form name="location" style="position: relative; top:10px; left:300px; width: 300px; height: 90px;">
<div style="background-color:99FFFF"><font color="blue">Location</font></div>
<table>
<tr>
<td>Region: </td><td ><select style="width:200px" name="region">
<option value="1">truc</option>
<option value="1">truc</option>
<option value="1">truc</option>
</select> </td>
</tr>
<tr>
<td>City: </td><td colspan="3"><input type="text" style="width:200px" name="city" /> </td>
</tr>
<tr>
<td>State/Province: </td><td colspan="3"><select style="width:200px">
<option value="1">truc</option>
<option value="1">truc</option>
<option value="1">truc</option>
</select> </td>
</tr>
<tr>
<td>Country: </td><td colspan="3"><select style="width:200px" >
<option value="1">truc</option>
<option value="1">truc</option>
<option value="1">truc</option>
</select> </td>
</tr>
</table>
</form>
<form name="keywords" style="position: relative; top:10px; left:300px; width: 400px; height: 50px;" >
<div style="background-color:99FFFF"><font color="blue">Keywords</font></div>
<table>
<tr>
<td colspan="2">Keywords: </td><td ><input type="text" style="width:225px" name="keywords" /> </td>
</tr>
</table>
</form>
<form name="company" style="position: relative; top:10px; left:300px; width: 400px; height: 50px;" >
<div style="background-color:99FFFF"><font color="blue">Company</font></div>
<table>
<tr>
<td>Company: </td><td colspan="3"><select style="width:230px">
<option value="1">truc</option>
<option value="1">truc</option>
<option value="1">truc</option>
</select> </td>
</tr>
</table>
</form>
<form name="job_category" style="position: relative; top:10px; left:300px; width: 400px; height: 50px;">
<div style="background-color:99FFFF"><font color="blue">Job category</font></div>
<table>
<tr>
<td>Job category: </td><td colspan="3"><select style="width:210px">
<option value="1">truc</option>
<option value="1">truc</option>
<option value="1">truc</option>
</select> </td>
</tr>
</table>
</form>
<form name="dates" style="position: relative; top:10px; left:300px; width: 400px; height: 50px;">
<div style="background-color:99FFFF"><font color="blue">Dates</font></div>
<table>
<tr>
<td>Date range: </td><td colspan="3"><select style="width:225px">
<option value="1">truc</option>
<option value="1">truc</option>
<option value="1">truc</option>
</select> </td>
</tr>
</table>
</form>
</form>
<input type="submit" name="bt_submit" value="Search Now" style="position: relative; left:400px; width: 100px" />
</form>
</body>
</html>
this file contains php and html code .the interface contains two sections : the first is a form and the second is a set of forms that must be submitted by the button
my problem is when i click in button of submit to validate the form the redirection didn't work and nothing is done. so i need know
why?
how can i fix this error?
You only need one <form>. You might want to use <fieldset> elements to group sections of the form together, but by having multiple forms they are treated completely separately.
<?php
if(isset($_POST['bt_submit'])){
header('Location: accueil.php?region=');
}
?>
Place this code on TOP of your page, even before one single alphabet of html. Header does not work when something has already been displayed
You can not have nested forms. Plus each input is apparently a different form in your code. You will have to update it to have it in single form.

Categories