Array displaying only one record - php

Friends,
I apologize in advance for posting this question again.
I got great help from Barmar in resolving the problem I was having with displaying array results to users.
The error issue was resolved and result was being displayed.
Problem is the array displays one record.
When we insert multiple rows of records, only one record is displayed.
Does anyone know what could be wrong?
Basically, by default, a user is presented with one row of textboxes.
If user needs to add additional records, the user clicks the Add button to dynamically add an additional row of textboxes,
The code below is from a page called preview.php. It is supposed to capture all records entered in markup page by the user and displays them so user will have the option to review the records and go back to make changes if needed or submit records if everything is ok.
So far as indicated above, it displays only one record regardless of whether the user created one row or multiple rows.
We would like to capture all rows.
Any ideas what I might be missing with code below?
I apologize in advance. I have to show this tomorrow at work and it has occupied my entire weekend.
<?php
//echo "DEBUG POST DATA: <pre>".print_r($_POST, 1)."</pre>";
if(isset($_POST['employeename']))
$employeename = $_POST['employeename'];
if(isset($_POST['ttitle']))
$ttitle = $_POST['ttitle'];
echo $employeename .'<br>';
echo $ttitle .'<br> <hr width=400 align=left>';
$rowIDs = $_POST['rowIDs'];
for ($id = 0; $id < $rowIDs; $id++){
$sourcename1 = $_POST['sourcename1'][$id];
$sourceaddress1 = $_POST['sourceaddress1'][$id];
$income1 = $_POST['income1'][$id];
echo $sourcename1 .'<br>';
echo $sourceaddress1.'<br>';
echo $income1.'<br>';
}
?>
DEBUG POST DATA:
Array
(
[employeename] => Catherine Duffy
[ttitle] => Sr. Systems Analyst
[rowIDs] => 1
[sourcename1] => Array
(
[0] => Mark
Zverkov
)
[sourceaddress1] => Array
(
[0] => Address1
)
[income1] => Array
(
[0] => $79,000.00
)
[sourcename13] => Jim Brown
[sourceaddress13] => 32 Xooker Rd
[income13] => $99,000.00
[spousename] =>
[spouseAddress] =>
[spouseIncome] =>
[dividentname] =>
[dividentaddress] =>
[dividentAmt] =>
[reimbursmentName] =>
[reimburseAddr] =>
[remursementAmt] =>
[inputHonoraria] =>
[giftname] =>
[giftaddress] =>
[giftamount] =>
[orgname] =>
[orgaddresss] =>
[donationamt] =>
[creditorname] =>
[creditoraddress] =>
[creditAmt] =>
[email] =>
[submitted] => true
)
Catherine Duffy
Sr. Systems Analyst
Mark Zverkov
Address1
$79,000.00
//Markup
<script id="row-template" type="text/x-handlebars-template">
<div>
<!--reseed attribute IDs in case of gap resulting from deletions -->
<input type="hidden" name="rowIDs[]" value="{{rowNumber}}" />
<div class="form-group">
<label for="sourcename{{rowNumber}}">Name</label><br>
<input type="text" name="sourcename1{{rowNumber}}" id="sourcename1{{rowNumber}}" value="" class="required requiredField" />
<?php if($nameError != '') { ?>
<span class="error"><?=$nameError;?></span>
<?php } ?>
</div>
<div class="form-group">
<label for="sourceaddress1{{rowNumber}}">Address</label><br>
<input type="text" name="sourceaddress1{{rowNumber}}" id="sourceaddress1{{rowNumber}}" style="width:250px;" class="form-control" value="" class="required requiredField" />
<?php if($nameError != '') { ?>
<span class="error"><?=$nameError;?></span>
<?php } ?>
</div>
<div class="form-group">
<label for="income1{{rowNumber}}">Income</label><br>
<input type="text" style="width:250px;" class="form-control" name="income1{{rowNumber}}" id="income1{{rowNumber}}" value="<?php if(isset($_POST['spouseIncome{{rowNumber}}'])) echo $_POST['spouseIncome{{rowNumber}}'];?>" class="required requiredField" />
<?php if($nameError != '') { ?>
<span class="error"><?=$nameError;?></span>
<?php } ?>
</div>
<input id="Button{{rowNumber}}" type="button" rel="remove-row" value="Remove" />
</div>
</script>
<div id="addrow">
<div>
<!--reseed attribute IDs in case of gap resulting from deletions -->
<input type="hidden" name="rowIDs[]" value="{{rowNumber}}" />
<div class="form-group">
<label for="sourcename">Name</label><br>
<input type="text" name="sourcename1[]" id="sourcename1" value="" class="required requiredField" />
<?php if($nameError != '') { ?>
<span class="error"><?=$nameError;?></span>
<?php } ?>
</div>
<div class="form-group">
<label for="sourceaddress1">Address</label><br>
<input type="text" name="sourceaddress1[]" id="sourceaddress1" style="width:250px;" class="form-control" value="" class="required requiredField" />
<?php if($nameError != '') { ?>
<span class="error"><?=$nameError;?></span>
<?php } ?>
</div>
<div class="form-group">
<label for="income1">Income</label><br>
<input type="text" name="income1[]" id="income1" style="width:250px;" class="form-control" value="" class="required requiredField" />
<?php if($nameError != '') { ?>
<span class="error"><?=$nameError;?></span>
<?php } ?>
<input type="button" value="Add More" rel="add-row" />
</div>
</div>
</div><br><br>

From the code snippets and debug you posted, your PHP code appears to be expecting the data in a different format than your HTML form is generating. It's clear that you have a lot going on with the form, I might suggest starting a new, blank page and re-creating the form piece by piece to make sure each piece submits correctly before you add the next block of fields.
Specific to the question of receiving multiple records from the form, if you format your HTML for the part of the form that gets repeated (assuming {{ rowNumber }} gets replaced by 1, 2, 3,... each time a new one is added) like this:
<div class="this-div-gets-repeated">
<label>
Source Name:
<input type="text" name="source[{{ rowNumber }}][name]"/>
</label>
<label>
Source Address:
<input type="text" name="source[{{ rowNumber }}][address]"/>
</label>
<label>
Income:
<input type="text" name="source[{{ rowNumber }}][income]"/>
</label>
</div>
They you can expect to parse it in PHP like this:
<?php
$sources = isset($_POST['source']) ? $_POST['source'] : []; // just in case no sources are posted
foreach ($_POST['source'] as $id => $source) {
$sourcename = $source['name'];
$sourceaddress = $source['address'];
$income = $source['income'];
echo "$sourcename<br>$sourceaddress<br>$income<br>";
}
Edit: further comments on your HTML
Your HTML form has two blocks: a set of fields for the first "record", and then a repeating template for any additional records.
The first issue with your HTML is that your "first record" form fields have different names than your "more records" form fields:
Your "first record" form fields have fields like <input type="text" name="sourcename1[]"/>.
Your "more records" form fields have fields like <input type="text" name="sourcename1{{rowNumber}}"/>.
If you were to look at the HTML that gets generated once you've clicked "Add More" a couple times, your HTML would look like this:
<!-- the default "first record" -->
<input type="text" name="sourcename1[]"/>
<!-- from the first click on "Add More" -->
<input type="text" name="sourcename11"/>
<!-- from the second click on "Add More" -->
<input type="text" name="sourcename12"/>
From that you can see how the values entered into the "first record" fields will appear differently than the values from the dynamically-added "add more" fields?
It also appears that there's some weirdness happening with your Angular templates: your PHP $_POST contains the values from your "first record" fields (in [sourcename1] => Array), and there are values from your "add more" fields (in [sourcename13] => Jim Brown where {{rowNumber}} was 3), but are you intentionally starting {{rowNumber}} at 3 in Angular?

Related

PHP For loop for $_POST

