Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 12-05-2012, 06:58 PM   PM User | #1
otty
New to the CF scene

 
Join Date: Dec 2012
Location: earth
Posts: 7
Thanks: 3
Thanked 0 Times in 0 Posts
otty is an unknown quantity at this point
PHP form valitaion and submit

I have been working on this form that seems to manage validating the right way, but I need it to submit afterwards and can't figure out how to do that how I want. I'm still new with PHP and could use some help.
I'm trying to make the form submit similar to this one, with no need for javascript.
http://allstatescartransport.com/car-transport.html

Here is my validation script so far. It's a little bulky, so any help is appreciated

Code:
<?php

if($_POST)
{
$first_name = $_POST['first_name']; 
$last_name = $_POST['last_name'];  
$phone = $_POST['phone'];
$email = $_POST['email'];
$year1 = $_POST['year1'];
$make1 = $_POST['make1']; 
$model1 = $_POST['model1'];  
$vehicle_type_id1 = $_POST['vehicle_type_id1']; 
$pickup_city = $_POST['pickup_city']; 
$pickup_state_code = $_POST['pickup_state_code'];
$dropoff_city = $_POST['dropoff_city']; 
$dropoff_state_code = $_POST['dropoff_state_code'];  
$vehicle_runs = $_POST['vehicle_runs'];
$ship_via_id = $_POST['ship_via_id'];
$estimated_ship_date = $_POST['estimated_ship_date'];


// First Name
if (preg_match ("/ ^ [A-Za-z -] {3.20} $ /", $ first_name))
 {
	   $valid_first_name=$first_name;
 }
else
{  
    $error_first_name='Enter valid First Name.';  
}
// Last Name
if (preg_match ("/ ^ [A-Za-z -] {3.20} $ /", $ last_name))
 {
	   $valid_last_name=$last_name;
 }
else
{  
    $error_last_name='Enter valid Last Name.';  
}
// Phone
if (preg_match ("/ ^ [0-9 -] {7.20} $ /", $ phone))
 {
	   $valid_phone=$phone;
 }
else
{  
    $error_phone='Enter valid Phone Number.';  
}
// Email 
if (preg_match ("/ ^ [a-zA-Z0-9._-] + @ [a-zA-Z0-9._-] + \. ([a-zA-Z] {2,4}) $ / ", $ email))
 {
	   $valid_email=$email; 
 }
else
{  
    $error_email='Enter valid Email.';  
}
// Year
if (preg_match("/^[0-9 -]{2,20}$/",$year1))
 {
	   $valid_year1=$year1;
 }
else
{  $error_year1='Enter valid Vehicle Year.';  }

// Make

if (preg_match ("/ ^ [A-Za-z0-9 -] {2.25} $ /", $ make1))
 {
	  $valid_make1=$make1;
 }
else
{  
    $error_make1='Enter valid Vehicle Make.';  
}
// Model

if (preg_match ("/ ^ [A-Za-z0-9 -] {2.25} $ /", $ model1))
 {
	  $valid_model1=$model1;
 }
else
{  
    $error_model1='Enter valid Vehicle Model.';  
}

// Vehicle Type
if ($vehicle_type_id1==00)
 {
	    $error_vehicle_type_id1='Select Vehicle Type'; 
 }
else
{  
$valid_vehicle_type_id1=$vehicle_type_id1;
    
}
// Pickup City
if (preg_match ("/ ^ [A-Za-z0-9 -] {3.20} $ /", $ pickup_city))
 {
	   $valid_pickup_city=$pickup_city;
 }
else
{  
    $error_pickup_city='Enter valid Pickup City.';  
}
// Pickup state
if ($pickup_state_code==00)
 {
	    $error_pickup_state_code='Select Pickup State.'; 
 }
else
{  
$valid_pickup_state_code=$pickup_state_code;
    
}
// Dropoff City
if (preg_match ("/ ^ [A-Za-z0-9 -] {3.20} $ /", $ dropoff_city))
 {
	   $valid_dropoff_city=$dropoff_city;
 }
else
{  
    $error_dropoff_city='Enter valid Dropoff City.';  
}
// Dropoff state
if ($dropoff_state_code==00)
 {
	    $error_dropoff_state_code='Select Dropoff State.'; 
 }
else
{  
$valid_dropoff_state_code=$dropoff_state_code;
    
}
// Vehicle Runs
if ($vehicle_runs==00)
 {
	    $error_vehicle_runs='Does your vehicle run?'; 
 }
else
{  
$valid_vehicle_runs=$vehicle_runs;
    
}
// Ship Via
if ($ship_via_id==00)
 {
	    $error_ship_via_id='Select how to ship.'; 
 }
else
{  
$valid_ship_via_id=$ship_via_id;
    
}
// Estimated Shipping Date
if (preg_match("/^[0-9]{1,2}\/[0-9]{1,2}\/[0-9]{4}$/",$estimated_ship_date))
 {
	   $valid_estimated_ship_date=$estimated_ship_date;
 }
else
{  
    $error_estimated_ship_date='Enter valid Shipping Date.';  
}

($ Valid_ship_via_id> 0) && (strlen ($ valid_estimated_ship_date)> 0))
{}
{
post to process.php


}


}
?>
otty is offline   Reply With Quote
Old 12-05-2012, 07:10 PM   PM User | #2
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,752
Thanks: 4
Thanked 2,468 Times in 2,437 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
What version of PHP are you using?
Fou-Lu is offline   Reply With Quote
Old 12-05-2012, 08:07 PM   PM User | #3
otty
New to the CF scene

 
Join Date: Dec 2012
Location: earth
Posts: 7
Thanks: 3
Thanked 0 Times in 0 Posts
otty is an unknown quantity at this point
5.2.17
otty is offline   Reply With Quote
Old 12-05-2012, 09:25 PM   PM User | #4
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,752
Thanks: 4
Thanked 2,468 Times in 2,437 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
Using the filter_vars from PHP5.2+ you can compact what you are doing into a simpler to modify validation process.
Here's an example of what (should) work for you based on most of what you have here. Some things didn't make sense like the year, but otherwise I pretty much just copied over the regexp as you have provided.
PHP Code:
<?php

