html5 form not reacting to submit - php

I've got a simple one-page form, the kind I've written dozens of times, but this behavior is totally new to me. At first, it was submitting on page-load, thus redirecting automatically to the next page in the series. I'm still not sure how I got that to stop, but now it's not doing anything at all when you hit "submit". The page simply sits there.
I've tried stripping out the error-checking scripts, the show/hide script, even jquery itself, then taking the form down to just one input. I tried getting rid of the redirect and just having it output a simple line, then vardump, and still nothing. I hit submit, and no matter what I do, the page just sits there. I've never run into behavior like this before, and firebug et al give me no errors or leads.
If anyone has any ideas at all, no matter how crazy, I'm willing to try. I'm at a loss. Thanks in advance!
<?php
session_start();
include('functions.php');
if ($_POST['submit']) {
$company = $_POST['company'];
$taxid = $_POST['taxid'];
header("location:step2.php");
}
include('head.php'); ?>
<form method="post" name="basic" action="step1.php">
<div class="col70">
<label for="company">Organization/Business name <img src="img/req.jpg" alt="required"></label>
<input type="text" name="company" id="company" value="" />
</div>
<div class="col30">
<label for="taxid">Taxpayer ID# (IEN or SS#) <img src="img/req.jpg" alt="required"></label>
<input type="text" name="taxid" id="taxid" value="" />
</div>
<div class="newcol">
<label for="address">Mailing Address <img src="img/req.jpg" alt="required"></label>
<input type="text" name="address" id="address" value="" />
</div>
<div class="col30 newcol">
<label for="city">City <img src="img/req.jpg" alt="required"></label>
<input type="text" name="city" id="city" value="" />
</div>
<div class="col30">
<label for="state">State <img src="img/req.jpg" alt="required"></label>
<select name="state" id="state" tabindex="<?php echo $tabin; $tabin++; ?>">
<option value="0"></option>
<option value="1">Alabama</option>
</select>
</div>
<div class="col25">
<label for="zipcode">Zip Code <img src="img/req.jpg" alt="required"></label>
<input type="text" name="zipcode" id="zipcode" value="" />
</div>
<fieldset><legend>1. What kind of group/company do you have? <img src="img/req.jpg" alt="required"></legend>
<span id="nfpfp" class="InputGroup">
<label><input name="nfpfp" id="nfpfp_1" type="radio" value="1" />For-profit business.</label>
<label><input name="nfpfp" id="nfpfp_2" type="radio" value="2" />Non-profit 501(c)3 organization.</label>
</span>
</fieldset>
<fieldset><legend>2. How will you use the booth space? Select all that apply. <img src="img/req.jpg" alt="required"></legend>
<span id="type" class="InputGroup">
<label><input name="food" id="type_1" type="checkbox" value="1" />Food sales</label>
<label><input name="retail" id="type_2" type="checkbox" value="2" />Retail sales</label>
<label><input name="activity" id="type_3" type="checkbox" value="3" />Activity</label>
<label><input name="display" id="type_4" type="checkbox" value="4" />Display</label>
<label><input name="other" id="type_5" type="checkbox" value="5" />Other</label>
</span>
</fieldset>
<label for="otherdetails" class="newcol offsides">Enter a short description of your use. (Ex: "BBQ sandwiches", "kite kits", "face painting".) <img src="img/req.jpg" alt="required"></label>
<input type="text" name="otherdetails" id="otherdetails" value="" />
<fieldset><legend>3. Select any/all that apply. Additional questions may appear, if further information is required.</legend>
<span id="additional" class="InputGroup">
<label><input name="raffle" id="raffle_1" type="checkbox" class="switchcheck1" value="1" />I'll be selling raffle tickets and/or holding a raffle at the festival.</label>
<div class="newcol offstate1">
<label for="raffledetails">You'll need written permission from the Exchange Club. Please enter details about the raffle. <img src="img/req.jpg" alt="required"></label>
<textarea name="raffledetails" id="raffledetails" tabindex="<?php echo $tabin; $tabin++; ?>"></textarea>
</div>
<label><input name="trailer" type="checkbox" id="trailer_1" value="1">I'll be bringing a trailer.</label>
<label><input name="outlets" type="checkbox" id="outlets_1" class="switchcheck2" value="1" />I'll require electrical outlets.</label>
<div class="newcol offstate2">
<label for="outletsdetails">How many outlets will you require? <img src="img/req.jpg" alt="required"></label>
<input type="text" name="outletsdetails" id="outletsdetails" />
</div>
</span>
</fieldset>
<input type="button" name="submit" class="a_button" value="submit" />
</form>

The element with name="submit" is of type button and not submit, so it renders a plain button that does nothing (with the intention that you bind some JavaScript to it).
Use type="submit" instead.

Try
<input type="submit" name="submit" class="a_button" value="submit" />
for your submit button.

Related

Autofilling a form with data from a previous form

I have 3 forms in an accordion, one for personal details, billing info and delivery info. I want to autofill the form in the delivery info section if the 'yes' radio button is selected when being asked if their billing and delivery info are the same.
I've looked on the web and can't seem to find anything on filling in a form in an accordion or on the same page.
Here is the HTML:
Details
<img class="editcheckoutbtn" src="<?php echo ROOT; ?>/Images/Buttons/rentals_84x25_edit.png">
<div class="inputsection details">
<form id="detailsform">
<label for="firstname">First Name*</label>
<input type="text" name="forename" />
<label for="lastname">Last Name*</label>
<input type="text" name="surname" />
<label for="email">Email*</label>
<input type="email" name="email" />
<label for="contactnumber">Contact Number*</label>
<input type="text" name="contactnumber"/>
<p class="marketingtext">Do you wish to be contacted by Interski with future promotions?</p>
<label>
<input type="radio" name="marketing" value="yes"/>Yes
</label>
<label>
<input type="radio" name="marketing" value="no"/>No
</label>
<div class="confirmdetailsbtn">
<input type="image" src="<?php echo ROOT; ?>/Images/Buttons/rentals_84x25_confirm.png">
</div>
</form>
</div>
<h3>billing address</h3>
<img class="editcheckoutbtn" src="<?php echo ROOT; ?>/Images/Buttons/rentals_84x25_edit.png">
<div class="inputsection billing">
<form id="billingform">
<label for="firstaddress">1st line of Address*</label>
<input type="text" name="firstaddress"/>
<label for="secondaddress">2nd line of Address</label>
<input type="text" name="secondaddress"/>
<label for="town">Town*</label>
<input type="text" name="town" />
<label for="postcode">Postcode*</label>
<input type="text" name="postcode" />
<label for="country">Country*</label>
<select name="country">
<option></option>
</select>
<p class="billingtext">Is your delivery address the same as your billing address?</p>
<label>
<input type="radio" id="deliveryyes" name="deliveryradio" value="yes"/>Yes
</label>
<label>
<input type="radio" id="deliveryno" name="deliveryradio" value="no"/>No
</label>
<div class="confirmbillingbtn">
<input type="image" src="<?php echo ROOT; ?>/Images/Buttons/rentals_84x25_confirm.png">
</div>
</form>
</div>
<h3>Delivery Address</h3>
<img class="editcheckoutbtn" src="<?php echo ROOT; ?>/Images/Buttons/rentals_84x25_edit.png">
<div class="inputsection delivery">
<form id="deliveryform">
<label for="firstaddress">1st line of Address*</label>
<input type="text" name="delfirstaddress" required/>
<label for="secondaddress">2nd line of Address</label>
<input type="text" name="delsecondaddress"/>
<label for="town">Town*</label>
<input type="text" name="deltown" />
<label for="postcode">Postcode*</label>
<input type="text" name="delpostcode" />
<label for="country">Country*</label>
<select name="delcountry">
<option></option>
</select>
<div class="confirmdeliverybtn">
<input type="image" src="<?php echo ROOT; ?>/Images/Buttons/rentals_84x25_confirm.png">
</div>
<div id="confirmbtn">
<input type="image" src="<?php echo ROOT; ?>/Images/Buttons/rentals_200x38_proceed_to_payment.png">
</div>
This is in complete assumption that as you mentioned its accordion,your page is not refreshed.
You can simply add an event listener on your Radio button to access the required fields and then use them to show wherever required.
Also give proper id's to your input fields
You can do it like this;
$("#deliveryyes").on('click',function(){
var firstaddress = $("#firstaddress").val();
...
// Use those values to populate other fields like
$("#delfirstaddress").val(firstaddress );
...
});
This way you can achieve it.