Sorry for the noob question. But I am stuck here.
This is my HTML form where the user-form div can be cloned to as many as possible. The #submit-form div has some hidden values which are common for all.
HTML -
<div class="user-form">
<input type="text" autocomplete="off" name="name[]" >
<input type="email" autocomplete="off" name="mail[]" >
</div>
<div class="user-form">
<input type="text" autocomplete="off" name="name[]" >
<input type="email" autocomplete="off" name="mail[]" >
</div>
<div id="submit-form">
<input type='hidden' name='refer_user_id' value='<?php echo $refer_user_id ?>'>
<input type='hidden' name='refer_user_email' value='<?php echo $refer_user_email ?>'>
<input type="submit" value="Invite" />
<input type="button" class="button" id="clonetrigger" value="Clone" />
</div>
I'm using ajax to submit the form. Basically I want to create accounts using the name and email fields. In PHP How do I use foreach to loop through the name and email fields so that I can create unique accounts?
My print_r($_POST); array looks like this.
Array
(
[name] => Array
(
[0] => david
[1] => Mark
[2] => cindy
)
[mail] => Array
(
[0] => david#abc.com
[1] => mark#abc.com
[2] => cindy#abc.com
)
[refer_user_id] => 2
[$refer_user_email] => test#abc.com
)
Create a loop with a number of iterations equal to the number of submitted name/email pairs, then use the loop counter to access the values for each user.
for ($i = 0; $i < count($_POST['name']); $i++) {
{
$name = $_POST['name'][$i];
$mail = $_POST['mail'][$i];
// Process the new user
}
go through one of the arrays with a foreach, use the key for the second array.
foreach($_POST['name'] as $key =>$name ){
$mail = $_POST[$key];
}
foreach($_POST['name'] as $key => $val) {
echo $val
}
foreach($_POST['mail'] as $key => $val) {
echo $val
}
Easiest way to loop through those elements. You can reference the other elements with $_POST['refer_user_id']. While this works for the purposes of a foreach, the for loop posted above is more efficient, so I'd recommend using it.
http://php.net/manual/en/control-structures.foreach.php More reading on it here.
You can use array_combine function:
$data = array_combine($_POST['name'],$_POST['mail']);
foreach($data as $name=>$mail){
print $name;
//...
}
See array_combine.
You could also use the JavaScript that's auto-generating the form items to give them a name that would result in linking the php object. i.e.
<div class="user-form">
<input type="text" autocomplete="off" name="user[1][name]" />
<input type="email" autocomplete="off" name="user[1][mail]" />
</div>
<div class="user-form">
<input type="text" autocomplete="off" name="user[2][name]" />
<input type="email" autocomplete="off" name="user[2][mail]" />
</div>
Then you could loop through the pairs with foreach($_POST['user'] as $key=>$value) etc...

Auto-Increment Form Input Names With $_SESSION

I want to use PHP $_SESSION to access user form-inputted data. The flow looks like this:
STEP 1
User fills out form.
<form method="post" action="review.php">
<input type="text" name="length">
<input type="text" name="width">
<input typ="text" name="quantity">
<input type="submit" value="submit">
</form>
STEP 2
Form data is submitted and 'review.php' converts from POST to SESSION. User reviews form details and adds item to cart.
STEP 3
Item is added to PayPal Shopping Cart. User decides he wants to add another item so user clicks on "continue shopping" and returns to STEP 1.
STEP 1
User fills out form details. Except this time, I want the input name to auto-increment.
For example:
<input type="text" name="length2">
<input type="text" name="width2">
<input type="text" name="quantity2">
And I want it to auto increment however many number of times the user adds new items to the cart.
<input type="text" name="length3">
<input type="text" name="length4">
<input type="text" name="etc">
Usual flow continues... STEP 2 ---> STEP 3
After successful payment in STEP 3, user will be redirected to a new page.
STEP 4(newPage)
All of the purchased items' details will be displayed on this page in order and with the same group. For example, (length, width, quantity) then (length2, width2, quantity2) and so on and so forth. They will each be displayed in different forms.
Those forms will also include <input type="file"> so that the user can upload a file for each form. Each form represents a purchased item.
Once the user uploads files to each corresponding form, they will be submitted to a database.
QUESTION
How can I make the input names auto increment preferably with PHP,
and of course whilst using $_SESSION? I would like the name to
return to its original name after the user's session. So let's say
that same user wanted to order the next day and he ordered 5 items,
the input names would span to 5 (length, length2,..., length5).
How can I display all of the user inputted data in each respective
form(see STEP 4)?
I know I have to do all of the back-end stuff on PHP($_SESSION, forms, etc) but if someone has a jQuery solution for the auto increment and showing all of the data in the end I'm all for it.
Here's What I Was Working With
Tried to use this to display the data with the incremented names but couldn't figure out a solution.
<?php
session_start();
?>
<form>
<?php
$size = $_SESSION['size'];
$variables = array("$size");
$i = 1;
foreach ($variables as $var ) {
$name = "txt".$i;
echo "<input type='text' name='".$name."' value='".$var."' />";
$i++;
}
?>
</form>
Some of you might bring up PayPal IPN. I created an IPN listener as well but it doesn't get called via sandbox. A user on here posted that his IPN listener didn't work on sandbox either but when he went live via paypal.com it did work. Could be the case with mine too, but I want to go ahead and start selling so I need a different approach. Even if my IPN listener does work via paypal.com, I can't risk going live with it without being 100% sure. So if I can use this method for now until I can confirm that my listener works I will do it.
As always I am very grateful for your guys' help.
I actually figured this out a while back. Here's the code I am using:
<?php
if(isset($_POST['submit'])){
$_SESSION['invoice'] = $_POST['invoice'];
$invoice_no = $_SESSION['invoice'];
$decal = array(
'length' => $_POST['os0'],
'width' => $_POST['os1'],
'color' => $_POST['os2'],
'quantity' => $_POST['os3'],
'price' => $_POST['price'],
'submit' => $_POST['submit']
);
$_SESSION['order'][] = $decal;
$i = 0;
}
if(isset($_SESSION['order'])){
foreach($_SESSION['order'] as $sav) {
$i++;
?>
<input type="hidden" name="on0_<?php echo $i; ?>" value="Length">
<div class="decalName">
<label>Custom Decal <?php echo $i; ?></label>
</div>
<div class="label-input">
<label>Length</label><input type="text" name="os0_<?php echo $i; ?>" id="length" size="2" class="num" value="<?php echo $sav['length']; ?>" readonly>
</div>
<input type="hidden" name="on1_<?php echo $i; ?>" value="Width">
<div class="label-input"><label>Width</label><input type="text" name="os1_<?php echo $i; ?>" id="width" size="2" class="num" value="<?php echo $sav['width']; ?>" readonly>
</div>
<input type="hidden" name="on2_<?php echo $i; ?>" value="Color">
<div class="label-input">
<label>Color</label><input type="text" name="os2_<?php echo $i; ?>" value="<?php echo $sav['color']; ?>" readonly>
</div>
<div class="label-input">
<label>Quantity</label><input type="text" name="os3_<?php echo $i; ?>" size="2" class="num" id="quantity" value="<?php echo $sav['quantity']; ?>" readonly>
</div>
<input type="hidden" name="on3_<?php echo $i; ?>" value="quantity">
<input type="hidden" class="num" value="0.20">
<div class="label-input">
<label>Price $:</label><input type="text" class="tot" name="price" value="<?php echo $sav['price']; ?>" readonly>
</div><!--end label-input-->
<?php
}
?>

How to post array data from a form to mysql DB

please forgive naivety and innocence...I am not a programmer! I have spent the best part of 4 days on this and I am ready for a PHP lesson or intense therapy.
Scenario: DB built in mySQL. Table with all columns varchar(50) except ID and age - both INT. See below, I just need a 'Yes' value in the checkbox linked colums/fields.
I want to insert data with a form that has both textboxes and checkboxes. I thought best way to do this was php array...??
Form:
<form action="process.php" method="post" enctype="multipart/form-data">
<label>Childname
<input type="text" name="textfield[childname]" />
</label>
<p>
<label>Age
<input type="text" name="textfield[age]" />
</label>
</p>
<p>
<label>Parent Name
<input type="text" name="textfield[parent_name]" />
</label>
</p>
<p>
<label>Contact Number
<input type="text" name="textfield[contact_no]" />
</label>
</p>
<p>Subjects<br />
<label>
<input type="checkbox" name="checkbox[scratch]" value="checkbox" />
Scratch</label>
<label>
<input type="checkbox" name="checkbox[app_inventor]" value="checkbox" />
App Inventor</label>
<label>
<input type="checkbox" name="checkbox[html]" value="checkbox" />
HTML</label>
</p>
<p>Sessions Attended<br />
<label>
<input type="checkbox" name="checkbox[nov12]" value="checkbox" />
Nov 2012</label>
</p>
<p>
<label>
<input type="checkbox" name="checkbox[dec12]" value="checkbox" />
Dec 2012</label>
</p>
<p> </p>
<p>
<label>
<input type="submit" name="Submit" value="Submit" />
</label>
</p>
</form>
PHP script:
<?php
include("config.php");
$childrecord = array("childname","age","parent_name","contact_no","scratch","app_inventor","html");
if(isset($_POST['childrecord'])){
$childrecord = $_POST['childrecord'];
$i = 0;
foreach ($childrecord as $key => $value); {
$i++;
$sql="INSERT INTO tblchildren (childrecord) VALUES ($_POST['childrecord'])";
mysql_query($sql);
}
?>
Please help!
Thanks in advance....
You want to store your form data in your code.
For this you have to make following changes in your code and database.
In Form
note: Input field value should be relevant.
With your existing html code your process.php will get data in this structure
Array
(
[textfield] => Array
(
[childname] => dang
[age] => 18
[parent_name] => doctor
[contact_no] => 100
)
[checkbox] => Array
(
[scratch] => checkbox
[app_inventor] => checkbox
[html] => checkbox
[nov12] => checkbox
[dec12] => checkbox
)
[Submit] => Submit
)
So you need to modify your process.php
Before that you have to modify structure of your table, follow these steps
1. Delete your existing table
2. Create new table
DROP TABLE tblchildren ;
CREATE TABLE tblchildren
(
id INT AUTO_INCREMENT PRIMARY KEY,
childname VARCHAR(30),
age TINYINT,
parent_name VARCHAR(30),
contact_no VARCHAR(20),
scratch ENUM('yes','no'),
app_inventor ENUM('yes','no'),
html ENUM('yes','no'),
sesNov12Attnd ENUM('yes','no'),
sesDec12Attnd ENUM('yes','no')
);
Since you are new to php so i have used basic function,
I will suggest you to use switch from mysql to mysqli
process.php
<?php
$con=mysql_connect("hostname","username","pass");
$db=mysql_select_db('dbname', $con);
//check form is submitted
if(isset($_POST)){
//mysql_real_escape_string() prevents from sql injection.
$childname= mysql_real_escape_string($_POST['textfield']['childname']);
$age=mysql_real_escape_string($_POST['textfield']['age']);
$parentName=mysql_real_escape_string($_POST['textfield']['parent_name']);
$contactNo=mysql_real_escape_string($_POST['textfield']['contact_no']);
$scratch=isset($_POST['checkbox']['scratch'])?'yes':'no';
$appInventor=isset($_POST['checkbox']['app_inventor'])?'yes':'no';
$html=isset($_POST['checkbox']['html'])?'yes':'no';
$nov12=isset($_POST['checkbox']['nov12'])?'yes':'no';
$dec12=isset($_POST['checkbox']['dec12'])?'yes':'no';
$sql="INSERT INTO tblchildren(childname, age, parent_name, contact_no, scratch,app_inventor,html, sesNov12Attnd, sesDec12Attnd )
VALUES
('$childname',$age,'$parentName','$contactNo','$scratch','$appInventor','$html','$nov12','$dec12')";
mysql_query($sql);
}else{
echo "Form Not SUbmitted";
}
?>

PHP code inside javascript

I have no idea about how javascript works, but I was able to write the following code by copying from different sites.
My aim is to have 2 radio boxes (1 = India, 2 = Other than India) and if Other than India is selected, then a dropdown box is displayed which shows names of all countries.
The dropdown is selected from a database and it is achieved by a custom php function.
I am able to make the code display the dropdown based on my radio box selection.
What I am unable to do is as follows:
I am not able to select any values from the dropdown.
I'm not able to make the dropdown hide if I change the choice in the radio box
Here is the code of the form:
<form action="<?php $_SERVER['PHP_SELF']?>" method="post">
<fieldset>
<br />
<script type="text/javascript">
function onclickradio(entry){
if (entry === true) {
alert("YOU HAVE CHOSEN INDIA");
}
else {
document.getElementById('OTHER THAN INDIA').innerHTML = '</br><?php dropdown('country');?>';
}
}
</script>
Country: </br>
<input onclick="onclickradio(document.getElementById('INDIA').checked);" id="INDIA" name="country" type="radio" checked="checked"/> INDIA
<input onclick="onclickradio(document.getElementById('INDIA').checked);" id="OTHER THAN INDIA" name="country" type="radio"/> OTHER THAN INDIA
<br /><br /><br />
State: <input type="text" name="State" maxlength="30"/><br />
Line1: <input type="text" name="Line1" maxlength="50" /><br />
Line2: <input type="text" name="Line2" maxlength="50" /><br />
City: <input type="text" name="City" maxlength="40" /><br />
PIN Code: <input type="text" name="PIN_Code" maxlength="8" /><br />
<input type="submit" name="submit_address" value="Submit Address" />
</fieldset>
</form>
Here is the code for the custom PHP dropdown function:
<?php
function dropdown($tablename) /*remember to add single quote around the input*/
{
$sql="SELECT * FROM ".$tablename;
$result=mysqli_query($GLOBALS["connection"], $sql)
or die('Error in running SELECT query');
$options=""; //initialising the variable, so that it can be concatenated later
while ($row=mysqli_fetch_array($result))
{
$x=0; /*$x is the index of the field in a row (it has to start with $x=0;
because the first index is 0 in php*/
$rowstr=" # "; /*initialising the variable,
so that it can be concatenated later*/
while ($x+1<=mysqli_num_fields($result)) /*mysqli_num_fields gives the actual number of fields, and not the index.
Since the index starts with 0, it is to be incremented by 1
before comparison with the mysqli_num_fields*/
{
$rowstr.= $row[$x]." # "; //concatenation operator
$x=$x+1;
}
$options.="<option value=".$rowstr.">".$rowstr."</option>"; //concatenation operator
}
Echo "<select>".$options."</select>";
}
?>
A few things that come to mind:
Don't put spaces in id values. I recommend that you use lower case as well, so you could have "india" and "not-india" instead.
Use Firefox/Firebug or similar to see if you have any JavaScript errors when you run this
Consider using jQuery or similar to catch change events - it is easy to use and uses the 'unobtrusive' method of adding JS functionality to your page.
Id field of an element can not have space. Just try removing spaces in "OTHER THAN INDIA" or replace to looks like OTHER_THAN_INDIA
Try this:
$(document).ready(function() {
// hide address inputs
$('#address').hide();
// show address inputs if the not india button is pressed
$('#not-india').click(function() {
$('#address').show();
});
// re-hide address inputs if india is selected
$('#india').click(function() {
$('#address').hide();
});
});
You will also have to include jQuery in your page.
Fiddle: http://jsfiddle.net/EN4jB/6/
Please note that I used the following markup - particular attention is due to the id of this div.
<input id="india" name="country" type="radio" checked="checked"/> India
<input id="not-india" name="country" type="radio" /> Not India
<br />
<div id="address">
<p><select>
<option>USA</option>
<option>UK</option>
<option>Ireland</option>
<option>etc...</option>
</select>
</p>
<p>State: <input type="text" name="State" maxlength="30"/></p>
<p>Line1: <input type="text" name="Line1" maxlength="50" /></p>
<p>Line2: <input type="text" name="Line2" maxlength="50" /></p>
<p>City: <input type="text" name="City" maxlength="40" /></p>
</div>
To clear the selection if India is chosen
function onclickradio(entry) {
if(entry===true) {
alert("YOU HAVE CHOSEN INDIA");
document.getElementById('OTHER THAN INDIA').innerHTML = '';
}
else {
document.getElementById('OTHER THAN INDIA').innerHTML = '<br/><?php dropdown('country');?>';
}
}

Why is this PHP validation returning the error msg?

This is stupidly simple, but I can't figure out why I constantly get the error msg here, it looks right and works right in other applications....is this due to the "0" zeros? It shouldn't be because it's returning the error before it gets to any of the other stuff, pls help! been staring at this so long Im getting to that "can't see the forest from the trees" point.
PHP
<?php
if(empty($_POST['Contact0FirstName']) || empty($_POST['Contact0LastName']) ||
empty($_POST['Contact0Email']) || empty($_POST['Contact0Phone1']) ||
empty($_POST['CaptchaInput']) || !empty($_POST['LeadBlind'])) {
echo "Please fill out all fields marked *";
die();
} else {
//curl stuff
}
?>
and the form
<form id="Lead" method="post" action="PHP/Lead.php" accept-charset="UTF-8">
<ul id="LeadForm">
<li>*required field</li>
<li>
<input type="hidden" name="LeadBlind" id="LeadBlind">
<label for="Contact0FirstName">1| First Name*</label>
<label for="Contact0LastName">2 | Last Name*</label>
<label for="Contact0Email">3 | Email*</label>
</li>
<li>
<input type="text" name="Contact0FirstName" id="Contact0FirstName">
<input type="text" name="Contact0LastName" id="Contact0LastName">
<input type="text" name="Contact0Email" id="Contact0Email">
</li>
<li>
<label for="Contact0Phone1">4| Daytime Phone*</label>
<label for="Contact0Phone2">5| Evening Phone</label>
<label for="CaptchaInput">6| Please enter the code</label>
</li>
<li>
<input type="text" name="Contact0Phone1" id="Contact0Phone1">
<input type="text" name="Contact0Phone2" id="Contact0Phone2">
<input type="text" class="numbers" name="Captcha" id="Captcha" value="" readonly>
<input type="text" class="numbers" name="CaptchaInput" id="CaptchaInput" size="6" maxlength="6">
</li>
<li>
<input type="submit" id="LeadSend" value="Try It Now!">
<span id="processing">Submitting Your Request</span>
</li>
<li class="text">You will get 30 days of NinjaTrader + Rithmic (the data feed) to experience how trading should really be.</li>
<li class="text">Email Support or call 800 771 6748 (Optimus Trading Group)</li>
</ul>
<div class="clear"></div>
</form>
In firebug, it shows the fields getting passed, with a value, but I get the "Please fill out all fields marked *" error returned.
!empty($_POST['LeadBlind'])
nothing else leads to the problem
try making it to check if its empty
else try removing fields one by one to see where exactly is the problem
otherwise
add var_dump($_POST); after <?php tag
Between here:
<?php
if(empty($_POST['Contact0FirstName']) ...
Please put a
print_r($_POST);
And make sure all the keys you're accessing the data from are correct and populated.
IE:
<?php
print_r($_POST);
if(empty($_POST['Contact0FirstName']) ...
!empty($_POST['LeadBlind']
This field can only be empty, because it's hidden and you didn't assigned a value to it.
Also, this is very poor HTML (Tags should be closed) and I would use the isset()-function on every $_POST-field that is been set in your Form. Because if a field has no value and the form is being send, there is no entry in the $_POST-Array in the first place.

Categories