if (count($_POST) <= 0)
{
    exit();
}

$aFilters = array(
    
'first_name' => array(
        
'filter' => FILTER_VALIDATE_REGEXP,
        
'options' => array('regexp' => '/^[a-z- ]{3,20}$/i'),
    ),
    
'last_name' => array(
        
'filter' => FILTER_VALIDATE_REGEXP,
        
'options' => array('regexp' => '/^[a-z- ]{3,20}$/i'),
    ),
    
'phone' => array(
        
'filter' => FILTER_VALIDATE_REGEXP,
        
'options' => array('regexp' => '/^[0-9-]{7,20}$/i'),
    ),
    
'email' => FILTER_VALIDATE_EMAIL,
    
'year1' => array(
        
'filter' => FILTER_VALIDATE_INT,
        
'options' => array('min_range' => 1900'max_range' => 2100),
    ),
    
'make1' => array(
        
'filter' => FILTER_VALIDATE_REGEXP,
        
'options' => array('regexp' => '/^[a-z0-9 -]{2,25}$/i'),
    ),
    
'model1' => array(
        
'filter' => FILTER_VALIDATE_REGEXP,
        
'options' => array('regexp' => '/^[a-z0-9 -]{2,25}$/i'),
    ),
    
'vehicle_type_id1' => array(
        
'filter' => FILTER_VALIDATE_INT,
        
'options' => array('min_range' => 1),
    ),
    
'pickup_city' => array(
        
'filter' => FILTER_VALIDATE_REGEXP,
        
'options' => array('regexp' => '/^[a-z0-9 -]{3,20}$/i'),
    ),
    
'pickup_state_code' => array(
        
'filter' => FILTER_VALIDATE_INT,
        
'options' => array('min_range' => 1),
    ),
    
'dropoff_city' => array(
        
'filter' => FILTER_VALIDATE_REGEXP,
        
'options' => array('regexp' => '/^[a-z0-9 -]{3,20}$/i'),
    ),
    
'dropoff_state_code' => array(
        
'filter' => FILTER_VALIDATE_INT,
        
'options' => array('min_range' => 1),
    ),
    
'vehicle_runs' => array(
        
'filter' => FILTER_VALIDATE_INT,
        
'options' => array('min_range' => 1),
    ),
    
'ship_via_id' => array(
        
'filter' => FILTER_VALIDATE_INT,
        
'options' => array('min_range' => 1),
    ),
    
'estimated_ship_date' => array(
        
'filter' => FILTER_CALLBACK,
        
'options' => 'strtotime',
    )
);


$aFailureNotices = array (
  
'first_name' => 'Invalid First Name',
  
'last_name' => 'Invalid Last Name',
  
'phone' => 'Invalid Phone Number',
  
'email' => 'Invalid Email Address',
  
'year1' => 'Invalid Year',
  
'make1' => 'Invalid Make',
  
'model1' => 'Invalid Model',
  
'vehicle_type_id1' => 'Invalid Vehicle Type ID',
  
'pickup_city' => 'Invalid Pickup City',
  
'pickup_state_code' => 'Invalid Pickup State Code',
  
'dropoff_city' => 'Invalid Dropoff City',
  
'dropoff_state_code' => 'Invalid Dropoff State Code',
  
'vehicle_runs' => 'Invalid Vehicle Runs option',
  
'ship_via_id' => 'Invalid Ship Via ID',
  
'estimated_ship_date' => 'Invalid Estimate Ship Date',
);


// Do the work now.
// Filter the input array
$filtered filter_input_array(INPUT_POST$aFilters);

function 
isEmpty($s)
{
    return empty(
$s);
}

