i dont know why my code doesn;t check the id number and phone availability. it doesn;t insert data if phone or id number exits but it still goes to next.pl it insert data very well if phone or id number not exits. but i want to remain on same page if phone or id number exits and print error
if ($PHONE, $ID_NUMBER) { $CHECK_PHONE = $DBH->prepare("SELECT COUNT(*) FROM tbl1 WHERE PHONE = +?"); $CHECK_PHONE->execute($PHONE); $P = $CHECK_PHONE->fetchrow_arrayref(); $CHECK_ID_NUMBER = $DBH->prepare("SELECT COUNT(*) FROM tbl1 WHERE ID_N +UMBER = ?"); $CHECK_ID_NUMBER->execute($ID_NUMBER); $ID = $CHECK_ID_NUMBER->fetchrow_arrayref(); if ($P eq $PHONE) { $error_phone = "phone exits"; } if ($P eq $PHONE) { $error_id = "id exits"; } if ($P ne $PHONE && $ID ne $ID_NUMBER){ $ADD_DATA = $DBH->prepare('INSERT INTO tb11(PHONE, ID_NUMBER) VALUES(?,?)'); $ADD_DATA->execute($PHONE, $ID_NUMBER); $ADD_DATA->finish; # go to next.pl next page } }
In reply to problem checking availability by bigup401
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |