Back to lesson Try it Yourself
PHP Form Validation and Security
PHP
Result

PHP runs on a web server

Browsers can't run PHP. To try this code: install XAMPP, save it as a file in htdocs (use Download above), then open it at http://localhost/yourfile.php.

Output
<p class="error">Enter a valid email address.</p>
<p class="error">Enter a Kenyan mobile number, e.g. 0712345678.</p>
<form method="post">
  <input name="name" value="Otieno">
  <input name="email" value="otieno@mail">
  <input name="phone" value="0712">
  <button>Register</button>
</form>

Keyboard shortcuts

Ctrl + EnterRun the code
Ctrl + SSave in this browser
Ctrl + /Comment / uncomment line
Tab / Shift + TabIndent / outdent
Ctrl + Z / Ctrl + YUndo / redo
Ctrl + FFind (browser search)

Your code is saved automatically in this browser. Share copies a link that opens this exact code. Code runs in a safe sandbox – it can't see your account.

Are you sure?