If the user inputs data in form field 'AddGuestName' i would like to query 'a_table' to see if they are allowed an additional guest. The column 'addguest' contains a "Y" if they can have an additional guest and a "N" if they cannot. If they cannot i would like to display and error message and not save the data until the 'AddGuestName' field is blank. Not sure where im going wrong.
My Code
$Name = check_name($_POST['name'],
" Enter Your First and Last Name....Click Your Browsers Back Button To Re-Enter ");
$RsvpNum = check_input($_POST['RsvpNum'], " Enter The 3 Digit RSVP Number Located On Your RSVP Card....Click Your Browsers Back Button To Re-Enter ");
$AddGuestName = check_rsvp($_POST['AddGuestName'], "You Are Not Allowed An Additional Guest.....Click your Browsers Back Button To Re-Enter");
function check_rsvp($data, $query, $result, $RsvpNum, $AddGuestName, $problem='')<br />
{
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
if ($problem && strlen($data) > 0)
{
mysql_query($query="SELECT addguest FROM a_table WHERE rsvp_num=$RsvpNum");
$result=mysql_query($query);
}
return $data;
if (($result) == 'N')
{
die($problem);
}
return $data;
}
Are you meaning to return $data
right after that first if
? I'm thinking no...
$query="SELECT addguest FROM guests WHERE rsvp_num=$RsvpNum LIMIT 1";
$result=mysql_query($query);
$row = mysql_fetch_row($result);
if ($row[0] =='y'){
...
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.