validation for a beginner
Posted: Fri Jan 28, 2005 8:12 am
I’m going mad trying to sort this out so I’m wondering if anybody can see what I’m missing here because for some reason I keep getting the message 'invalid email'. I’m sure the expression is ok as I’m using this from another form that I have but obviously I’m missing something else vital.
Thanks for any advice
Brian
Thanks for any advice
Brian
Code: Select all
<?php $pattern = '/^\wї-.\w]*@(ї-a-z0-9]+\.)+їa-z]{2,4}$/i';
if ($_POST && array_key_exists('send',$_POST)) {
$nomessage='';
$error=array();
$message='';
$guestemail= '';
// Check each field and build errors array if problems found
if (empty($_POSTї'guestemail'])) {
echo 'empty email'; // to be removed once working
} else {
if (!preg_match($pattern,$guestemail)) $errorї'invalid'] = 'invalid email';
}
echo 'validate code running'; // to be removed once working
}
?>
<form method="post" name="form1" action="">
<table align="center" class="mainContent">
<tr valign="baseline">
<td nowrap align="right">Email Address:
<?php
if (isset($error)) {
foreach ($error as $key => $value) {
echo $value.'<br />';
}
}
?>
</td>
<td><input type="text" name="guestemail" id="guestemail" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right"> </td>
<td><input name="send" type="submit" id="sendCom" value="Post Message" /> </td>
</tr>
</table>
<input type="hidden" name="MM_insert" value="form1">
</form>