// Pick out the empty ones (null is actually not provided, false is failed)
$aBadEntries array_filter($filtered'isEmpty');

// Get a collection of error messages
$aErrorMessages array_intersect_key($aFailureNotices$aBadEntries);
$aErrorMessages will contain key => messages of the failures. Give that a try.
Note that I haven't made extensive use of the filter functionality myself; I still have an old school validation library I wrote years ago for this purpose, and haven't had a chance to update it.

Edit:
Oh btw, there's nothing that says you cannot compact down the validation even further. If you have a ruleset that's generic (such as for names and cities which will likely contain the same characters realistically), you can create that string separately and simply use the variable as the options. There are always ways to trim it down.

Last edited by Fou-Lu; 12-05-2012 at 09:28 PM..
Fou-Lu is offline   Reply With Quote
Users who have thanked Fou-Lu for this post:
otty (12-06-2012)
Old 12-05-2012, 10:56 PM   PM User | #5
otty
New to the CF scene

 
Join Date: Dec 2012
Location: earth
Posts: 7
Thanks: 3
Thanked 0 Times in 0 Posts
otty is an unknown quantity at this point
I think I'm putting it in wrong hahah. I know I write over the code from the top and I'm assuming that I put it in either to just before "if((strlen($valid_first_name)" which I don't believe is what it's supposed to be, or to just before "?>" but neither way seems to work properly both ways seem to show up blank

