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 6047299
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T07:20:09+00:00 2026-05-23T07:20:09+00:00

I have a contact form that is being submitted, I have PHP validation all

  • 0

I have a contact form that is being submitted, I have PHP validation all set up before it sends the email, however, I have 2 fields that are dynamically disabled or enabled based on the link clicked to get to the contact form.

I need to know how to determine whether they are disabled or not and then validate them only if they’re not disabled.

Here’s part of my form:

<label for="name">Name</label><br />
<input type="text" name="name" id="name" />

<label for="email">Email</label><br />
<input type="text" name="email" id="email" />

<label for="number">Phone Number</label><br />
<input type="text" name="number" id="number" />

<div id="date-time">
    <label for="date">Date</label><br />
    <input type="text" name="date" id="date" <?php
        if (!isset($_GET["appt"])==true) echo('disabled="disabled"'); ?> />

    <label for="time">Time</label><br />
    <input type="text" name="time" id="time" <?php
        if (!isset($_GET["appt"])==true) echo('disabled="disabled"'); ?> />
</div>

Here’s part of my mail.php file (disregard the cookie functions):

    $name   = trim($_POST["name"]);
    $email  = trim($_POST["email"]);
    $phone  = trim($_POST["phone"]);
    $date   = trim($_POST["date"]);
    $time   = trim($_POST["time"]);

//Check to make sure that the name field is not empty
    if($name == NULL) {
        $hasError = true;
        $emailSent = false;
        cookie("hasError", "true");
        cookie("nameError", "true");
    } else {
        $name = $name;
    }

//Check to make sure sure that a valid email address is submitted
    if($email == NULL) {
        $hasError = true;
        $emailSent = false;
        cookie("hasError", "true");
        cookie("emailError", "true");
    } else if (!eregi("^[A-Z0-9._%-]+@[A-Z0-9._%-]+\.[A-Z]{2,4}$", $email)) {
        $hasError = true;
        $emailSent = false;
        cookie("hasError", "true");
        cookie("emailError", "true");
    } else {
        $email = $email;
    }

//Check to make sure that the phone field is not empty
    if($phone == '' || $phone < 10) {
        $hasError = true;
        $emailSent = false;
        cookie("hasError", "true");
        cookie("phoneError", "true");
    } else {
        $phone = $phone;
    }

//Check to make sure that the date field is not empty
    if($date == '') {
        $hasError = true;
        $emailSent = false;
        cookie("hasError", "true");
        cookie("dateError", "true");
    } else {
        $date = $date;
    }

//Check to make sure that the time field is not empty
    if($time == '') {
        $hasError = true;
        $emailSent = false;
        cookie("hasError", "true");
        cookie("timeError", "true");
    } else {
        $time = $time;
    }

I’m still learning my way around PHP so thanks in advance for any help you can give. 🙂

//EDIT

appt is from a URL query string. Even if the query string is not present & the inputs are disabled, I’m using jQuery to add or remove disabled from the inputs upon clicking a link on the page.

  • 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-05-23T07:20:10+00:00Added an answer on May 23, 2026 at 7:20 am

    You can use isset($_POST['date']) to check if the value is set during the submit, cos, if the fields that are disabled will not be submitted in the form right.

    EDIT

    You might face a problem here, as it is very easy to tamper with the form in client side and pass both date and time here. So the best thing you can do here is have a hidden field which you set with either date or time along with setting the “dynamic” fields disabled. So, in the server side, just read the hidden field and read the required value accordingly.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a contact form that sends to my email and I recently got
The basics: I have a contact form that uses php to validate the forms.
I have a contact form that I'm writing using jQuery and PHP. Below is
I have a website with a contact form. User submits name, email and message
I have a form that looks kind of like this: <div> <div class=contact> <h1>Person's
I have a contact form i want to use Ajax for. My contact.php script
I have a pretty standard contact form that uses a cfc for processing now.
I have a cForms II contact form set up. It works perfectly if I
I have a within a form that contains other fields for the form. I
I have a table for a contact form and this table contains another table

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.