Post selected option's value to second page using sessions - php

I've been trying to post the value of two selected dropdown menu's using the SESSIONS method, however there seems to be an issue because when submitted the second page displays the PHP code only. Here are the relevant snippets of code:
shop.php
<form action="processing.php" method="post"> <div class="item">
<span class="caption">Essential Gray Suit<br />£459</span>
<select name="size1" class="size" id="size1" onchange="showDiv(this)">
<optgroup label="Size">
<option value="0">SELECT SIZE</option>
<option value="1">XS</option>
<option value="2">S</option>
<option value="3">M</option>
<option value="4">L</option>
<option value="5">XL</option>
</select>
<div id="quantity1" style="display: none;">
<select name="quantity1" class="size" onchange="showCart(this)">
<optgroup label="Quantity">
<option value="0">SELECT QUANTITY</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
</select>
</div>
<input type="submit" value="Submit" name="submit" id="submit">
</form>
processing.php
<?php
session_start();
if (isset($_POST['submit'])) {
$_SESSION['size1'] = $_POST['size1'];
}
echo $_SESSION['size1'];
?>

Related

How to get value from combobox into next url

I wonder if anyone can help my problem, in which way I can get value from combobox selection into next url by clicking so I can make it as a parameter to the pdf report.
this is my code to add some combobox :
<form method="GET">
<label class="col-sm-3 control-label">Bulan</label>
<div class="col-sm-2">
<select name="bln" class="form-control">
<option value="1">Januari</option>
<option value="2">Februari</option>
<option value="3">Maret</option>
<option value="4">April</option>
<option value="5">Mei</option>
<option value="6">Juni</option>
<option value="7">Juli</option>
<option value="8">Agustus</option>
<option value="9">September</option>
<option value="10">Oktober</option>
<option value="11">November</option>
<option value="12">Desember</option>
</select>
</div>
<br>
<br>
<label class="col-sm-3 control-label">Tahun</label>
<div class="col-sm-2">
<select name="thn" class="form-control">
<option value="2018">2018</option>
<option value="2019">2019</option>
<option value="2020">2020</option>
<option value="2021">2021</option>
<option value="2022">2022</option>
<option value="2023">2023</option>
<option value="2024">2024</option>
<option value="2025">2025</option>
</select>
</div>
</form>
<?php
if (isset($_GET['bln'])) {
$bln = $_GET['bln'];
$thn = $_GET['thn'];
}
?>
<a class="btn btn-success" href="rep-cuti-tahunan-all.php?bln="$bln"&thn="$thn"">Print</a>
so I would like to put $bln and $thn into <a class="btn btn-success" href="rep-cuti-tahunan-all.php?bln="$bln"&thn="$thn"">Print</a>
and get my report in pdf exactly according to that parameters
any suggestions?
You don't have to add it as a parameter.Just change your form like this.
<form method="GET" action ="rep-cuti-tahunan-all.php">
....
</form>
then on your php file, you fetch the selected value.
<?php
....
if (isset($_GET['bln'])) {
$bln = $_GET['bln'];
$thn = $_GET['thn'];
}
....
//Do your print method ...
?>