html form-- need help having new input area populate if radio button is clicked

I am making a basic new customer database with mysql and php. I would like when people click on the radio button"different mailing address" for another couple of input fields to appear for the mailing address. Im not quite sure how to handle this with inputs and not variables. Is there a way to do an if statement here is my html form code below
<form method="POST" action="insert.php">
<fieldset>
<legend>New Customer data</legend>
<label>Complete Below</label>
<div class="controls controls-row">
<input class="span4" name="firstname" type="text" placeholder="First name">
<input class="span3" name="lastname" type="text" placeholder="Last Name">
<input class="span3" name="phone" type="text" placeholder="Phone">
</div>
<div class="controls controls-row">
<input class="span4" name="address" type="text" placeholder="Address">
<input class="span2" name="city" type="text" placeholder="City">
<input class="span1" name="state" type="text" placeholder="State">
</div>
<div class="controls controls-row">
<input class="span4" name="zip" type="text" placeholder="Zip Code">
<input class="span2" name="email" type="text" placeholder="Email">
<input class="span2" name="ccemail" type="text" placeholder="cc email">
</div>
<span class="help-block">When is the customers due date monthly</span>
<label class="radio">
<input type="radio" name="duedate" id="optionsRadios1" value="1" checked>
1st of the month</label>
<label class="radio">
<input type="radio" name="duedate" id="optionsRadios2" value="15">
15th of the month
</label>
<span class="help-block">Mailing address</span>
<label class="radio">
<input type="radio" name="mailingaddress" id="optionsRadios3" value="1" checked>
Check if mailing address is the same as the service address
</label>
<label class="radio">
<input type="radio" name="mailingaddress" id="optionsRadios4" value="0">
Check if mailing address is different
</label>
<button type="submit" class="btn btn-primary">Submit</button>
</fieldset>
</form>
Using jQuery, have two inputs that are initially hidden. Once the user checks the box, '$.show()' on those two inputs. Id have a div containing two inputs, and just show or hide the div depending on whether the box is checked or not
you can try this.
<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js" >
</script>
<script>
$(document).ready(function(){
$("#checkme").on('change',function(){
if($("#checkme").is(":checked")){
$("input#myemail").fadeIn();
}else{
$("input#myemail").fadeOut();
}
});
});
</script>
</head>
<body>
show: <input type="checkbox" id="checkme" /><br />
<input type="text" id="myemail" hidden />
</body>
</html>

Text for checkboxes not appearing in Drupal 6

This is a Drupal 6 build, I'm trying to figure out why the checkboxes are not showing text. Here's an image of what's going on - you can see that the checkboxes are empty.
The actual generated code is as follows:
<div id="attach-wrapper"><div id="edit-files-392-description-wrapper" class="form-item">
<input type="text" class="form-text" value="2011 SchoolAgePQA_Sample_Items.pdf" size="60" id="edit-files-392-description" name="files[392][description]" maxlength="256">
<div class="description"><small>http://domain.org/sites/domain.org/files/2011 SchoolAgePQA_Sample_Items.pdf</small></div>
</div>
492.94 KB<div id="edit-files-392-remove-wrapper" class="form-item">
<input type="checkbox" class="form-checkbox" value="1" id="edit-files-392-remove" name="files[392][remove]">
</div>
<div id="edit-files-392-list-wrapper" class="form-item">
<input type="checkbox" class="form-checkbox" value="1" id="edit-files-392-list" name="cats">
</div>
<div id="edit-files-392-weight-wrapper" class="form-item">
<select id="edit-files-392-weight" class="form-select" name="files[392][weight]"><option value="-8">-8</option><option value="-7">-7</option><option value="-6">-6</option><option value="-5">-5</option><option value="-4">-4</option><option value="-3">-3</option><option value="-2">-2</option><option value="-1">-1</option><option selected="selected" value="0">0</option><option value="1">1</option><option value="2">2</option><option value="3">3</option><option value="4">4</option><option value="5">5</option><option value="6">6</option><option value="7">7</option><option value="8">8</option></select>
</div>
<div id="edit-files-392-private-wrapper" class="form-item">
<input type="checkbox" class="form-checkbox" value="1" id="edit-files-392-private" name="files[392][private]">
</div>
The only thing that sticks out to me is that the value of the checkboxes is exactly the same as the name - and those are all various positive and negative integers.
I've never seen this before, and I'm not sure what might cause it - incorrect configuration setting, poorly coded theme, something else?
There's no label there, so no text is going to be displayed. In drupal it should allow you to change the label and set a value.
The output code should look similar to
<label><input type="checkbox" class="form-checkbox" value="1" id="edit-files-392-list" name="cats">Cats</label>
Try to add label or simply text after your checkbox:
<div id="edit-files-392-list-wrapper" class="form-item">
<label> Text here
<input type="checkbox" class="form-checkbox" value="1" id="edit-files-392-list" name="cats">
</label>
</div>
Or simply :
<div id="edit-files-392-list-wrapper" class="form-item">
<input type="checkbox" class="form-checkbox" value="1" id="edit-files-392-list" name="cats">
Text here
</div>
But i recommande the first solution.

