Jump to content

POST data Array


Drezard

Recommended Posts

With my script (see below) it is posting the POST data 'first' and 'lname' as arrays. I have no idea why. Can someone please help me?

(sorry, the code is alittle long)

 


<?php
setcookie( "lastform", serialize( $_POST ), time()+3600 );
$db_host = "p41mysql117.secureserver.net";
$db_user = "CLAC";
$db_pwd = "CarLoan1";
$db_name = "CLAC";
mysql_connect($db_host, $db_user, $db_pwd);
mysql_select_db($db_name);
?>
<!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>

<body>
<?php ( $_POST ); ?>
<?php
$apikey = 'ABQIAAAAa_vPjCuokzxUGTFFtjsfbRRWn1TU0Tw0wFlpcwpj28I8BQkE7xQUiwwSeEDKf7rDx2donY1EK7AT5g';
$zipcode = current( $_POST ).", USA";
$zipcode = trim( $zipcode );
$URL = 'http://maps.google.com/maps/geo?output=xml&key='.$apikey.'&q='.$zipcode;
$file = file_get_contents ($URL);

function find( $tagName, $Ixml = false ) {
if( !$Ixml ) { global $xml; } else { $xml = $Ixml; } 
$regex = "/<$tagName>([^<>]*)<\/$tagName>/i";
preg_match( $regex, $xml, $out );
return $out[1];
}

$status = find( 'code', $file );

if( $status == '200' && strlen( $zipcode ) == 10 ) {
$state = find( "AdministrativeAreaName", $file );
$city = find( "SubAdministrativeAreaName", $file );
}
?>
<?php
print "Great News! Auto loan coverage found in your area: $city, $state <br />";

if (!isset($_POST['B1'])) {

?>
<form method="post">
        <p>
            <span class="qfHeader">Auto Finance Qualification/Request Form</span></p>
        <table id="table1">

            <tr>
                <td>
                    <label for="first">First name</label>                </td>
			<td>
                <input type='text' name='first' id='first' size='20' />               </td>
            </tr>

            <tr>
                <td>
                    <label for="lname">Last name</label>                </td>
                <td>
                    <input type="text" name="lname" id="lname" size="20" />                </td>
            </tr>

            <tr>
                <td>
                    <label for="address1">Address</label>                </td>
                <td>
                    <input type="text" name="address1" id="address1" size="40" />                </td>
            </tr>

            <tr>
                <td>
                    <label for="city">City</label>                </td>
                <td>
                    <input type='text' name='city' value='<?=$city;?>' />                </td>
            </tr>

              <tr>

                <td>
                    <label for="yearsWithEmployer">How long with this employer</label>                </td>
                <td>
                    <select name="yearsWithEmployer" id="yearsWithEmployer">
                        <option value="0">0</option>
                        <option value="1" selected="selected">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>
                        <option value="10">10+</option>
                    </select> <label for="yearsWithEmployer">years</label>
                    <select name="monthsWithEmployer" id="monthsWithEmployer">
                        <option value="0" selected="selected">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>
                        <option value="9">9</option>
                        <option value="10">10</option>
                        <option value="11">11</option>
                    </select> <label for="monthsWithEmployer">months</label>              </td>
            </tr>
            <tr>
                <td>
                    <label for="monthlyincome">Household monthly income</label>
                    (before taxes): </td>
                <td>
                    <select name="monthlyincome" id="monthlyincome">
                        <option value="1200" selected="selected">Under $1200</option>
					<option value="1600">$1,201-$1,600</option>
                        <option value="1800">$1,600-$1,800</option>
                        <option value="2000">$1,801-$2,000</option>
                        <option value="2250">$2,001-$2,250</option>
                        <option value="2500">$2,251-$2,500</option>
                        <option value="2750">$2,501-$2,750</option>
                        <option value="3000">$2,751-$3,000</option>
                        <option value="3500">$3,001-$3,500</option>
                        <option value="4000">$3,501-$4,000</option>
                        <option value="4500">$4,001-$4,500</option>
                        <option value="5000">$4,501-$5,000</option>
					<option value="5500">$5,001-$5,500</option>
                        <option value="6000">$5,501-$6,000</option>
					<option value="6500">$6,001-$6,500</option>
					<option value="7000">$6,501-$7,000</option>
					<option value="7500">$7,001-$7,500</option>
					<option value="8000">$7,501-$8,000</option>
					<option value="8500">$8,001-$8,500</option>
					<option value="9000">$8,501-$9,000</option>
					<option value="9500">$9,001-$9,500</option>
					<option value="10000">$9,501-$10,000+</option>
			                  </select>
                    <span class="qfExplain">(Note: usual minimum is $1,200)</span>                </td>
            </tr>
            <tr>
                <td>
                    <label for="workphone">Work phone</label>                </td>
                <td>

                    <input name="workphone" type="text" id="workphone" size="20"/> 
                    <label for="workPhoneExtension">ext: </label>
                    <input id="workPhoneExtension" name="workPhoneExtension" style="width: 41px" type="text" /></td>
            </tr>
            <tr>
                <td height="24">
              <label for="bankno">Declared bankruptcy in the last 7 years?</label>                </td>

              <td><label for="bankno"></label>
                  <label for="bankyes">Yes</label>                <input name="bankruptcy" type="radio" id="radio" value="false" />
                  No
                  <input name="bankruptcy" type="radio" id="bankyes" value="true" checked="checked" /></td>
            </tr>
            <tr>

                <td>
                    <label for="cosignyes">Cosigner available (if needed)?</label>                </td>
                <td><label for="cosignyes">Yes
                  <input name="cosigner" type="radio" id="cosignyes" value="true" checked="checked" />
                </label>
                  <label for="cosignno">No</label>                <input type="radio" name="cosigner" value="false" /></td>
            </tr>
            <tr>
            <td colspan="2"><table width="70%">
                    <tr>
                        <td>
                            <p>
                              <input name='agree' type='checkbox' id="agree" />
                            By clicking submit you   have read both the <a href="d">Privacy Policy</a> and <a href="d">Terms of Use</a> for CarLoanAutoCredit.com and agree  to be bound by the terms therein.</p>
                            <p>
                              <input name='creditcheck' type='checkbox' id="creditcheck" />
                            I understand that in order to be considered for a car loan a dealer and/or lender will need to perform a credit check.</p>
                          <p>
                             
                          </p></td>
                </tr>
                    <tr>
                        <td align="center">
                            <input type="submit" value="Submit Request" name="B1" id="B1" onclick="check('AutoFinanceRequestV1')"

						/>                        </td>
                    </tr>
              </table>            </td>
            </tr>
        </table>

        <input type="hidden" name="creditAuthorization" id="creditAuthorization" value="true" />
        <input type="hidden" name="forwardAppAuthorization" id="forwardAppAuthorization" value="true" />

        <input type="hidden" name="specialOffers" id="specialOffers" value="true" />
        <input type="hidden" name="FormType" value="AutoFinQuotFrm" />
        <input type="hidden" name="FormVersion" value="4.2.0" />
        <input type="hidden" name="generatorID" value="0000-1590" />
        <input type="hidden" name="leadID" value="" />
        <input type="hidden" name="generatorPostURL" id="generatorPostURL" value="PostSubmit.htm" />
        <input type="hidden" name="leadgenMethod" value="SITE" />
        <input type="hidden" name="campaignID" value="CID123" />
</form>
<?php

}

else {

if (!isset($_POST['first']) || trim($_POST['first']) == '') 
{
echo 'Please enter a first name';
}

else if (!isset($_POST['lname']) || trim($_POST['lname']) == '') 
{
echo 'Please enter a last name';
}

else if (!isset($_POST['address1']) || trim($_POST['address1']) == '')
{
echo 'Please enter an address';
}

else if (!isset($_POST['city']) || trim($_POST['city']) == '')
{
echo 'Please enter a city';
}	
else if( $_POST['agree'] != 'on' )
{
echo 'Please Agree to the Privacy Policy and Terms Of Use to continue.';
}

else if( $_POST['creditcheck'] != 'on' )
{
echo 'Please check that you understand that in order to be considered for a car loan a dealer and/or lender will need to perform a credit check.';
}

else {

	$first = $_POST['first'];

	$lname = $_POST['lname'];

	$address1 = $_POST['address1'];

	$city = $_POST['city'];

	$job = $_POST['yourjobname'];

	$Gdate = date("d-m-Y");
	mysql_query("INSERT INTO `formdetails` (First Name, Last Name, Email, Date) VALUES ('$first', '$lname', '$email', '$Gdate')") or die(mysql_error());

	// echo "<meta http-equiv='refresh' CONTENT='0;url=NewCarquoteform.php'>";

}

}

?>

</body>
</html>

 

Whats wrong,

 

the exact error im getting is:

 

Great News! Auto loan coverage found in your area: Barry, MO

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Name, Last Name, Email, Date) VALUES ('Array', 'Array', '11512351235', '07-04-20' at line 1

 

Daniel

Link to comment
Share on other sites

#1 I don't see you initializing $email anywhere in your source.

 

#2 (the array issue): Your using the same id for your label, as you are for your textbox.  Change the label to lblName or something other than what your textbox is named.

 

                    <label for="lname">Last name</label>                </td>
                <td>
                    <input type="text" name="lname" id="lname" size="20" />   

Link to comment
Share on other sites

#1 I don't see you initializing $email anywhere in your source.

 

#2 (the array issue): Your using the same id for your label, as you are for your textbox.  Change the label to lblName or something other than what your textbox is named.

 

                    <label for="lname">Last name</label>                </td>
                <td>
                    <input type="text" name="lname" id="lname" size="20" />   

 

Actually--that's not naming the label.  It says label FOR first.  When using a label, you need to tell what field it's a label for.  This HAS to be the same as the field name.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.