Storing SESSION data all within a single form [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 6 years ago.
Improve this question
I am trying to store data in $_SESSION variables so I can use it in other parts of the form.
I have an input for team name which I need to use within a drop down a couple of steps down the form, the team name come from the user input only.
Im struggling to pass this data throughout the form and then post it at the end.
The session is being set in header.php
<?php
if(!empty($_POST)) {
$_SESSION['dashboardName'] = $_POST['dashboardName'];
$_SESSION['teamName'] = $_POST['teamName'];
$_SESSION['firstName'] = $_POST['firstName'];
$_SESSION['lastName'] = $_POST['lastName'];
$_SESSION['memberTeam'] = $_POST['memberTeam'];
$_SESSION['stenData'] = $_POST['stenData'];
$_SESSION['score_1'] = $_POST['score_1'];
$_SESSION['score_2'] = $_POST['score_2'];
$_SESSION['score_3'] = $_POST['score_3'];
$_SESSION['score_4'] = $_POST['score_4'];
$_SESSION['score_5'] = $_POST['score_5'];
$_SESSION['score_6'] = $_POST['score_6'];
$_SESSION['score_7'] = $_POST['score_7'];
$_SESSION['score_8'] = $_POST['score_8'];
}
?>
<form action="" method="POST">
<!-- STEP :: 1 -->
<div class="step-one">
<h1>STEP 1</h1>
<input type="text" name="dashboardName" required placeholder="Dashboard Name" value="<?php echo $_SESSION['dashboardName']; ?>">
<button class="step-one-next">Next</button>
</div>
<!-- STEP :: 2 -->
<div class="step-two">
<h1>STEP 2</h1>
<input type="text" name="teamName" placeholder="Team name" required value="<?php echo $_SESSION['teamName']; ?>">
<button class="step-two-previous">Previous</button>
<button class="step-two-next">Next</button>
</div>
<!-- STEP :: 3 -->
<div class="step-three">
<h1>STEP 3</h1>
<input type="text" name="firstName" placeholder="First Name" required value="<?php echo $_SESSION['firstName']; ?>">
<input type="text" name="lastName" placeholder="Last Name" required value="<?php echo $_SESSION['lastName']; ?>">
<button class="step-three-previous">Previous</button>
<button class="step-three-next">Next</button>
</div>
<!-- STEP :: 4 -->
<div class="step-four">
<h1>STEP 4</h1>
<select name="memberTeam">
<option><?php echo $_SESSION['teamName']; ?></option>
</select>
<button class="step-four-previous">Previous</button>
<button class="step-four-next">Next</button>
</div>
<!-- STEP :: 5 -->
<div class="step-five">
<h1>STEP 5</h1>
<textarea name="stenData" placeholder="Paste Sten Data..." required><?php echo $_SESSION['stenData']; ?></textarea>
<button class="step-five-previous">Previous</button>
<button class="step-five-next">Next</button>
</div>
<!-- STEP :: 6 -->
<div class="step-six">
<h1>STEP 6</h1>
<select name="score_1">
<option selected="selected"><?php echo $_SESSION['score_1']; ?></option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
</select>
<select name="score_2">
<option selected="selected"><?php echo $_SESSION['score_2']; ?></option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
</select>
<select name="score_3">
<option selected="selected"><?php echo $_SESSION['score_3']; ?></option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
</select>
<select name="score_4">
<option selected="selected"><?php echo $_SESSION['score_4']; ?></option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
</select>
<select name="score_5">
<option selected="selected"><?php echo $_SESSION['score_5']; ?></option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
</select>
<select name="score_6">
<option selected="selected"><?php echo $_SESSION['score_6']; ?></option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
</select>
<select name="score_7">
<option selected="selected"><?php echo $_SESSION['score_7']; ?></option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
</select>
<select name="score_8">
<option selected="selected"><?php echo $_SESSION['score_8']; ?></option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
</select>
<button class="step-six-previous">Previous</button>
<button class="step-six-next">Next</button>
</div>
<!-- STEP :: 7 -->
<div class="step-seven">
<h1>STEP 7</h1>
<p><?php echo $_SESSION['dashboardName']; ?></p>
<button class="step-seven-previous">Previous</button>
<input type="submit" name="test" value="Submit">
</div>
</form>
<script>
$(".step-one-next").click(function(){
$(".step-one").hide();
$(".step-two").show();
});
$(".step-two-previous").click(function(){
$(".step-two").hide();
$(".step-one").show();
});
$(".step-two-next").click(function(){
$(".step-two").hide();
$(".step-three").show();
});
$(".step-three-previous").click(function(){
$(".step-three").hide();
$(".step-two").show();
});
$(".step-three-next").click(function(){
$(".step-three").hide();
$(".step-four").show();
});
$(".step-four-previous").click(function(){
$(".step-four").hide();
$(".step-three").show();
});
$(".step-four-next").click(function(){
$(".step-four").hide();
$(".step-five").show();
});
$(".step-five-previous").click(function(){
$(".step-five").hide();
$(".step-four").show();
});
$(".step-five-next").click(function(){
$(".step-five").hide();
$(".step-six").show();
});
$(".step-six-previous").click(function(){
$(".step-six").hide();
$(".step-five").show();
});
$(".step-six-next").click(function(){
$(".step-six").hide();
$(".step-seven").show();
});
$(".step-seven-previous").click(function(){
$(".step-seven").hide();
$(".step-six").show();
});
</script>
So the end goal is to input the inputs at each stage, name the team and then the team names be available in the drop down on the memberTeam <select>
Every time you hit Next button, the form data don't post to server. You can change to <button type="submit" class="step-one-next">Next</button> (add type as submit), but you need to handle which step you're in and which step is next when hit Next. Otherwise, it's easier to use JavaScript.
Updated using jQuery:
https://jsfiddle.net/79nj8e7p/1/
Sorry, I don't have enough reputation to put as comment.

How should I make the php script for a contact form from multiple select dependencies

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>

How do I limit form options based on previous entry & leave all fields (including file selection) populated on submittion

I have the current form:
<form name="estimate" action="live_preview.php" method="post"enctype="multipart/form-data">
<label for="file">Upload File 1:</label>
<input type="file" name="file" id="file"/>
<label for="qty1">Quantity:</label>
<select name="qty1">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
</select>
<br>
<label for="file">Upload File 2:</label>
<input type="file" name="file2" id="file2"/>
<label for="qty2">Quantity:</label>
<select name="qty2">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
</select>
<br>
<label for="file">Upload File 3:</label>
<input type="file" name="file3" id="file3"/>
<label for="qty3">Quantity:</label>
<select name="qty3">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
</select>
<br>
<label for="file">Upload File 4:</label>
<input type="file" name="file4" id="file4"/>
<label for="qty4">Quantity:</label>
<select name="qty4">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
</select>
<br>
<label for="file">Upload File 5:</label>
<input type="file" name="file5" id="file5"/>
<label for="qty5">Quantity:</label>
<select name="qty5">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
</select>
<br>
<br>
<label for="meterial">Meterial:</label>
<select name="material">
<option value="PLA">PLA (0.60$ / Gram)</option>
<option value="ABS">ABS (0.60$ / Gram)</option>
<option value="POLYCARB">PolyCarb (1.80$ / Gram)</option>
<option value="NYLON">Nylon (1.20$ / Gram)</option>
</select>
|
<label for="color">Color:</label>
<select name="color">
<option value="WHITE">White</option>
<option value="BLACK">Black</option>
<option value="RED">Red</option>
<option value="GREEN">Green</option>
<option value="GRAY">Gray</option>
</select>
|
<label for="delivery">Delivery Method:</label>
<select name="delivery">
<option value="PICK UP">Pick Up (Free)</option>
<option value="SHIPPED">Shipped (+10$)</option>
</select>
|
<label for="marketing">Marketing?</label>
<select name="marketing">
<option value="YES">YES</option>
<option value="NO">NO</option>
</select>
<br>
<label for="infill">Infill: 20%</label>
<input type="range" name="infill" id="infill" value="20" min="20" max="90" step="10" onchange="printValue('infill','rangeValue1')"/>
90%
<input id="rangeValue1" type="text" size="2"/>
<br>
<ul class="buttons vertical">
<input type="submit" class="button fit scrolly" name="submit" value="Refresh Estimate" />
</ul>
</form>
What I'm trying to do is:
Being able to limit the colour selection based on the type of material previously chosen
Upon submission, process php file while still keeping all fields populated so that if user isn't happy with price given, they can modify some settings and get a new "estimate"
have the following actions happen w/o a page refresh (not a priority)
Thank you very much for taking the time to read this! Its extremely appreciated.
1.
This would be achieved with client-side code. Javascript / jQuery is what you need here.
2.
Unfortunately, file fields can't be kept populated when you reload the page (or redirect back). You can keep them populated by using AJAX to send your form contents, but it can be quite complex and sending files with AJAX will only work in modern browsers.
3.
AJAX is what you are looking for if you want server actions to happen without a page refresh. Look at jQuery $.post. My suggestion is that you have your form which people begin to fill out. The site will check the inputs along the way and suggest prices without refreshing the page, and once they are happy and ready to go, they submit the form which will upload the files and "refresh the page".
on 2, php only solution: You can keep the fields populated on submission by adding a placeholder to the input field. The placeholder gets the submitted value ($_POST('value') or similar). Just make sure that the value isn't lost if you have several fields and thus several submits before the customer hits the final "all fine" button, maybe use $_SESSION for that.

IF POST Variables equals then redirect

Im trying to get form post values and if they match certain criteria redirect only my page doesnt seem to...
I have a form with multiple input fields
HTML
<form method="post" action="?page_id=151">
<div style="display: block;" id="Q1">
<label for="vehicleType">1. What type of vehicles do you have?</label>
<select id="vehicleType" name="vehicleType">
<option selected="selected" value="choose">Please choose</option>
<option value="hgv">HGV</option>
<option value="psv">PSV</option>
<option value="lgv">LGV</option>
<option value="car">Car</option>
<option value="mixed">Mixed Fleet</option>
</select>
</div>
<div id="Q2group1">
<label for="coverageRegion">2. Do you require national or international coverage?</label>
<select id="coverageRegion" name="coverageRegion">
<option selected="selected" value="choose">Please choose</option>
<option value="national">National</option>
<option value="international">International</option>
</select>
</div>
<div id="Q2others">
<label for="pricing">2. Do you prefer a fixed weekly price or a pump-related price?</label>
<select id="pricing" name="pricing">
<option selected="selected" value="choose">Please choose</option>
<option value="fixed">Weekly fixed price</option>
<option value="pump">Pump-related price</option>
</select>
</div>
<div id="Q3group1">
<label for="locationType">3. What type of site do you prefer?</label>
<select id="locationType" name="locationType">
<option selected="selected" value="choose">Please choose</option>
<option value="truckstops">Truck stops at lowest price</option>
<option value="motorway">Branded motorway sites</option>
</select>
</div>
<div id="Q3others">
<label for="siteCoverage">3. What site coverage do you need?</label>
<select id="siteCoverage" name="siteCoverage">
<option value="choose">Please choose</option>
<option value="countysites">County</option>
<option value="nationalsites">National</option>
</select>
</div>
<div id="Q4others">
<label for="county">4. Select your county:</label>
<select id="county" name="county">
<option value="choose">Please choose</option>
<optgroup label="England">
<option>Bedfordshire</option>
<option>Berkshire</option>
<option>Bristol</option>
<option>Tyrone</option>
</optgroup>
</select></div>
<div id="searchbuttondiv"> <input type="submit" id="searchbutton" onclick="_gaq.push(['_trackEvent', 'Fuel Card Search', 'Homepage Select Criteria'])"> </div>
</form>
PHP
if ($_POST['vehicleType'] == 'car' && $_POST['pricing'] == 'fixed' && $_POST['coverageRegion'] == 'national') {
echo '<script>alert("hi");</script>';
// header('Location: /car-weekly-national/');
}
One of your conditions is falling (and because they are all bound by AND, all of the if statement fails.
Have an else statement where you var_dump all relevant variables and see what's wrong.
Sorry everyone, oversight by me, I was checking to see if the wrong variable had been posted, wouldn't have found it if it wasn't for the suggestions to add an else statement, thanks!

Categories