I am presently facing a bit of an issue when someone enters their data in my form. The issue is that the form will only allow the user to enter a zip code (allowing numbers only) and what I need from it is to allow entries for both Zip Code (90210) and Postal Code for instance M1M 2N5.
Here is the code :
Please note :
Code: Select all
if (!valid_number($userzip))
$err = $err."• Postal code<br>";Code: Select all
<?
#=========== check if the form is filled out =============#
$err= "";
if (isset($register))
{
if ($username=="")
$err = $err."• Username<br>";
if ($userpass=="")
$err = $err."• Password<br>";
if ($userfullname=="")
$err = $err."• Name<br>";
if (!valid_email($useremail))
$err = $err."• E-mail<br>";
if ($useraddress1=="" && $useraddress2=="")
$err = $err."• Address<br>";
if ($usercity=="")
$err = $err."• City<br>";
if ($userstate=="")
$err = $err."• State/province<br>";
if (!valid_number($userzip))
$err = $err."• Postal code<br>";
if ($terms=="")
$err = $err."• You should agree with terms of the site!<br>";
if (valid_email($useremail) && $escrowid=="")
{
$db->query("select id from ".prefix."users where useremail='$useremail'");
$db->next_record();
if ($db->f("id")!="")
$err = $err."• An account already exists with this email address!<br>";
}
if ($username!="")
{
$db->query("select id from ".prefix."users where username='$username'");
$db->next_record();
if ($db->f("id")!="")
$err = $err."• Username has been taken. Please select a different username!<br>";
}
if ($err=="" && $escrowid=="")
{
$db->query("insert into ".prefix."users (username, userpass, userfullname, useremail, userbusiness, useraddress1, useraddress2, usercity, userstate, userzip, usercountry, paymentaccepttype, registrationdate)
values ('$username', '$userpass', '$userfullname', '$useremail', '$userbusiness', '$useraddress1', '$useraddress2', '$usercity', '$userstate', '$userzip', '$usercountry', '$paymentaccepttype', '".date("U")."')");
echo "Thank you for the registration with us.";
registration_letter($useremail);
include("inc/footer.php");
exit();
}
}Code: Select all
function valid_number($num)
{
if(ereg("^[0-9]+$",$num))
return true;
else
return false;
}If anyone could kindly help me I will be eternally greatfull.
Thanks in advance.