Jump to content

Recommended Posts

Posted

fisierul index.html:

<html>

<head>

</head>

<body>


<form action="subscribe.php" method="post">

<p>

Name:<br \>

<input type="text" id="name" name="name" size="20" maxlength="40" />

</p>

<p>

E-mail Address: <br />

<input type="text" id="email" name="email" size="20" maxlength="40" />

</p>

<input type="submit" id="submit" name="submit" value="submit" />

</form>

</body>

</html>
fisierul subscribe.php:
<?php

//function used to check e-mail syntax

function validateEmail($email)

{

//create the e-mail validation regular expression

$regexp="^([_a-z0-9-]+)(\.[_a-z0-9-]+)*@([a-z0-9]+)(\.[a-z0-9-]+)*(\.[a-z]{2,6})$";

//validate the syntax

if(eregi($regexp, $email))

return 1;

else return 0;

}


//has the form been submitted?

if(isset($_POST['submit']))

{

$name=htmlentities($_POST['name']);

$email=htmlentities($_POST['email']);

printf("Hi %s <br />", $name);

if(validateEmail($email))

printf("The address <strong>%s</strong> is valid!", $email);

else

printf("The address <strong>%s</strong> is invalid", $email);

}

?>

  • Downvote 1

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • 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.