I'm currently doing an appointment scheduling system.
So, I have time slot of 15 minutes for each hour and, for 9:00am, 10:00am, 11:00am, 2:00pm, 3:00pm, 4:00pm, I will only put 1 patient for these time slot. Then for the rest time slot it will be 2 patients.
How do I code this in PHP?
Below is the code I did for the form:
<form method="POST" action="MAppointment.php">
Patient Name: <input type="text" name="name" class="form-control" required>
<br>
Phone Number: <input type="text" name="contact" class="form-control" required>
<br>
Appointment Date: <input type="date" name="date" class="form-control" onchange="AjaxFunctionForTime" required>
<br>
Appointment Time: <select name="time" class="btn1" id="time" required>
<option value="9:00">9:00am</option>
<option value="9:15">9:15am</option>
<option value="9:30">9:30am</option>
<option value="10:00">10:00am</option>
<option value="10:15">10:15am</option>
<option value="10:30">10:30am</option>
<option value="11:00">11:00am</option>
<option value="11:15">11:15am</option>
<option value="11:30">11:30am</option>
<option value="14:00">2:00pm</option>
<option value="14:15">2:15pm</option>
<option value="14:30">2:30pm</option>
<option value="15:00">3:00pm</option>
<option value="15:15">3:15pm</option>
<option value="15:30">3:30pm</option>
<option value="16:00">4:00pm</option>
<option value="16:15">4:15pm</option>
<option value="16:30">4:30pm</option>
<br>
<input type="submit" value="Book the Appointment">
And this is the code in MAppointment.php
<?php
include('session.php');
$name=$_POST['name'];
$phoneNumber=$_POST['contact'];
$appointmentDate=$_POST['date'];
if(isset($_POST['time'])){
$appointmentTime=$_POST['time'];
mysqli_query($conn,"insert into appointment (name,contact,apptdate,appttime) values ('$name','$phoneNumber','$appointmentDate','$appointmentTime')");
$pid=mysqli_insert_id($conn);
}
?>
<script>
window.alert('Appointment booked successfully!');
window.history.back();
</script>
<?php
?>
Related
I am trying to create a dynamic HTML form where the fields displayed are based on inputs in the field above it. So far, I have only found resources that work in JS but I was wondering if there was a pure PHP way to do it.
To give some context: I would like to create a form for a user to set their goal. The 'How Much' and 'programme duration' fields are dependent on the 'goal type' field. Ie. if They choose a muscle building goal then it will only show 5% etc. Here is my code so far...
Much appreciated in advanced!
<?php
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
session_start();
if (isset($_SESSION['Username'])) {
?>
<html>
<head>
</head>
<body>
<h1>Please set your goal and programme type</h1>
<form method="POST" action="Set_Goal_process.php" >
<label for="Sex"><b>Sex: </b></label>
<select name="Sex" id="Sex" required>
<option value="Male">Male</option>
<option value="Female">Female</option>
</select>
<label for="Age"><b>Age: </b></label>
<input type="number" name="Age" id="Age" value="Age" required>
<label for="Height"><b>Height: </b></label>
<input type="number" name="Height" id="Height" required>
<label for="Current Weight"><b>Current Weight: </b></label>
<input type="number" name="Initial_weight" id="Initial Weight" required>
<br><br><br><br><br><br><br><br><br>
<label for="Activity level"><b>Activity level: </b></label>
<select name="Activity_level" id="Activity level" required>
<option value=1>Sedentary</option>
<option value=2>Mostly sedentary</option>
<option value=3>Lightly active</option>
<option value=4>Highly active</option>
</select>
<label for="Goal type"><b>Goal type: </b></label>
<select name="Goal_type" id="Goal type" required>
<option value=1>Fat Loss</option>
<option value=2>Maintenance</option>
<option value=3>Muscle Building</option>
</select>
<label for="How much"><b>How much: </b></label>
<select name="How_much" id="How much" default="0" required>
<option value=-10>-10%</option>
<option value=-7.5>-7.5%</option>
<option value=-5>-5%</option>
<option value=-2.5>-2.5%</option>
<option value=0 selected>0%</option>
<option value=2.5>2.5%</option>
<option value=5>5%</option>
</select>
<!-- comment make both How much and program duration conditional -->
<label for="Program Duration"><b>Program Duration: </b></label>
<select name="Program_duration" id="Program Duration" required>
<option value=4>4 weeks</option>
<option value=8>8 weeks</option>
<option value=12 selected>12 weeks</option>
</select>
<label for="Experience_level"><b>Experience level: </b></label>
<select name="Expereince_level" id="Expereince level" required>
<option value=1 selected>Beginner</option>
<option value=2>Novice</option>
<option value=3 >Intermediate</option>
<option value=4 >Advanced</option>
</select>
<label for="Sessions per week">Sessions per week:</label>
<input type="number" name="Sessions_per_week" id="Sessions per week" min="1" max="7" required>
<label for="Start date">Start date:</label>
<input type="date" name="Start date"id="Start date" >
<br><br>
<input type="submit" name="Submit" value="Get Started!"required>
</form>
</body>
</html>
<?php
}else {
session_destroy();
header("location: index.php");
}
Before anyone yells Repost, there aren't many cases like mine that I've seen.I have a contact form that has the possibility to have a main Select option, a sub-Select option and then a sub-Select option of that one. Overall, There are 27 options to choose from and I think I could make the php give me all 27 of those and then do a "yes they selected this one but not that one" type of report, but I digress.How do I have the php script for my contact form send only what is selected from a possible three-tiered select menu? EDIT: I'm totally willing to use something other than PHP to help facilitate this, I just need help with the PHP script as well.Edit: To be clear, I'm try to create and populate a php script, not valdiate the form/check that all required sections are filled out.Code
<form action="sending.php" method="POST" enctype="multipart/form-data">
<input type="hidden" name="action" value="submit">
Name:<br>
<input name="name" type="text" value="" size="30"/><br>
Email:<br>
<input name="email" type="text" value="" size="30"/><br>
Service:<br>
<select name="service" id="service" class="service">
<option>Select a Service</option>
<option value="screen" data-target="devices" id="screen">Screen Replacement</option>
<option value="comp" data-target="comp" id="comp">Computer Work</option>
<option value="misc" data-target="misc" id="misc">Miscellaneous</option>
</select>
<div style="display:none" id="service-devices">
<select name="devices" id="devices" class="devices">
<option>Select a Device</option>
<option value="iphone" data-target="iphones" id="iphone">iPhone</option>
<option value="ipad" data-target="ipads" id="ipad">iPad</option>
<!--<option value="watch" id="watch">Apple Watch</option> -->
<option value="android" id="android">Android</option>
</select>
<div style="display:none" id="devices-iphones">
<select name="iphone" id="iphone" class="iphone">
<!--<option value="iphone6s" id="iphone6s">iPhone 6S</option> -->
<!--<option value="iphone6splus" id="iphone6splus">iPhone 6S Plus</option>-->
<option>Select a Model</option>
<option value="iphone6" id="iphone6">iPhone 6</option>
<option value="iphone6plus" id="iphone6plus">iPhone 6 Plus</option>
<option value="iphone5s" id="iphone5s">iPhone 5S</option>
<option value="iphone5c" id="iphone5c">iPhone 5C</option>
<option value="iphone5" id="iphone5">iPhone 5</option>
<option value="iphone4s" id="iphone4s">iPhone 4S</option>
<option value="iphone4" id="iphone4">iPhone 4</option>
</select>
</div>
<div style="display:none" id="devices-ipads">
<select name="ipad" id="ipad" class="ipad">
<option>Select a Model</option>
<option value="ipadmini3" id="ipadmini3">iPad Mini 3</option>
<option value="ipadmini2" id="ipadmini2">iPad Mini 2</option>
<option value="ipadair" id="ipadair">iPad Air</option>
<option value="ipad4" id="ipad4">iPad 4</option>
<option value="ipad3" id="ipad3">iPad 3</option>
<option value="ipadmini" id="ipadmini">iPad Mini</option>
<option value="ipad2" id="ipad2">iPad 2</option>
</select>
</div>
</div>
<div style="display:none" id="service-comp">
<select name="compwork" id="compwork" class="compwork">
<option value="desktopcreation" id="desktopcreation">Desktop Creation</option>
<option value="desktopbuild" id="desktopbuild">Desktop Build</option>
<option value="hardwareupgrades" id="hardwareupgrades">Hardware Upgrades</option>
<option value="datarecovery" id="datarecovery">Data Recovery/Transfer</option>
<option value="spywareremoval" id="spywareremoval">Spyware/Adware Removal</option>
<option value="virusremoval" id="virusremoval">Virus Removal</option>
</select>
</div>
<div style="display:none" id="service-misc">
<select name="miscellaneous" id="miscellaneous" class="miscellaneous">
<option value="networksecurity" id="networksecurity">Network Security</option>
<!--<option value="webdesign" id="webdesign">Website Design</option>-->
</select>
</div><br>
Message:<br>
<textarea name="message" rows="7" cols="30"></textarea><br>
<input type="submit" value="Submit Request"/>
</form>
I assume that you do have jquery to display the relevant select boxes upon selection of devices etc... I have made a few changes in your html form, like adding id="form" in your form tag. Also added value="" for options like "Please select Service".. Here is the code. Hope this helps.. Refer to this as well..
Jquery form submit to check empty fields
<form id="form" action="sending.php" method="POST" enctype="multipart/form-data">
<input type="hidden" name="action" value="submit">
Name:<br>
<input name="name" type="text" value="" size="30"/><br>
Email:<br>
<input name="email" type="text" value="" size="30"/><br>
Service:<br>
<select name="service" id="service" class="service">
<option value="">Select a Service</option>
<option value="screen" data-target="devices" id="screen">Screen Replacement</option>
<option value="comp" data-target="comp" id="comp">Computer Work</option>
<option value="misc" data-target="misc" id="misc">Miscellaneous</option>
</select>
<div style="display:none" id="service-devices">
<select name="devices" id="devices" class="devices">
<option value="">Select a Device</option>
<option value="iphone" data-target="iphones" id="iphone">iPhone</option>
<option value="ipad" data-target="ipads" id="ipad">iPad</option>
<!--<option value="watch" id="watch">Apple Watch</option> -->
<option value="android" id="android">Android</option>
</select>
<div style="display:none" id="devices-iphones">
<select name="iphone" id="iphone" class="iphone">
<!--<option value="iphone6s" id="iphone6s">iPhone 6S</option> -->
<!--<option value="iphone6splus" id="iphone6splus">iPhone 6S Plus</option>-->
<option value="">Select a Model</option>
<option value="iphone6" id="iphone6">iPhone 6</option>
<option value="iphone6plus" id="iphone6plus">iPhone 6 Plus</option>
<option value="iphone5s" id="iphone5s">iPhone 5S</option>
<option value="iphone5c" id="iphone5c">iPhone 5C</option>
<option value="iphone5" id="iphone5">iPhone 5</option>
<option value="iphone4s" id="iphone4s">iPhone 4S</option>
<option value="iphone4" id="iphone4">iPhone 4</option>
</select>
</div>
<div style="display:none" id="devices-ipads">
<select name="ipad" id="ipad" class="ipad">
<option value="">Select a Model</option>
<option value="ipadmini3" id="ipadmini3">iPad Mini 3</option>
<option value="ipadmini2" id="ipadmini2">iPad Mini 2</option>
<option value="ipadair" id="ipadair">iPad Air</option>
<option value="ipad4" id="ipad4">iPad 4</option>
<option value="ipad3" id="ipad3">iPad 3</option>
<option value="ipadmini" id="ipadmini">iPad Mini</option>
<option value="ipad2" id="ipad2">iPad 2</option>
</select>
</div>
</div>
<div style="display:none" id="service-comp">
<select name="compwork" id="compwork" class="compwork">
<option value="desktopcreation" id="desktopcreation">Desktop Creation</option>
<option value="desktopbuild" id="desktopbuild">Desktop Build</option>
<option value="hardwareupgrades" id="hardwareupgrades">Hardware Upgrades</option>
<option value="datarecovery" id="datarecovery">Data Recovery/Transfer</option>
<option value="spywareremoval" id="spywareremoval">Spyware/Adware Removal</option>
<option value="virusremoval" id="virusremoval">Virus Removal</option>
</select>
</div>
<div style="display:none" id="service-misc">
<select name="miscellaneous" id="miscellaneous" class="miscellaneous">
<option value="networksecurity" id="networksecurity">Network Security</option>
<!--<option value="webdesign" id="webdesign">Website Design</option>-->
</select>
</div><br>
Message:<br>
<textarea name="message" rows="7" cols="30"></textarea><br>
<input type="submit" value="Submit Request"/>
<script src="js/jquery-1.10.2.min.js"></script>
<script>
$(document).ready(function() {
$('select').change(function(){
var boxid = $(this).children('option:selected').attr('data-target');
alert(boxid);
if(boxid == "devices") {
var divId = "service-" + boxid;
}
document.getElementById(divId).style.display = "block";
});
$("form").submit(function(){
// $(':input[value=""]').attr('disabled', true);
$("input[type='text'],select,input[type='password'],textarea",this).each(function() {
if($(this).val().trim() == "") {
$(this).attr('disabled', true);
}
})
});
});
</script>
I have a project (index.php) that is essentially a HTML webpage. I am trying to use an 'include' function to bring in the header and footer (header.php, footer.php). I'm also trying to have the current date automatically load in a textbox. While I believe the syntax for all of these are correct, no actual PHP statements seem to execute or get recognized. I discovered this by adding a simple echo statement to the page.
Can anyone give me advice? I'm at a loss.
HTML Input Value for date:
<p><label>Order Date:</label> <input value="<?php echo date('m/d/Y'); ?>" maxlength="20" size="10" name="txtOrderDate" type="text" pattern="\d{1,2}/\d{2}/\d{4}" required/></p>
Statements used for header/footer (difference obviously being file name, referenced first and last line of index.php):
<?php include '../view/header.php'; ?>`
Header.php:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<!-- header -->
<head>
<title>Order Form</title>
<link rel="stylesheet" type="text/css" href="../view/main.css" />
</title>
</head>
Footer.php:
<div id="footer">
<p>
© <?php echo date("Y"); ?> Ordering Form
</p>
</div>
</body>
Index.php
(the beginning/end got broken up a bit, but I think everything is there)
<!-- include header -->
<?php require_once '../view/header.php'; ?>
<?php $today = date("m/d/Y"); ?>
<body>
<h1> Order Form </h1>
<div id="wrapper">
<form method="post" action="../model/A03_OrderForm.php">
<fieldset>
<!-- body -->
<body>
<div id="wrapper">
<form method="post" action="../model/A03_OrderForm.php">
<fieldset>
<div class="container">
<p><label>Order Date:</label> <input value="<?php echo $today; ?>" maxlength="20" size="10" name="txtOrderDate" type="date" pattern="\d{1,2}/\d{2}/\d{4}" required/></p>
</div></br>
<div class="container">
<p><label>Salutation:</label> <select name="selSalutation"> <option selected="selected" value="">(none)</option><option value="Mr">Mr.</option><option value="Mrs">Mrs.</option><option value="Ms">Ms.</option><option value="Miss">Miss</option><option value="Dr">Dr.</option></select></p>
<p><label>First Name:</label> <input maxlength="20" name="txtFirstName" type="text" pattern="[A-Za-z]+" required/></p>
<p><label>Middle Initial:</label> <input maxlength="1" size="2" name="txtMiddleInit" pattern="[A-Za-z]" "type="text" /></p>
<p><label>Last Name:</label> <input maxlength="20" name="txtLastName" type="text" pattern="[A-Za-z]+" required/></p>
<p><label>Suffix:</label> <select name="selSuffix"> <option selected="selected" value="">(none)</option><option value="Jr">Jr</option><option value="Sr">Sr</option><option value="I">I</option><option value="II">II</option><option value="III">III</option><option value="IV">IV</option><option value="V">V</option></select></p>
</div></br>
<div class="container">
<p><label>Address:</label> <input maxlength="30" size="36" name="txtAddress" type="text" required/></p>
<p><label>City:</label> <input maxlength="20" name="txtCity" type="text" pattern="[A-Za-z0-9\s]+" required/></p>
<p><label>State:</label> <select name="selState"> <option selected="selected" value="DEFAULT">(none)</option> <option value="AL">AL</option> <option value="AK">AK</option> <option value="AZ">AZ</option> <option value="AR">AR</option> <option value="CA">CA</option> <option value="CO">CO</option> <option value="CT">CT</option> <option value="DE">DE</option> <option value="DC">DC</option> <option value="FL">FL</option> <option value="GA">GA</option> <option value="GU">GU</option> <option value="HI">HI</option> <option value="ID">ID</option> <option value="IL">IL</option> <option value="IN">IN</option> <option value="IA">IA</option> <option value="KS">KS</option> <option value="KY">KY</option> <option value="LA">LA</option> <option value="ME">ME</option> <option value="MD">MD</option> <option value="MA">MA</option> <option value="MI">MI</option> <option value="MN">MN</option> <option value="MS">MS</option> <option value="MO">MO</option> <option value="MT">MT</option> <option value="NE">NE</option> <option value="NV">NV</option> <option value="NH">NH</option> <option value="NJ">NJ</option> <option value="NM">NM</option> <option value="NY">NY</option> <option value="NC">NC</option> <option value="ND">ND</option> <option value="OH">OH</option> <option value="OK">OK</option> <option value="OR">OR</option> <option value="PA">PA</option> <option value="RI">RI</option> <option value="SC">SC</option> <option value="SD">SD</option> <option value="TN">TN</option> <option value="TX">TX</option> <option value="UT">UT</option> <option value="VT">VT</option> <option value="VA">VA</option> <option value="WA">WA</option> <option value="WV">WV</option> <option value="WI">WI</option> <option value="WY">WY</option></select></p>
<p><label>Postal Code:</label> <input maxlength="10" size="14" name="txtPostalCode" type="text" pattern="[0-9]{5}" required/></p>
</div></br>
<div class="container">
<p><label>Item No:</label> <input value="01" maxlength="30" name="txtItem" type="number" required/></p>
<p><label>Quantity:</label> <input value="0" maxlength="20" size="14" name="txtQuantity" type="number" required/></p>
<p><label>Price:</label> <input value="0.00" maxlength="50" size="14" name="txtPrice" type="number" step="0.01" required/></p>
</div></br>
<div class="submit"><input class="button" value="Submit" type="submit" name="btnSubmit" /> <input class="button" value="Reset" type="reset" name="btnReset" />
<div></div>
</div>
</form>
</fieldset></div>
<!-- include footer -->
<?php require_once '../view/footer.php'; ?>
As a reminder, none of the PHP statements execute on screen.
Thanks for the input thus far.
One thing to add is the webpage loads and operates just fine except the header/footer are not included (therefore no CSS either) and the date does not load in the textbox. Beyond those two things, it's golden.
ANSWERS TO COMMENTS:
Using XAMPP and Notepad++
Local
Not sure what is meant by the verbatim comment. When I view the source code from the page it is exactly as written in my text editor?
<?php $today = date("m.d.y"); ?>
<p><label>Order Date:</label> <input value="<?php echo $today; ?>" name="txtOrderDate" type="date"></p>
try like this
2nd
make new php file (time.php) copy code from here to it run it on your pc
<?php
$today = date("m.d.y"); // 03.10.01
echo = $today;
?>
is that work?
I think that beater solution is to use date picker for this u will not have problem in future how user use date m.d.y m/d/y and so on.
and if possible can u share all code?
Solved! I copied the text from 'index.php', deleted the file, and pasted it onto a new sheet. The textbox value loads today's date and the header/footer were successfully displayed.
Thank you all for the replies and ideas. Greatly appreciated!
Here's part of my form:
<label for="User">Select your account type:</label>
<select name="usertype" for="usertype" id="usertype" required>
<option value="1">Employee</option>
<option value="2">Manager</option>
</select>
<label for="User">Select the company you work for:</label>
<select name="company" for="company" id="company" required>
<?php
include ('processors/generate-company-list.php');
?>
<option value="NULL">I'll create my own company later</option>";
</select>
I only want <option value="NULL">I'll create my own company later</option> to be available if they choose to be a manager earlier in the form. Is this possible?
<script type="text/javascript">
function check(){
var usertype=document.getElementById("usertype").value;
if(usertype==2){
document.getElementById("company").selectedIndex = "0";
document.getElementById("company").disabled=true;
}else{
document.getElementById("company").disabled=false;
}
}
</script>
<label for="User">Select your account type:</label>
<select name="usertype" for="usertype" id="usertype" required onchange='check();'>
<option value="1">Employee</option>
<option value="2">Manager</option>
</select>
<label for="User">Select the company you work for:</label>
<select name="company" for="company" id="company" required>
<?php
include ('processors/generate-company-list.php');
?>
<option value="NULL">I'll create my own company later</option>";
<option value="1"> listitem1 </option>";
<option value="1"> listitem2</option>";
</select>
I used javascript function to select 0 index whenever manager is selected and disabled second select box.
I am trying to create a simple form that will send data to a PHP script upon submitting the form. I am able to access all of the textbox values, and have successfully implemented variables for each of them. However, when I try to access the value of a combo box on my form, I get this error in the PHP:
Notice: Undefined index: cmbProvince in C:\inetpub\wwwroot\krAssignment4\scripts\index.php on line 15
HTML
<form id="orderForm" action="scripts/index.php" method="post" onsubmit="return validateForm()">
<fieldset id="customerInfo">
<legend>Customer Information</legend>
<label for="txtFirstName">Name:</label><br>
<input type="text" id="txtFirstName" name="txtFirstName"
placeholder="First Name" autofocus="true"
oninput="formatFirstName()">
<input type="text" id="txtLastName" name="txtLastName"
placeholder="Last Name" oninput="formatLastName()"><br><br>
<label for="txtAddress">Address:</label><br>
<input type="text" id="txtAddress" name="txtAddress" placeholder="Address"
oninput="formatAddress()"><br>
<input type="text" id="txtCity" name="txtCity" placeholder="City"
oninput="formatCity()">
<select id="cmbProvince" name="cmbProvince">
<option value="on">ON</option>
<option value="qc">QC</option>
<option value="mb">MB</option>
<option value="sk">SK</option>
<option value="ab">AB</option>
<option value="bc">BC</option>
<option value="nb">NB</option>
<option value="nl">NL</option>
<option value="ns">NS</option>
<option value="nu">NU</option>
<option value="pe">PE</option>
<option value="nt">NT</option>
<option value="yt">YT</option>
</select><br>
<input type="text" id="txtPostalCode" name="txtPostalCode"
placeholder="Postal Code" oninput="displayPostalCode()">
<br><br>
<!-- Button that will display the order form -->
<input type="button" id="btnOrder" value="Order"
onclick="showOrderInformation()">
</fieldset><br>
<fieldset id="orderInfo">
<legend>Order Information</legend>
<label for="cmbProduct">Product:</label><br>
<select id="cmbProduct">
<option> -- Select -- </option>
<option>Blackberries</option>
</select>
#
<input type="number" id="txtQuantity" name="txtQuantity" value="1"
step="1" min="1" max="50" oninput="displayTotalTax()"><br><br>
</fieldset>
<br><br>
<!-- Button to submit the form to PHP after validation -->
<input type="submit" id="btnSubmit" value="Submit">
</form>
PHP (lines 10 - 19)
/* Capture the user input from the HTML form */
$strFirstName = $_POST['txtFirstName'];
$strLastName = $_POST['txtLastName'];
$strAddress = $_POST['txtAddress'];
$strCity = $_POST['txtCity'];
$strProvince = $_POST['cmbProvince'];
$strPostalCode = $_POST['txtPostalCode'];
Am I typing something wrong? Or missing something? Everything except the combo box is working.
Let me know if I need to include anything else. Thanks!
EDIT
Here is what happens when I try var_dump($_POST);:
Notice: Undefined index: cmbProvince in C:\inetpub\wwwroot\krAssignment4\scripts\index.php on line 15
Notice: Undefined index: cmbProduct in C:\inetpub\wwwroot\krAssignment4\scripts\index.php on line 18
array(6) { ["txtFirstName"]=> string(7) "Kendall"
["txtLastName"]=> string(4) "Roth"
["txtAddress"]=> string(19) "22 Resolution Drive"
["txtCity"]=> string(8) "Millbank"
["txtPostalCode"]=> string(7) "K2K 2K2"
["txtQuantity"]=> string(1) "2" }
Your code works for me with a little bit changes, try this:
<form id="orderForm" action="scripts/index.php" method="post" onsubmit="return validateForm()">
<fieldset id="customerInfo">
<legend>Customer Information</legend>
<label for="txtFirstName">Name:</label><br>
<input type="text" id="txtFirstName" name="txtFirstName"
placeholder="First Name" autofocus="true"
oninput="formatFirstName()">
<input type="text" id="txtLastName" name="txtLastName"
placeholder="Last Name" oninput="formatLastName()"><br><br>
<label for="txtAddress">Address:</label><br>
<input type="text" id="txtAddress" name="txtAddress" placeholder="Address"
oninput="formatAddress()"><br>
<input type="text" id="txtCity" name="txtCity" placeholder="City"
oninput="formatCity()">
<select id="cmbProvince" name="cmbProvince">
<option value="on">ON</option>
<option value="qc">QC</option>
<option value="mb">MB</option>
<option value="sk">SK</option>
<option value="ab">AB</option>
<option value="bc">BC</option>
<option value="nb">NB</option>
<option value="nl">NL</option>
<option value="ns">NS</option>
<option value="nu">NU</option>
<option value="pe">PE</option>
<option value="nt">NT</option>
<option value="yt">YT</option>
</select><br>
<input type="text" id="txtPostalCode" name="txtPostalCode"
placeholder="Postal Code" oninput="displayPostalCode()">
<br><br>
<!-- Button that will display the order form -->
<input type="button" id="btnOrder" value="Order"
onclick="showOrderInformation()">
</fieldset><br>
<fieldset id="orderInfo">
<legend>Order Information</legend>
<label for="cmbProduct">Product:</label><br>
<select id="cmbProduct" name="cmbProduct"> //changes is in this code
<option> -- Select -- </option>
<option value="Blackberries">Blackberries</option>
</select>
#
<input type="number" id="txtQuantity" name="txtQuantity" value="1"
step="1" min="1" max="50" oninput="displayTotalTax()"><br><br>
</fieldset>
<br><br>
<!-- Button to submit the form to PHP after validation -->
<input type="submit" id="btnSubmit" value="Submit">
</form>
In your index.php write:
<?php
if(isset($_POST) && !empty($_POST)){
echo "<pre/>";print_r($_POST);die;
}
?>
Output:-
Array
(
[txtFirstName] => a
[txtLastName] => b
[txtAddress] => c
[txtCity] => d
[cmbProvince] => qc
[txtPostalCode] => e
[cmbProduct] => Blackberries
[txtQuantity] => 1
)
Kendall, you were:
missing name for your <select id="cmbProduct">, and
missing value for your cmbProduct options as well
Putting in 'disabled selected' is a good practice as well as people won't be able to select the 'select' option :)
Your code
<select id="cmbProduct">
<option> -- Select -- </option>
<option>Blackberries</option>
</select>
Correct code
<select id="cmbProduct" name="cmbProduct>
<option value="select" disabled selected> -- Select -- </option>
<option value="blackberries">Blackberries</option>
</select>