Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Facebook Sign In with Google Sign In with OpenID

Categories

We have migrated to a new platform! Please note that you will need to reset your password to log in (your credentials are still in-tact though). Please contact lee@programmersheaven.com if you have questions.
Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

PHP form validate and submit

ottott Posts: 2Member
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.
[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.';
}

if((strlen($valid_first_name)>1)&&(strlen($valid_last_name)>1)&&(strlen($valid_phone)>5)&&(strlen($valid_email)>5)&&(strlen($valid_year1)>0)&&(strlen($valid_make1)>0)&&(strlen($valid_model1)>0)&&(strlen($valid_vehicle_type_id1)>0)&&(strlen($valid_pickup_city)>0)&&($valid_pickup_state_code>0)&&(strlen($valid_dropoff_city)>0)&&($valid_dropoff_state_code>0)&&($valid_vehicle_runs>0)&& ($valid_ship_via_id>0)&& (strlen($valid_estimated_ship_date)>0))
{}
{
post to process.php


}


}
?>
[/code]
Sign In or Register to comment.