Ok so I have a php variable called $contact_id which is inputted from the POST method.
$contact_id = $_POST['contact_id'];
I want this variable to either store a phone number or an email address. I know this isn’t the best way to do things but I have to work with what I have been given.
I was thinking of having something like
if($output = checkEmailValidation($contact_id) == 1 || $output = checkPhoneValidation($contact_id) == 1)
{
//input into database
}
else
{
//display error message
}
checkEmailValidation($input)
{
//do something
return $whatever
}
checkPhoneValidation($input)
{
//do something
return $whatever
}
First of all would this work. Second of all what would I put in the functions to make this work.
Thanks.
For email and phone, I’d go here:
Phone:
http://regexlib.com/DisplayPatterns.aspx?categoryId=7&cattabindex=6&AspxAutoDetectCookieSupport=1
Email:
http://regexlib.com/(A(llgnVic_ey1CZ-ARhYWF5QuIIWLB_e6dL5XiIJIyg6XJi02tVUo6G-L3wnj86Y6iAAoHxFNohNJupckHv1t4NZOxUY2-7EPAF80Lp5q96SMN10FzqKsTUj58iAOwyeNYbpecP25_crQt663bemwnIVb4EJijt_raaBeWYVnQiw7c1nSrQQ3W3PNoyopPWB6K0))/DisplayPatterns.aspx?cattabindex=0&categoryId=1
You can use PHP’s preg_match function to check them: http://php.net/manual/en/function.preg-match.php