PHP read before javascript ????
Posted: Mon Nov 20, 2006 12:47 pm
Hi,
Does PHP get read before the javascript
As my confirm box doesnt display it just does the PHP straight away a deletes the table
this is whats shown
heres the code:
thanks any help would be nice
Does PHP get read before the javascript
As my confirm box doesnt display it just does the PHP straight away a deletes the table
this is whats shown
i think the php is stoping the javascript as in my php it has the die function. Is this is what is being read and stops the js??Pleaseeeee function disp_confirm() { var r=confirm("Press a button") if (r==true) { document.write("You pressed OK!
Droped DB
heres the code:
Code: Select all
<script type="text/javascript">
function disp_confirm()
{
var r=confirm("Are you sure you want to delete")
if (r==true)
{
document.write("<?
$sql = "DROP TABLE `$tabletodrop`";
$dosql=mysql_query($sql);
if ($dosql)
{
$logedinuser=$_SESSION['user'];
$month=date('F Y');
$day=date('l dS');
$time=date('h:i:s A');
$addtolog="INSERT INTO net_db_log (`username`, `log`, `time`, `day`, `month`) VALUES ('$logedinuser', 'Deleted Database $tabletodrop', '$time', '$day', '$month')";
$doaddlog=mysql_query($addtolog);
die ("<br>Droped $tabletodrop");
}
else
{
echo "<br>Error Droping $tabletodrop it may not exist";
}
?>")
}
else
{
document.write("Canceled")
}
}
</script>
<form>
<input type="button" onclick="disp_confirm()" value="Display a confirm box">
</form>