bigup401 has asked for the wisdom of the Perl Monks concerning the following question:
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 } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: problem checking availability
by haj (Vicar) on Sep 03, 2018 at 21:52 UTC | |
by bigup401 (Pilgrim) on Sep 03, 2018 at 23:10 UTC | |
by haj (Vicar) on Sep 04, 2018 at 07:47 UTC | |
by bigup401 (Pilgrim) on Sep 04, 2018 at 08:23 UTC | |
by poj (Abbot) on Sep 04, 2018 at 13:02 UTC | |
|