Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8918977
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T05:53:34+00:00 2026-06-15T05:53:34+00:00

This code works for validation, but I cannot get it to work with submitting

  • 0

This code works for validation, but I cannot get it to work with submitting and I can’t figure out why. As far as I can tell the issue is in the if statement at the end of the PHP, starting with if((strlen($valid_first_name)
I have looked through many instructional sites but can’t figure out the issue. I would appreciate and help or guidance on this! Thank you!

<?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)>0)&&(strlen($valid_last_name)>0)&&(strlen($valid_phone)>0)&&(strlen($valid_email)>0)&&(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))
{
//mysql_query(' SQL insert statement');
header("Location: thanks.html");

}


}
?>

<!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>

<title>Reg Form</title>

<!-- Meta Tags -->
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<!-- CSS -->
<link rel="stylesheet" href="css/structure.css" type="text/css" />
<link rel="stylesheet" href="css/form.css" type="text/css" />

<!-- JavaScript -->
<script type="text/javascript" src="js/9lessons.js"></script>
<style type="text/css">
.err
{
font-size:11px;
padding-left:10px;
color:#CC0000;
float:left;

}
input
{
float:left;

}
</style>

</head>

<body id="public">
    <div style="height:30px"></div>

<div id="container">

<div style="height:30px"></div>

<form autocomplete="on"
    enctype="multipart/form-data" method="post" action=""  name="form">



<ul>


<li id="foli1"      class="   ">
    <label class="desc" id="title1" for="Field1">
        First Name          </label>
    <div>
        <input id="first_name"          name="first_name"           type="text"             class="field text medium"           value="<?php echo $valid_first_name; ?>"            maxlength="255"             tabindex="1"                        /><span class="err"> <?php echo $error_first_name; ?></span>
        </div>
    </li>
    <li id="foli2"      class="   ">
    <label class="desc" id="title1" for="Field2">
        Last Name           </label>
    <div>
        <input id="last_name"           name="last_name"            type="text"             class="field text medium"           value="<?php echo $valid_last_name; ?>"             maxlength="255"             tabindex="2"                        />
        </div>
        <div><span class="err"> <?php echo $error_last_name; ?></span>
        </div>
    </li>


<li id="foli3"      class="   ">
    <label class="desc" id="title3" for="Field3">
        Phone</label>
    <div>
        <input id="phone"           name="phone"            type="text"             class="field text medium"           value="<?php echo $valid_phone; ?>"             maxlength="255"             tabindex="3"                        /><span class="err"> <?php echo $error_phone; ?></span>
        </div>
    </li>


<li id="foli4"      class="   ">
    <label class="desc" id="title4" for="Field3">
        Email           </label>
    <div>
        <input id="email"           name="email"            type="text"             class="field text medium"           value="<?php echo $valid_email; ?>"             maxlength="255"             tabindex="4"  /><span class="err"> <?php echo $error_email; ?></span>
        </div>
    </li>


<li id="foli5"      class="   ">
    <label class="desc" id="title5" for="Field5">
        Year            </label>
    <div>
        <input id="year1"           name="year1"            type="text"             class="field text medium"           value="<?php echo $valid_year1; ?>"             maxlength="255"             tabindex="5"                        /><span class="err"> <?php echo $error_year1; ?></span>
        </div>
    </li>

    <li id="foli6"      class="   ">
    <label class="desc" id="title6" for="Field6">
        Make            </label>
    <div>
        <input id="make1"           name="make1"            type="text"             class="field text medium"           value="<?php echo $valid_make1; ?>"             maxlength="255"             tabindex="6"                        /><span class="err"> <?php echo $error_make1; ?></span>
        </div>
    </li>

    <li id="foli7"      class="   ">
    <label class="desc" id="title7" for="Field7">
        Model           </label>
    <div>
        <input id="model1"          name="model1"           type="text"             class="field text medium"           value="<?php echo $valid_model1; ?>"            maxlength="255"             tabindex="7"                        /><span class="err"> <?php echo $error_model1; ?></span>
        </div>
    </li>


