Jump to content

Email Checker before Submission


ksduded

Recommended Posts

I am using an email variable from a form textfield to create a subdirectory. It only happens once the user hits the submit button on the form.

 

Now if the user didn't enter the email address, my whole system will get messed up, and no one else will be able to use it.

 

I need to create an email checker which checks it before the user hits the submit button. So it should check the email textfield right after the user enters in.

Link to comment
https://forums.phpfreaks.com/topic/123975-email-checker-before-submission/
Share on other sites

 if(!$_POST['email'])

  {

   print "You did not enter a email, please go back and enter a email.";

  }

 

Just change email to whatever you named the input form text area for email.

 

Pretty basic though, it'll accept stuff like "email" which isn't a valid email address.

Ok, so check it via a regular expression.  Search for a email format checker.

The email format checkers that I have seen only check it once the form has been submitted.

I need to check it before it has been submitted.

 

 if(!$_POST['email'])

  {

   print "You did not enter a email, please go back and enter a email.";

  }

 

Just change email to whatever you named the input form text area for email.

 

Pretty basic though, it'll accept stuff like "email" which isn't a valid email address.

I don't know how that will check it before submission. Do I place it right after the email textfield, before the submit button?

Like this

 

if(isset($_POST['submit']))  // checks to see if submit was pressed

{

  if(!$_POST['email']) // if there is no email, it doesn't advance.

   {

    print "You did not enter a email, please go back and enter a email.";

   }

  else

   {

   $InsertQuery=mysql thingy // Your query to create the directories etc.

   }

  }

else

{

// Form stuff where all the textfields and submit button are

}

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.