if (!empty($_POST)) not working

I have a php form (code to follow) with a submit button that runs JSON-events.php as its action (method = POST). In the JSON-events code I am testing whether the form has been submitted using if (!empty($_POST)). My issue is that the JSON-events code doesnt seem to be recognising $_POST.
Heres the form side code section.
<div class="simple_overlay" id="searchform">
<form id="myform" class = "cols" action="json-events.php" method="post" >
<h3>Search</h3>
<p>
<label>address/postcode *</label>
<input type="address" id="searchaddress" />
</p>
<p>
<label for="amount">maximum distance:</label>
<input type="text" id="amount" value="5 miles" style=" border:0; color:#43a8c4; font-weight:bold;" />
</p>
<div id="slider-range-min" style="width:130px; margin-left:4px; margin-bottom:20px"></div>
<p id="terms">
<label>Category 1</label>
<input name="cat1" type="checkbox" value="1" checked="checked"/>
</p>
<p id="terms">
<label>Category 2</label>
<input name="cat2" type="checkbox" value="1" checked="checked"/>
</p>
<p id="terms">
<label>Category 3</label>
<input name="cat3" type="checkbox" value="1" checked="checked"/>
</p>
<p id="terms">
<label>Category 4</label>
<input name="cat4" type="checkbox" value="1" checked="checked"/>
</p>
<p id="terms">
<label>Category 5</label>
<input name="cat5" type="checkbox" value="1" checked="checked"/>
</p>
<p id="terms">
<label>Category 6</label>
<input name="cat6" type="checkbox" value="1" checked="checked"/>
</p>
<p id="terms">
<label>Category 7</label>
<input name="cat7" type="checkbox" value="1" checked="checked"/>
</p>
<p id="terms">
<label>Category 8</label>
<input name="cat8" type="checkbox" value="1" checked="checked"/>
</p>
<p id="terms">
<label>Category 9</label>
<input name="cat9" type="checkbox" value="1" checked="checked"/>
</p>
<p id="terms">
<label>Category 10</label>
<input name="cat10" type="checkbox" value="1" checked="checked"/>
</p>
<p>
<input type="hidden" name="searchlat" id="searchlat"/>
</p>
<p>
<input type="hidden" name="searchlong" id="searchlong" />
</p>
<input type="submit" name="search" id="search"/>
<input type="button" value="Check Address" onclick="codeAddressSearch()"/>
<button type="reset">Reset</button>
</form>
</div>
and here is the top part of the JSON...
if (!empty($_POST)) {
any help very much appreciated
empty() will work if $_POST does not have any values (Empty array), but in your case when you submit without any values still you get an array like below and it's not empty:
Array
(
[searchlat] =>
[searchlong] =>
[search] => Submit Query
)
empty() will return true only if $_POST returns
Array (
)
But it's not going to happen as every form will have one Sumbit button.
Just use
if($_POST) {
//php code
}
It will solve your problem.
Learn more about empty() by visiting http://php.net/manual/en/function.empty.php
Do not use
if (!empty($_POST)) {
to check if there is a post done use this:
if( $_SERVER['REQUEST_METHOD'] == 'POST') {
Conditions that you can use with $_POST
if(count($_POST)>0){
//...
}
if(isset($_POST['field_name'])){
//...
}
if( $_SERVER['REQUEST_METHOD'] == 'POST') {
//..
}
Try this
if(!empty($_POST['search']) && isset($_POST['search']))
much better to check for an actual value in the $_POST array. Eg.
if (!empty($_POST['search']))
Using empty() will fail if value 0 is posted
So it is better to use
isset($_POST['FIELD_NAME'])

PHP Form Sending Information to Limbo!

I was told my client's quote form has not been generating very many emails. I have learned that although the form brings you to a confirmation page, the information never reaches the recipient.
I have altered the code so it goes to my office email for testing purposes. If I post code for the form elements below, would someone be able to spot what the problem might be?
Thank you very much!
Link to the quote page is http://autoglass-plus.com/quote.php
First is the form itself:
<form id="quoteForm" name="form" action="form/index.php" method="post">
<fieldset>
<p> <strong>Contact Information:</strong><br />
</p>
<div>
<label for="firstname">First Name:<br />
</label>
<input type="text" size="30" name="firstname" class="txt" id="firstname" />
</div>
<div>
<label for="lastname">Last Name:<br />
</label>
<input type="text" size="30" name="lastname" class="txt" id="lastname" />
</div>
<div>
<label for="address">Address:<br />
</label>
<input type="text" size="30" name="address" class="txt" id="address" />
</div>
<div>
<label for="city">City:<br />
</label>
<input type="text" size="30" name="city" class="txt" id="city" />
</div>
<div>
<label for="state">State:<br />
</label>
<input type="text" size="30" name="state" class="txt" id="state" />
</div>
<div>
<label for="zip">Zip:<br />
</label>
<input type="text" size="30" name="zip" class="txt" id="zip" />
</div>
<div>
<label for="label">Phone:<br />
</label>
<input type="text" size="30" name="phone" class="txt" id="label" />
</div>
<div>
<label for="email">Email:<br />
</label>
<input type="text" size="30" name="email" class="txt" id="email" />
</div>
<p><br />
<b>Insurace Information</b></p>
<p><i>Auto Glass Plus in an Approved Insurance Vendor. Insurance claims require additional information that we will request when we contact you for your quote.</i></p>
<br />
<div>
<input type="checkbox" name="insurance" value="yes" />
Check here if this is an insurance claim.<br />
<label for="year">Insurance Provider:<br />
</label>
<input type="text" size="30" name="provider" class="txt" id="provider" />
</div>
<p><br />
<b>Vehicle Information:</b><br />
</p>
<div>
<label for="year">Vehicle Year :<br />
</label>
<input type="text" size="30" name="year" class="txt" id="year" />
</div>
<div>
<label for="make">Make: </label>
<br />
<input type="text" size="30" name="make" class="txt" id="make" />
</div>
<div>
<label for="model">Model:</label>
<br />
<input type="text" size="30" name="model" class="txt" id="model" />
</div>
<div>
<label for="body">Body Type:<br />
</label>
<select name="body" id="body">
<option>Select One</option>
<option value="2 Door Hatchback">2 Door Hatchback</option>
<option value="4 Door Hatchback">4 Door Hatchback</option>
<option value="2 Door Sedan">2 Door Sedan</option>
<option value="4 Door Sedan">4 Door Sedan</option>
<option value="Station Wagon">Station Wagon</option>
<option value="Van">Van</option>
<option value="Sport Utility">Sport Utility</option>
<option value="Pickup Truck">Pickup Truck</option>
<option value="Other Truck">Other Truck</option>
<option value="Recreational Vehicle">Recreational Vehicle</option>
<option value="Other">Other</option>
</select>
</div>
<p><b><br />
Glass in Need of Repair:</b><br />
</p>
<div>
<input type="checkbox" name="repairs" value="Windshield" />
Windshield<br />
<input type="checkbox" name="repairs" value="Back Glass" />
Back Glass<br />
<input type="checkbox" name="repairs" value="Driver’s Side Window" />
Side Window*<br />
<input type="checkbox" name="repairs" value="Chip Repair" />
Chip Repair<br />
<input type="checkbox" name="repairs" value="Other" />
Other </div>
<p><strong>*Important:</strong> For side glass, please indicate the specific window that needs replacement <i>(e.g. passenger side rear door or driver side vent glass)</i>, and any tinting color preference in the <strong>Describe Damage </strong> field.</p>
<p><br />
<b>Describe Damage</b></p>
<div>
<textarea rows="6" name="damage" id="damage" cols="37" class="txt"></textarea>
</div>
<input type="hidden" name="thanks" value="../thanks.php" />
<input type="hidden" name="required_fields" value="firstname, lastname, email, phone" />
<input type="hidden" name="html_template" value="testform.tpl.html" />
<input type="hidden" name="mail_template" value="testmail.tpl.txt" />
<div class="submit">
<center>
<input type="submit" value="Submit Form" name="Submit" id="Submit" />
</center>
</div>
</fieldset>
</form>
Then it sends to a file named index.php inside the "form" folder:
<?php
$script_root = './';
$referring_server = 'www.wmsgroup.com, wmsgroup.com, scripts';
$allow_empty_referer = 'yes'; // (yes, no)
$language = 'en'; // (see folder 'languages')
$ip_banlist = '';
$ip_address_count = '0';
$ip_address_duration = '48';
$show_limit_errors = 'yes'; // (yes, no)
$log_messages = 'no'; // (yes, no)
$text_wrap = '65';
$show_error_messages = 'yes';
$attachment = 'no'; // (yes, no)
$attachment_files = 'jpg, gif,png, zip, txt, pdf, doc, ppt, tif, bmp, mdb, xls, txt';
$attachment_size = 100000;
$path['logfile'] = $script_root . 'logfile/logfile.txt';
$path['upload'] = $script_root . 'upload/'; // chmod 777 upload
$path['templates'] = $script_root . 'templates/';
$file['default_html'] = 'testform.tpl.html';
$file['default_mail'] = 'testmail.tpl.txt';
/*****************************************************
** Add further words, text, variables and stuff
** that you want to appear in the templates here.
** The values are displayed in the HTML output and
** the e-mail.
*****************************************************/
$add_text = array(
'txt_additional' => 'Additional', // {txt_additional}
'txt_more' => 'More' // {txt_more}
);
/*****************************************************
** Do not edit below this line - Ende der Einstellungen
*****************************************************/
/*****************************************************
** Send safety signal to included files
*****************************************************/
define('IN_SCRIPT', 'true');
/*****************************************************
** Load formmail script code
*****************************************************/
include($script_root . 'inc/formmail.inc.php')
?>
There is also formail.inc.php, testform.tpl.php, testform.tpl.text and then the confirmation page, thanks.php
I want to know how these all work together and what the problem could be.
Your form appears to be using the GentleSource.com Form Mail package. I suggest starting from scratch with a fresh download of their source zip or tar.gz files in a subdirectory. Then run through their installation instructions, test it. Then get it customized in the way your prior form worked.
This is in response to your question "how these all work together".
The user enters information on quote.php page. When the page is submitted, it is sent to form/index.php for processing. This file does some checks and formats the information entered two ways, one way for html email using the template testform.tpl.php and a second way for text email using the form testform.tpl.text. The information is then passed to formmail.inc.php which sends the email and then to thanks.php which displays the response to the user.
What the problem could be? Look at the formmail.inc.php file and make sure that it is properly configured for your server and php installation.
You should make sure that the e-mail addresses in the mail template mail.tpl.txt have the correct format. E-mail addresses should be in angle brackets:
From: <visitor#example.com>
If you're using the fields firstname and lastname, they need to be in quotes:
From: "{firstname} {lastname}" <vistor#example.com>
Other possibilities, why the script won't send e-mails: Windows server with no MTA. Mails get caught by a spam filter somewhere on the way.
You should test if the server can even send e-mails:
<?php
mail('your-email#example.com', 'Test-Subject', 'Test-Message');
?>

Categories