<?php

$ypostcode = stripslashes($_REQUEST[you]);
$yourpostcode = htmlspecialchars($ypostcode);
if(!ereg('^[A-Za-z]{1,2}[0-9]{1,2}[[:space:]]{1,}[0-9][A-Za-z]{2}$',$ypostcode)){
    $pcStat=0;
}
else{
    $pcStat=1;
}
$yemail = stripslashes($_REQUEST[email]);
$youremail = htmlspecialchars($yemail);
if(!ereg('^[-A-Za-z0-9._]+@([-A-Za-z0-9]+\.)+[A-Za-z]{2,6}$',$yemail)){
    $emStat=0;
}
else{
    $emStat=1;
}

?>


<html>
<head>
<title>This is an RegExpr demo</title>
</head>
<body bgcolor=#FFFF00>
<h1>Regular expressions</h1>
<table>
<form>
<tr><td>Please enter your postcode <td><input name = you value="<?= $yourpostcode ?>">
<tr><td>Please enter your email <td><input name = email  value="<?= $youremail ?>">
<tr><td><input type=submit>
</form>
</table>
<hr>

<?
if ($yourpostcode && $pcStat){
    print "Your post code is valid: $yourpostcode";
}
if ($yourpostcode && !$pcStat){
    print "Your post code is not valid :  $yourpostcode";
}
print "<p>\n";
if ($youremail && $emStat){
    print "Your email address is valid: $youremail";
}
if ($youremail && !$emStat){
    print "Your email address is not valid :  $youremail";
}


?>

</body>
</html>

-- PeterJones - 08 Nov 2006

Edit | Attach | Watch | Print version | History: r1 | Backlinks | Raw View | WYSIWYG | More topic actions
Topic revision: r1 - 2006-11-08 - PeterJones
 
    • Cern Search Icon Cern Search
    • TWiki Search Icon TWiki Search
    • Google Search Icon Google Search

    Main All webs login

This site is powered by the TWiki collaboration platform Powered by PerlCopyright & 2008-2019 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback