I want to detect if a condition is met in php and if not show a javascript alert box and prevent the form from processing
I tried to set up the alert box but it always runs
function confirmfillin()
{
$pm = $SQL->query("SELECT * FROM `".TABLE_PREFIX."shopping` WHERE user_id='".$userdata['id']."' AND shopping_id='".$store['id']."'");
if (mysql_num_rows($pm)<1) {
echo "<script type='text/javascript'>alert('fill in form');</script>";
}
}
?>
<form action=postfinish.php method=POST>
<input name="title" type="text" value="my title" >
<div style="position:fixed; bottom:4in; right:20;"><input type="submit" class="submitter" onClick=<?php confirmfillin(); ?> value="Select your item and submit" style="width:220px;"></div>
</form>
the alert show each time the page loads