Lars,
Many thanks for your help. I am not too familiar with SQL syntax, my background is C++ programming. I would be grateful if you could let me know if the following SQL function is correct. If not please let me know the correct way to construct the function.
CREATE FUNCTION VerifyEmployee (IN surname VARCHAR(15), IN email VARCHAR(30))
RETURNS INT
BEGIN
SELECT LastName,EmailAddress FROM Employee
IF(LastName = surname AND EmailAddress = email)
THEN return 1;
ELSE return 0;
END IF;
END;
Further, how can I use the above function in a PHP statement, e.g. can I say something like:
<?php
$con = .............
$answer = 0;
//‘surname’ and ‘email’ are entered by user
$surname=mysql_real_escape_string($POST['surname']);
$email=mysql_real_escape_string($POST['email']);
$sql= mysql_query("$answer = call VerifyEmployee($secondname, $email)");
if($answer == 1) echo "Employee verified”;
else echo "Employee not verified”;
if (!mysql_query($sql,$con))
{ die('Error: ' . mysql_error());
}
mysql_close($con);
?>