Jump to content
Sign in to follow this  
Elnof

PHP events

Recommended Posts

Is there such a thing as events in PHP? I want to use the FILTER_VALIDATE_EMAIL when the user clicks 'submit', but the only way I can think to do that is:

...<input type="submit" onClick="<?PHP if (!filter_input(INPUT_GET, "email", FILTER_VALIDATE_EMAIL))  {  echo "Enter a valid E-mail";  } else  {  echo "Thank You!";  } }?>" />...

Would that work?

Share this post


Link to post
Share on other sites

No, you cannot run PHP code client-side, only on the server. If you want to do that, you need to use AJAX to send the email address to a PHP script which can check it and send a response back, or just submit the form and check the email on the next page like usual.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...