My problem is this. After a user enters information on the site and hits submit, I use javascript to ask if these are the 2 values they want to submit. if so run the server code and change the data. if they hit cancel then do nothing. The problem is if cancel is chosen its alert is shown but the php code in the if is still executed. Is there anyway around this problem? I'm frustrated.
if(confirm('Is this info correct? '+z1+':'+z2))
{
alert("Updated users status.");
<?php
if(mysql_connect('localhost', 'LunnyS', 'baud,when'))
{
mysql_select_db('LunnyS');
}
else
{
die ("Could not connect to db " . mysql_error());
}
$querystatus="update users set status='$sta' where ID='$oid'";
mysql_query($querystatus)or die("Invalid insert ".mysql_error());
echo "executed";
?>
}
else
{
window.location="SiteAdmin.php";
alert("Action canceled!");
}
</script>