Last edited by otty; 12-05-2012 at 11:38 PM..
otty is offline   Reply With Quote
Old 12-05-2012, 11:30 PM   PM User | #6
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,752
Thanks: 4
Thanked 2,468 Times in 2,437 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
It would replace everything you have.
Put it in a file of its own then take a copy of the original form and point the action to this script instead. This would let you test it with various good and bad input parameters.
Beyond this point you would check to see if the $aErrorMessages is empty. If it is, validation passed the input values and you can continue processing. Otherwise it failed, and you can show the error messages in the $aErrorMessages array.
Fou-Lu is offline   Reply With Quote
Users who have thanked Fou-Lu for this post:
otty (12-06-2012)
Old 12-06-2012, 07:15 PM   PM User | #7
otty
New to the CF scene

 
Join Date: Dec 2012
Location: earth
Posts: 7
Thanks: 3
Thanked 0 Times in 0 Posts
otty is an unknown quantity at this point
Quote:
Originally Posted by Fou-Lu View Post
It would replace everything you have.
Put it in a file of its own then take a copy of the original form and point the action to this script instead. This would let you test it with various good and bad input parameters.
Beyond this point you would check to see if the $aErrorMessages is empty. If it is, validation passed the input values and you can continue processing. Otherwise it failed, and you can show the error messages in the $aErrorMessages array.
With my obvoiusly "superb" skills in php I have added
PHP Code:
echo $aErrorMessages
to the bottom of your code and is has given me the response "Array"
I've had a problem with something like this before and it had something to do with how my functions were held or something... I wish I had more time to stud this so I wouldn't have to request much assistance, but I guess I have to start somewhere.
Anyway, thank you for helping me with this! I really appreciate it and hope to get this functioning soon
otty is offline   Reply With Quote
Old 12-06-2012, 07:37 PM   PM User | #8
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,752
Thanks: 4
Thanked 2,468 Times in 2,437 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
Arrays are a complex datatype; they cannot be directly printed.
PHP Code:
if (!empty($aErrorMessages))
{
    print(
'The following errors occurred: ');
    foreach (
$aErrorMessages AS $error)
    {
        print 
PHP_EOL $error;
    }
}
else
{
    
// all good.

Fou-Lu is offline   Reply With Quote
Users who have thanked Fou-Lu for this post:
otty (12-06-2012)
Old 12-06-2012, 08:38 PM   PM User | #9
otty
New to the CF scene

 
Join Date: Dec 2012
Location: earth
Posts: 7
Thanks: 3
Thanked 0 Times in 0 Posts
otty is an unknown quantity at this point
it works! Now I just need to set it to do all this in the else{} area
The first part is easy enough >_< maybe have a process page after that one with the tracking stuff in it? Or can I get all of that to work somehow? I don't think javascript will run inside php tags right?
PHP Code:

<?php

$ch 
curl_init();
curl_setopt($chCURLOPT_URL"http://www.jtracker.com/lead_post.php");
curl_setopt($chCURLOPT_POST1);
curl_setopt($chCURLOPT_TIMEOUT100);
curl_setopt($chCURLOPT_RETURNTRANSFER1);
curl_setopt($chCURLOPT_POSTFIELDShttp_build_query($_POST));
$data curl_exec($ch);
curl_close($ch);

mysql_connect("localhost, "user", "password") or die("Connection Failed");
mysql_select_db("
database")or die("Connection Failed");
$referrer = $_POST['referrer'];
$first_name = $_POST['first_name'];
$last_name = $_POST['last_name'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$vehicle_type_id1 = $_POST['vehicle_type_id1'];
$pickup_city = $_POST['pickup_city'];
$pickup_state_code = $_POST['pickup_state_code'];
$dropoff_city = $_POST['dropoff_city'];
$dropoff_state_code = $_POST['dropoff_state_code'];
$vehicle_runs = $_POST['vehicle_runs'];
$ship_via_id = $_POST['ship_via_id'];
$estimated_ship_date = $_POST['estimated_ship_date'];
$query = "
INSERT INTO Boat_Shipping(referrer,first_name,last_name,email,phone,vehicle_type_id1,pickup_city,pickup_state_code,dropoff_city,dropoff_state_code,vehicle_runs,ship_via_id,estimated_ship_date)VALUES('$referrer','$first_name','$last_name','$email','$phone','$vehicle_type_id1','$pickup_city','$pickup_state_code','$dropoff_city','$dropoff_state_code','$vehicle_runs','$ship_via_id','$estimated_ship_date')";
if(mysql_query($query)){
echo "
Your information is being processedPlease wait.";}
else{
echo "
Database Error";}




mysql_close();




?>
<script type="
text/javascript"> if (!window.mstag) mstag = {loadTag : function(){},time : (new Date()).getTime()};</script> <script id="mstag_tops" type="text/javascript" src="//flex.atdmt.com/mstag/site/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/mstag.js"></script> <script type="text/javascript"> mstag.loadTag("analytics", {dedup:"1",domainId:"1570529",type:"1",actionid:"104890"})</script> <noscript> <iframe src="//flex.atdmt.com/mstag/tag/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/analytics.html?dedup=1&domainId=1570529&type=1&actionid=104890" frameborder="0" scrolling="no" width="1" height="1" style="visibility:hidden;display:none"> </iframe> </noscript>

<meta http-equiv="REFRESH" content="1;url=/thankyou.php">
<
center><h1>Please <a href="/thankyou.php">Click Here</a> if your Thank You page does not load.</h1></center>

Last edited by otty; 12-07-2012 at 01:54 PM..
otty is offline   Reply With Quote
Old 12-06-2012, 08:38 PM   PM User | #10
otty
New to the CF scene

 
Join Date: Dec 2012
Location: earth
Posts: 7
Thanks: 3
Thanked 0 Times in 0 Posts
otty is an unknown quantity at this point
I think I've managed to get it to run by moving the ?> under mysql_close to the bottom and then putting echo 'all the script under the ?>"
I'm waiting for bing to update the tracking info to tell me if everything worked

Last edited by otty; 12-06-2012 at 10:14 PM.. Reason: was a repost
otty is offline   Reply With Quote
Old 12-07-2012, 05:07 PM   PM User | #11
otty
New to the CF scene

 
Join Date: Dec 2012
Location: earth
Posts: 7
Thanks: 3
Thanked 0 Times in 0 Posts
otty is an unknown quantity at this point
I've had some help with the issue and have removed the validation code from the page with the form so the form action posts to process.php as in the code above, then process.php does this.
PHP Code:

<?php

if (count($_POST) <= 0)
{
    exit();
}

$aFilters = array(
    
'first_name' => array(
        
'filter' => FILTER_VALIDATE_REGEXP,
        
'options' => array('regexp' => '/^[a-z- ]{3,20}$/i'),
    ),
    
'last_name' => array(
        
'filter' => FILTER_VALIDATE_REGEXP,
        
'options' => array('regexp' => '/^[a-z- ]{3,20}$/i'),
    ),
    
'phone' => array(
        
'filter' => FILTER_VALIDATE_REGEXP,
        
'options' => array('regexp' => '/^[0-9-]{7,20}$/i'),
    ),
    
'email' => FILTER_VALIDATE_EMAIL,
    
'year1' => array(
        
'filter' => FILTER_VALIDATE_INT,
        
'options' => array('min_range' => 1900'max_range' => 2100),
    ),
    
'make1' => array(
        
'filter' => FILTER_VALIDATE_REGEXP,
        
'options' => array('regexp' => '/^[a-z0-9 -]{2,25}$/i'),
    ),
    
'model1' => array(
        
'filter' => FILTER_VALIDATE_REGEXP,
        
'options' => array('regexp' => '/^[a-z0-9 -]{2,25}$/i'),
    ),
    
'vehicle_type_id1' => array(
        
'filter' => FILTER_VALIDATE_INT,
        
'options' => array('min_range' => 1),
    ),
    
'pickup_city' => array(
        
'filter' => FILTER_VALIDATE_REGEXP,
        
'options' => array('regexp' => '/^[a-z0-9 -]{3,20}$/i'),
    ),
    
'pickup_state_code' => array(
        
'filter' => FILTER_VALIDATE_REGEXP,
        
'options' => array('regexp' => '/^[a-zA-Z- ]{2}$/i'),
    ),
    
'dropoff_city' => array(
        
'filter' => FILTER_VALIDATE_REGEXP,
        
'options' => array('regexp' => '/^[a-z0-9 -]{3,20}$/i'),
    ),
    
'dropoff_state_code' => array(
        
'filter' => FILTER_VALIDATE_REGEXP,
        
'options' => array('regexp' => '/^[a-zA-Z- ]{2}$/i'),
    ),
    
'vehicle_runs' => array(
        
'filter' => FILTER_VALIDATE_INT,
        
'options' => array('min_range' => 1),
    ),
    
'ship_via_id' => array(
        
'filter' => FILTER_VALIDATE_INT,
        
'options' => array('min_range' => 1),
    ),
    
'estimated_ship_date' => array(
        
'filter' => FILTER_CALLBACK,
        
'options' => 'strtotime',
    )
);


$aFailureNotices = array (
'first_name' => 'Invalid First Name',
'last_name' => 'Invalid Last Name',
'phone' => 'Invalid Phone Number',
'email' => 'Invalid Email Address',
'year1' => 'Invalid Year',
'make1' => 'Invalid Make',
'model1' => 'Invalid Model',
'vehicle_type_id1' => 'Invalid Vehicle Type ID',
'pickup_city' => 'Invalid Pickup City',
'pickup_state_code' => 'Invalid Pickup State Code',
'dropoff_city' => 'Invalid Dropoff City',
'dropoff_state_code' => 'Invalid Dropoff State Code',
'vehicle_runs' => 'Invalid Vehicle Runs option',
'ship_via_id' => 'Invalid Ship Via ID',
'estimated_ship_date' => 'Invalid Estimate Ship Date',
);


// Do the work now.
// Filter the input array
$filtered filter_input_array(INPUT_POST$aFilters);

function 
isEmpty($s)
{
    return empty(
$s);
}

// Pick out the empty ones (null is actually not provided, false is failed)
$aBadEntries array_filter($filtered'isEmpty');

// Get a collection of error messages
$aErrorMessages array_intersect_key($aFailureNotices$aBadEntries);

if (!empty(
$aErrorMessages))
{
    print(
'The following errors occurred: ');
    foreach (
$aErrorMessages AS $error)
    {
        print 
PHP_EOL $error;
        echo 
'<br>';
    }

echo 
'<br><center><table width="75%"><tr><td valign="top"><form action="" method="post" name="quoteForm">
<input type="hidden" name="broker_id" value="33d1918e06fd9a56a257ab44154e54e2" />
<input type="hidden" name="referrer" value="BPPC" />
<input type="hidden" name="post_back" value="http://www.shipyourcarnow.com/thankyou.php" />
<input type="hidden" name="company_name" value="SYCNB" />
<div class="column-1 left">
<h4>Contact Information:</h4>

<div class="fieldContainer">

<p><span class="redStar">*</span> First Name:
<input name="first_name" type="text" required="required" id="first_name" pattern="[A-Za-z -]{3,20}" value="" />
</p>
</div>

<div class="fieldContainer">
<p><span class="redStar">*</span> Last Name:
<input name="last_name" type="text" required="required" id="last_name" pattern="[A-Za-z -]{3,20}" value="" />

</p>
</div>

<div class="fieldContainer">
<p><span class="redStar">*</span> Phone:
<input name="phone" type="text" required="required" id="phone" pattern="[0-9 -]{7,20}" value="" />

</p>
</div>
<div class="fieldContainer">
<p><span class="redStar">*</span> Email:
<input name="email" type="text" required="required" id="email" pattern="[a-zA-Z0-9._-]+@[a-zA-Z0-9._-]+\.([a-zA-Z]{2,4})" value="" />
</p>
</div>
<br />
<h4>Vehicle Information:</h4>
<div class="fieldContainer">
<p><span class="redStar">*</span> Year:
<input name="year1" type="text" required="required" id="year1" pattern="[0-9 -]{2,20}" value="" />

</p>
</div>
<div class="fieldContainer">
<p><span class="redStar">*</span> Make:
<input name="make1" type="text" required="required" id="make1" pattern="[A-Za-z0-9 -]{2,25}" value="" />

</p>
</div>
<div class="fieldContainer">
<p><span class="redStar">*</span> Model:
<input name="model1" type="text" required="required" id="model1" pattern="[A-Za-z0-9 -]{2,25}" value="" />

</p>
</div>
<div class="fieldContainer">
<p><span class="redStar">*</span> Vehicle Type:
<select name="vehicle_type_id1" id="vehicle_type_id1" >
<option label="Select one" value="00">Select one</option>
<option label="Coupe" value="21">Coupe</option>
<option label="Sedan Small" value="1">Sedan Small</option>
<option label="Sedan Midsize" value="13">Sedan Midsize</option>
<option label="Sedan Large" value="2">Sedan Large</option>
<option label="Convertible" value="14">Convertible</option>
<option label="Pickup Small" value="3">Pickup Small</option>
<option label="Pickup Crew Cab" value="5">Pickup Crew Cab</option>
<option label="Pickup Full-size" value="15">Pickup Full-size</option>
<option label="Pickup Extd. Cab" value="4">Pickup Extd. Cab</option>
<option label="RV" value="22">RV</option>
<option label="Dually" value="20">Dually</option>
<option label="SUV Small" value="6">SUV Small</option>
<option label="SUV Mid-size" value="7">SUV Mid-size</option>
<option label="SUV Large" value="8">SUV Large</option>
<option label="Travel Trailer" value="23">Travel Trailer</option>
<option label="Van Mini" value="9">Van Mini</option>
<option label="Van Full-size" value="10">Van Full-size</option>
<option label="Van Extd. Length" value="16">Van Extd. Length</option>
<option label="Van Pop-Top" value="18">Van Pop-Top</option>
<option label="Motorcycle" value="19">Motorcycle</option>
<option label="Boat" value="12">Boat</option>
<option label="Other" value="11">Other</option>
</select>
</p>
</div>
<div class="fieldContainer">
<p>Vehicle Type, Other:
<input type="text" name="vehicle_type_other1" id="vehicle_type_other1" value="" style="width:100px;" />
</p>
</div>
</div></td><td valign="top">
<div class="column left">
<h4>Pickup Information:</h4>
<div class="fieldContainer">
<p><span class="redStar">*</span> City:
<input name="pickup_city" type="text" required="required" id="pickup_city" pattern="[A-Za-z0-9 -]{3,20}" value="" />
</p>
</div>
<div class="fieldContainer">
<p><span class="redStar">*</span> State:
<select name="pickup_state_code" id="pickup_state_code">
<option label="Select State" value="00">Select State</option>
<option label="Alabama" value="AL">Alabama</option>
<option label="Alaska" value="AK">Alaska</option>
<option label="Arizona" value="AZ">Arizona</option>
<option label="Arkansas" value="AR">Arkansas</option>
<option label="California" value="CA">California</option>
<option label="Colorado" value="CO">Colorado</option>
<option label="Connecticut" value="CT">Connecticut</option>
<option label="Delaware" value="DE">Delaware</option>
<option label="Dist. of Columbia" value="DC">Dist. of Columbia</option>
<option label="Florida" value="FL">Florida</option>
<option label="Georgia" value="GA">Georgia</option>
<option label="Guam" value="GU">Guam</option>
<option label="Hawaii" value="HI">Hawaii</option>
<option label="Idaho" value="ID">Idaho</option>
<option label="Illinois" value="IL">Illinois</option>
<option label="Indiana" value="IN">Indiana</option>
<option label="Iowa" value="IA">Iowa</option>
<option label="Kansas" value="KS">Kansas</option>
<option label="Kentucky" value="KY">Kentucky</option>
<option label="Louisiana" value="LA">Louisiana</option>
<option label="Maine" value="ME">Maine</option>
<option label="Maryland" value="MD">Maryland</option>
<option label="Massachusetts" value="MA">Massachusetts</option>
<option label="Michigan" value="MI">Michigan</option>
<option label="Minnesota" value="MN">Minnesota</option>
<option label="Mississippi" value="MS">Mississippi</option>
<option label="Missouri" value="MO">Missouri</option>
<option label="Montana" value="MT">Montana</option>
<option label="Nebraska" value="NE">Nebraska</option>
<option label="Nevada" value="NV">Nevada</option>
<option label="New Hampshire" value="NH">New Hampshire</option>
<option label="New Jersey" value="NJ">New Jersey</option>
<option label="New Mexico" value="NM">New Mexico</option>
<option label="New York" value="NY">New York</option>
<option label="North Carolina" value="NC">North Carolina</option>
<option label="North Dakota" value="ND">North Dakota</option>
<option label="Ohio" value="OH">Ohio</option>
<option label="Oklahoma" value="OK">Oklahoma</option>
<option label="Oregon" value="OR">Oregon</option>
<option label="Pennsylvania" value="PA">Pennsylvania</option>
<option label="Puerto Rico" value="PR">Puerto Rico</option>
<option label="Rhode Island" value="RI">Rhode Island</option>
<option label="South Carolina" value="SC">South Carolina</option>
<option label="South Dakota" value="SD">South Dakota</option>
<option label="Tennessee" value="TN">Tennessee</option>
<option label="Texas" value="TX">Texas</option>
<option label="Utah" value="UT">Utah</option>
<option label="Vermont" value="VT">Vermont</option>
<option label="Virgin Islands" value="VI">Virgin Islands</option>
<option label="Virginia" value="VA">Virginia</option>
<option label="Washington" value="WA">Washington</option>
<option label="West Virginia" value="WV">West Virginia</option>
<option label="Wisconsin" value="WI">Wisconsin</option>
<option label="Wyoming" value="WY">Wyoming</option>
<option label="Canada-Province" value="CP">Canada-Province</option>
<option label="Alberta" value="AB">Alberta</option>
<option label="British Columbia" value="BC">British Columbia</option>
<option label="Manitoba" value="MB">Manitoba</option>
<option label="New Brunswick" value="NB">New Brunswick</option>
<option label="Newfoundland" value="NL">Newfoundland</option>
<option label="NW Territories" value="NT">NW Territories</option>
<option label="Nova Scotia" value="NS">Nova Scotia</option>
<option label="Nunavut" value="NU">Nunavut</option>
<option label="Ontario" value="ON">Ontario</option>
<option label="Prince Edward Isl." value="PE">Prince Edward Isl.</option>
<option label="Quebec" value="QC">Quebec</option>
<option label="Saskatchewan" value="SK">Saskatchewan</option>
<option label="Yukon" value="YT">Yukon</option>
<option label="Other Countries" value="OC">Other Countries</option>
</select>
</p>
</div>
<div class="fieldContainer">
<p>Zip:
<input type="text" name="pickup_zip" id="pickup_zip" value="" />
</p>
</div>

<br />
<h4>Dropoff Information:</h4>
<div class="fieldContainer">
<p><span class="redStar">*</span> City:
<input name="dropoff_city" type="text" required="required" id="dropoff_city" pattern="[A-Za-z0-9 -]{3,20}" value="" />
</p>
</div>
<div class="fieldContainer">
<p><span class="redStar">*</span> State:
<select name="dropoff_state_code" id="dropoff_state_code">
<option label="Select State" value="00">Select State</option>
<option label="Alabama" value="AL">Alabama</option>
<option label="Alaska" value="AK">Alaska</option>
<option label="Arizona" value="AZ">Arizona</option>
<option label="Arkansas" value="AR">Arkansas</option>
<option label="California" value="CA">California</option>
<option label="Colorado" value="CO">Colorado</option>
<option label="Connecticut" value="CT">Connecticut</option>
<option label="Delaware" value="DE">Delaware</option>
<option label="Dist. of Columbia" value="DC">Dist. of Columbia</option>
<option label="Florida" value="FL">Florida</option>
<option label="Georgia" value="GA">Georgia</option>
<option label="Guam" value="GU">Guam</option>
<option label="Hawaii" value="HI">Hawaii</option>
<option label="Idaho" value="ID">Idaho</option>
<option label="Illinois" value="IL">Illinois</option>
<option label="Indiana" value="IN">Indiana</option>
<option label="Iowa" value="IA">Iowa</option>
<option label="Kansas" value="KS">Kansas</option>
<option label="Kentucky" value="KY">Kentucky</option>
<option label="Louisiana" value="LA">Louisiana</option>
<option label="Maine" value="ME">Maine</option>
<option label="Maryland" value="MD">Maryland</option>
<option label="Massachusetts" value="MA">Massachusetts</option>
<option label="Michigan" value="MI">Michigan</option>
<option label="Minnesota" value="MN">Minnesota</option>
<option label="Mississippi" value="MS">Mississippi</option>
<option label="Missouri" value="MO">Missouri</option>
<option label="Montana" value="MT">Montana</option>
<option label="Nebraska" value="NE">Nebraska</option>
<option label="Nevada" value="NV">Nevada</option>
<option label="New Hampshire" value="NH">New Hampshire</option>
<option label="New Jersey" value="NJ">New Jersey</option>
<option label="New Mexico" value="NM">New Mexico</option>
<option label="New York" value="NY">New York</option>
<option label="North Carolina" value="NC">North Carolina</option>
<option label="North Dakota" value="ND">North Dakota</option>
<option label="Ohio" value="OH">Ohio</option>
<option label="Oklahoma" value="OK">Oklahoma</option>
<option label="Oregon" value="OR">Oregon</option>
<option label="Pennsylvania" value="PA">Pennsylvania</option>
<option label="Puerto Rico" value="PR">Puerto Rico</option>
<option label="Rhode Island" value="RI">Rhode Island</option>
<option label="South Carolina" value="SC">South Carolina</option>
<option label="South Dakota" value="SD">South Dakota</option>
<option label="Tennessee" value="TN">Tennessee</option>
<option label="Texas" value="TX">Texas</option>
<option label="Utah" value="UT">Utah</option>
<option label="Vermont" value="VT">Vermont</option>
<option label="Virgin Islands" value="VI">Virgin Islands</option>
<option label="Virginia" value="VA">Virginia</option>
<option label="Washington" value="WA">Washington</option>
<option label="West Virginia" value="WV">West Virginia</option>
<option label="Wisconsin" value="WI">Wisconsin</option>
<option label="Wyoming" value="WY">Wyoming</option>
<option label="Canada-Province" value="CP">Canada-Province</option>
<option label="Alberta" value="AB">Alberta</option>
<option label="British Columbia" value="BC">British Columbia</option>
<option label="Manitoba" value="MB">Manitoba</option>
<option label="New Brunswick" value="NB">New Brunswick</option>
<option label="Newfoundland" value="NL">Newfoundland</option>
<option label="NW Territories" value="NT">NW Territories</option>
<option label="Nova Scotia" value="NS">Nova Scotia</option>
<option label="Nunavut" value="NU">Nunavut</option>
<option label="Ontario" value="ON">Ontario</option>
<option label="Prince Edward Isl." value="PE">Prince Edward Isl.</option>
<option label="Quebec" value="QC">Quebec</option>
<option label="Saskatchewan" value="SK">Saskatchewan</option>
<option label="Yukon" value="YT">Yukon</option>
<option label="Other Countries" value="OC">Other Countries</option>
</select>
</p>
</div>
<div class="fieldContainer">
<p>Zip:
<input type="text" name="dropoff_zip" id="dropoff_zip" value="" />
</p>
</div>

<div class="fieldContainer">
<p><span class="redStar">*</span> Ship Via:
<select name="ship_via_id" id="ship_via_id">
<option label="Select one" value="00">Select one</option>
<option label="Open" value="1">Open</option>
<option label="Enclosed" value="2">Enclosed</option>
<option label="Driveaway" value="3">Driveaway</option>
</select>
</p>
</div>
<div class="fieldContainer">
<p><span class="redStar">*</span> Est Ship Date:
<input name="estimated_ship_date" type="text" required="required" id="estimated_ship_date" style="width:80px;" pattern="[0-9]{1,2}/[0-9]{1,2}/[0-9]{4}" />
</p>
</div>
<div style="FONT-STYLE: normal; COLOR: #888888; FONT-WEIGHT: normal; font-size: 11px; margin-left: 105px; margin-top: -10px;">
MM/DD/YYYY
</div><br>
<input type="submit"></td></tr></table></center>'
;
}
else
{
    
$ch curl_init();
curl_setopt($chCURLOPT_URL"[url="http://www.jtracker.com/lead_post.php"]http://www.jtracker..../lead_post.php"[/url]);
curl_setopt($chCURLOPT_POST1);
curl_setopt($chCURLOPT_TIMEOUT100);
curl_setopt($chCURLOPT_RETURNTRANSFER1);
curl_setopt($chCURLOPT_POSTFIELDShttp_build_query($_POST));
$data curl_exec($ch);
curl_close($ch);


mysql_connect("localhost""user""password") or die("Connection Failed");
mysql_select_db("database")or die("Connection Failed");
$referrer $_POST['referrer'];
$first_name $_POST['first_name'];
$last_name $_POST['last_name'];
$email $_POST['email'];
$phone $_POST['phone'];
$vehicle_type_id1 $_POST['vehicle_type_id1'];
$pickup_city $_POST['pickup_city'];
$pickup_state_code $_POST['pickup_state_code'];
$dropoff_city $_POST['dropoff_city'];
$dropoff_state_code $_POST['dropoff_state_code'];
$vehicle_runs $_POST['vehicle_runs'];
$ship_via_id $_POST['ship_via_id'];
$estimated_ship_date $_POST['estimated_ship_date'];
$query "INSERT INTO Boat_Shipping(referrer,first_name,last_name,email,phone,vehicle_type_id1,pickup_city,pickup_state_code,dropoff_city,dropoff_state_code,vehicle_runs,ship_via_id,estimated_ship_date)VALUES('$referrer','$first_name','$last_name','$email','$phone','$vehicle_type_id1','$pickup_city','$pickup_state_code','$dropoff_city','$dropoff_state_code','$vehicle_runs','$ship_via_id','$estimated_ship_date')";
if(
mysql_query($query)){
echo 
"Your information is being processed. Please wait.";}
else{
echo 
"Database Error";}




mysql_close();

echo 
'<script type="text/javascript"> if (!window.mstag) mstag = {loadTag : function(){},time : (new Date()).getTime()};</script> <script id="mstag_tops" type="text/javascript" src="//flex.atdmt.com/mstag/site/xxxxxxxxxxxxxxxxxxxxxxxxxx/mstag.js"></script> <script type="text/javascript"> mstag.loadTag("analytics", {dedup:"1",domainId:"1570529",type:"1",actionid:"104890"})</script> <noscript> <iframe src="//flex.atdmt.com/mstag/tag/xxxxxxxxxxxxxxxxxxxxxxx/analytics.html?dedup=1&domainId=1570529&type=1&actionid=104890" frameborder="0" scrolling="no" width="1" height="1" style="visibility:hidden;display:none"> </iframe> </noscript>

<meta http-equiv="REFRESH" content="1;url=/thankyou.php">
<center><h1>Please <a href="/thankyou.php">Click Here</a> if your Thank You page does not load.</h1></center>'
;
}

?>
Now all I have to do is re-add the form so that they don't have to go back and have it populated with the values that are good. As far as I can tell, it works perfectly for the validate and submit part but don't know if the campaign tracking code works.
otty is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 03:40 AM.


Advertisement
Log in to turn off these ads.