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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T19:12:56+00:00 2026-06-13T19:12:56+00:00

Based heavily upon this email validation code (which works – I’ve tested it) <?php

  • 0

Based heavily upon this email validation code (which works – I’ve tested it)

<?php


require_once("include/connectionpdo.php"); 


echo("<h2>parsed1</h2> ");

function died($error) {
    // your error code can go here
    echo "We are very sorry, but there were error(s) found with the form you submitted. ";
    echo "These errors appear below.<br /><br />";
    echo $error."<br /><br />";
    echo "Please go back and fix these errors.<br /><br />";
    echo "If you have fixed any possible errors, and you believe that there is a problem with our submission system, please ";
    die();
    }

   echo("<h2>parsed2</h2> ");

   // first checks to see if any information is supplied at all in the required fields 
    if(!isset($_POST['first_name']) ||
        !isset($_POST['last_name']) ||
        !isset($_POST['email']) ||
        !isset($_POST['phone']) ||
        !isset($_POST['addressl1']) ||
        !isset($_POST['addressl2']) ||
        !isset($_POST['town']) ||
        !isset($_POST['county']) ||
        !isset($_POST['type']))
    {
        died('We are sorry, but there appears to be a problem with the form you submitted.');       
    }

    echo("<h3>parsed3</h3> ");

    $first_name = $_POST['fname']; // required
    $last_name = $_POST['sname']; // required
    $email_from = $_POST['email']; // required
    $telephone = $_POST['phone']; // not required
    $dateofbirth = $_POST['dob']; // required
    $addresslone = $_POST['addressl1']; // required
    $addressltwo = $_POST['addressl2']; // required
    $townnm = $_POST['town']; // required
    $countynm = $_POST['county']; // required     
    $typeapp = $_POST['type']; // required
    $issubscribed = $_POST['subscribed']; // required

    // checks to see if information supplied is correct

    echo("<h4>parsed4</h4> ");

    $error_message = "";
    $email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/';
    $number_exp = '/^[0-9]/';  
  if(!preg_match($email_exp,$email_from)) {
    echo("errortest1 ");
    $error_message .= 'The Email Address you entered does not appear to be valid.<br />';
  }
    $string_exp = "/^[A-Za-z .'-]+$/";
  if(!preg_match($string_exp,$first_name)) {
    echo("errortest2 ");
    $error_message .= 'The First Name you entered does not appear to be valid.<br />';
  }
  if(!preg_match($string_exp,$last_name)) {
    echo("errortest3 ");
    $error_message .= 'The Last Name you entered does not appear to be valid.<br />';
  }
    $number_exp = '/^[0-9]/';  
  if(!preg_match($string_exp,$last_name)) {
    echo("errortest4 ");
    $error_message .= 'Please just enter numerical values for your phone number.<br />';
  }

  if(strlen($addresslone) < 2) {
    echo("errortest5 ");
    $error_message .= 'The address (line one) you entered do not appear to be valid.<br />';
  }
   if(strlen($addressltwo) < 2) {
    echo("errortest6 ");
    $error_message .= 'The address (line two) you entered do not appear to be valid.<br />';
  } 
  if((!preg_match($string_exp,$townnm)) || (strlen($townnm) < 2)) {
    echo("errortest7 ");
    $error_message .= 'The town you entered does not appear to be valid.<br />';
  } 
  if((!preg_match($string_exp,$countynm)) || (strlen($countynm) < 2)) {
    echo("errortest8 ");
    $error_message .= 'The county you entered does not appear to be valid.<br />';
  } 

  if(strlen($error_message) > 0) {
    died($error_message);
  }


# the data we want to insert
$data = array($first_name, $second_name, $email_from, $telephone, $dateofbirth, $addresslone, $addressltwo, $townnm, $countynm, $typeapp, $issubscribed);
$STH = $DBH->prepare("INSERT INTO members (fname, sname, email, phone, dob, addressl1, addressl2, town, county, type, subscribed) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
$STH->execute($data);


?>
<!--<!DOCTYPE html>
<head><title></title></head><body> -->

Thank you for contacting us  We will be in touch with you very soon.

<!-- </body></html> -->

The code prints “parsed 2”, but doesn’t get much further.

function died runs, but only prints the additional generic message of “‘We are sorry, but there appears to be a problem with the form you submitted.”

Oddly !isset always seems to return true (regardless of what form information is in the form). I deleted all of the if !isset block, which caused the printing of “parsed 3”, “parsed 4”, “errortest1” and “The Email Address you entered does not appear to be valid.” Again, this was irrespective of whether or not the email address in the form met the stated condition. Removing the if!preg_match statements causes the generation of the error message

“Fatal error: Call to a member function prepare() on a non-object in
public_html/application4.php on line 88”

.

There are no syntax errors, or at least if there are any syntax errors they are generating merely logical errors.

  • 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-13T19:12:57+00:00Added an answer on June 13, 2026 at 7:12 pm

    imho you have changed names for first_name and last_name fields, so below code should return false if all fields in the condition are set:

    if(!isset($_POST['fname']) ||
            !isset($_POST['sname']) ||
            !isset($_POST['email']) ||
            !isset($_POST['phone']) ||
            !isset($_POST['addressl1']) ||
            !isset($_POST['addressl2']) ||
            !isset($_POST['town']) ||
            !isset($_POST['county']) ||
            !isset($_POST['type']))
    {
            died('We are sorry, but there appears to be a problem with the form you submitted.');       
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I made a REST Service which is heavily based on this tutorial . I
I have a project which is heavily JavaScript based (e.g. node.js, backbone.js, etc.). I'm
I am about to embark upon yet another large PHP project. This time, I
I am using my own home grown PHP framework and it is heavily based
Background The main application where I work is based heavily on the MUMPS-esque Caché
I’m developing a site heavily based on jQuery and involving WordPress. Is there any
I've got an app that is heavily based on remote images. They are usually
I'm studying for an automata test on a course that's heavily based on jflap.
Based on the answer for this question What's the difference between CompositionBatch and catalogs?
Based on a configuration setting I'd like to direct users to a This site

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.