<li id="foli8"      class="   ">
    <label class="desc" id="title8" for="Field8">
        Vehicle type        </label>
    <div>
        <select id="vehicle_type_id1"           name="vehicle_type_id1"             class="field select medium"             tabindex="8" style="float:left"> 
                        <option value="00">Gender</option><option value="1">Male</option><option value="2">Female</option>
          </select><span class="err"> <?php echo $error_vehicle_type_id1; ?></span>
    </div>
    </li>

    <li id="foli9"      class="   ">
    <label class="desc" id="title9" for="Field9">
        pickup city</label>
    <div>
        <input id="pickup_city"             name="pickup_city"          type="text"             class="field text medium"           value="<?php echo $valid_pickup_city; ?>"           maxlength="255"             tabindex="9"                        /><span class="err"> <?php echo $error_pickup_city; ?></span>
        </div>
    </li>

    <li id="foli10"         class="   ">
    <label class="desc" id="title10" for="Field10">
        pickup  state       </label>
    <div>
        <select id="pickup_state_code"          name="pickup_state_code"            class="field select medium"             tabindex="10" style="float:left"> 
                        <option value="00">Gender</option><option value="1">Male</option><option value="2">Female</option>
          </select><span class="err"> <?php echo $error_pickup_state_code; ?></span>
    </div>
    </li>

    <li id="foli11"         class="   ">
    <label class="desc" id="title11" for="Field11">
        Dropoff City        </label>
    <div>
        <input id="dropoff_city"            name="dropoff_city"             type="text"             class="field text medium"           value="<?php echo $valid_dropoff_city; ?>"          maxlength="255"             tabindex="11"                       /><span class="err"> <?php echo $error_dropoff_city; ?></span>
        </div>
    </li>

    <li id="foli12"         class="   ">
    <label class="desc" id="title12" for="Field12">
        Dropoff State       </label>
    <div>
        <select id="pickup_state_code"          name="pickup_state_code"            class="field select medium"             tabindex="12" style="float:left"> 
                        <option value="00">Gender</option><option value="1">Male</option><option value="2">Female</option>
          </select><span class="err"> <?php echo $error_pickup_state_code; ?></span>
    </div>
    </li>

    <li id="foli13"         class="   ">
    <label class="desc" id="title13" for="Field13">
        Runs?           </label>
    <div>
        <select id="vehicle_runs"           name="vehicle_runs"             class="field select medium"             tabindex="13" style="float:left"> 
                        <option value="00">Gender</option><option value="1">Male</option><option value="2">Female</option>
          </select><span class="err"> <?php echo $error_vehicle_runs; ?></span>
    </div>
    </li>

    <li id="foli14"         class="   ">
    <label class="desc" id="title14" for="Field14">
        Ship    Via?        </label>
    <div>
        <select id="ship_via_id"            name="ship_via_id"          class="field select medium"             tabindex="14" style="float:left"> 
                        <option value="00">Gender</option><option value="1">Male</option><option value="2">Female</option>
          </select><span class="err"> <?php echo $error_ship_via_id; ?></span>
    </div>
    </li>

     <li id="foli15"        class="   ">
    <label class="desc" id="title15" for="Field15">
        Ship    Date        </label>
    <div>
        <input id="estimated_ship_date"             name="estimated_ship_date"          type="text"             class="field text medium"           value="<?php echo $valid_estimated_ship_date; ?>"           maxlength="255"             tabindex="15"                       /><span class="err"> <?php echo $error_estimated_ship_date; ?></span>
        </div>
    </li>


<li id="foli15"         class="   "></li>


<li class="buttons">
                <input  type="submit" value="Submit" style=" background:#0060a1; color:#FFFFFF; font-size:14px; border:1px solid #0060a1"/>
      </li>


</ul>
</form>
<div style="height:20px"></div>
</div><!--container-->
</body>
</html>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T05:53:35+00:00Added an answer on June 15, 2026 at 5:53 am

    Yes, you are not closing right your (neverending) last if, you have it ending like this:

    ... && strlen($valid_estimated_ship_date>0))
    

    and it should be:

    .. && (strlen($valid_estimated_ship_date)>0))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simple setup but cannot figure out why this wont work. Here's
This code works well for displaying separate xml items in my main.xml. But is
This code works fine, but I'll want to handle exception if any thing goes
I have tried so many combinations, but cannot get the validation to turn off
I have a error that I can not get rid of, but the code
This is part of an assignment. Everything that's supposed to work, already works, but
I've been trying out MSMQ with WCF, but I can't seem to get it
This is a pretty frustrating newb question, but I can't seem to get iteration
This code works well: UIDatePicker *pickerView = [[UIDatePicker alloc] initWithFrame:pickerFrame]; [pickerView addTarget:self action:@selector(pickerChanged:) forControlEvents:UIControlEventValueChanged];
This code works fine in Chrome. However, in Firefox, when it hits the GMxhr

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.