I have my long PHP script with some JavaScript at the end. In the middle of the script if an 'if' statement is true then is their a way to stop the rest of the PHP script and output the rest of the HTML part of the page. Here's a little snippet:
... more code ...
case 2:
$e=$_POST['email'];
$n=$_POST['name'];
mysql_connect($dbloc,$dbuser,$dbpass);
mysql_select_db($dbname)or die(mysql_error());
$query="SELECT * FROM users WHERE email='$e'";
$re=mysql_query($query);
$numm=mysql_numrows($re);
if($numm>=1){
$js="alert('Sorry but your email is currently in use. Please try again with a different email address.');";
$url="./";
exit();
}
else{
$_SESSION['rEmail']=$e;
$_SESSION['rName']=$n;
}
break;
... more code...
<html goes here />
I originally thought exit()
would end just the PHP portion but still give back the rest of the page but that does not seem to be the case.