0
我有下面的代碼。運行php mysql插入然後運行javascript
它插入到mysql罰款。
但我希望它完成後關閉窗口。下面似乎沒有辦法。
任何幫助將appriciated。
<body>
<?php
$link = mysqli_connect("localhost", "", "", "");
if($link === false){
die("ERROR: Could not connect. " . mysqli_connect_error());
}
// Escape user inputs for security
$patrolno= mysqli_real_escape_string($link, $_POST['patrolno']);
$patroller = mysqli_real_escape_string($link, $_POST['patroller']);
$type= mysqli_real_escape_string($link, $_POST['type']);
$site= mysqli_real_escape_string($link, $_POST['site']);
$location = mysqli_real_escape_string($link, $_POST['location']);
$lat = mysqli_real_escape_string($link, $_POST['lat']);
$lng = mysqli_real_escape_string($link, $_POST['lng']);
$reallat = mysqli_real_escape_string($link, $_POST['reallat']);
$reallng = mysqli_real_escape_string($link, $_POST['reallng']);
$sql = "INSERT INTO activepatrolpoints (patrolno, patroller, type, site, location, lat, lng, reallat, reallng) VALUES ('$patrolno', '$patroller', '$type', '$site', '$location', '$lat', '$lng', '$reallat', '$reallng')";
if(mysqli_query($link, $sql)){
//echo "Records added successfully.";
} else{
echo "ERROR: Could not able to execute $sql. " . mysqli_error($link);
}
mysqli_close($link);
//header('location:index.php');
echo "<script>window.close();</script>";
?>
</body>
這打開about:空白頁,但不關閉它。 –
javascript可以自己關閉任何打開的選項卡,不能像這樣直接關閉。 – Jobayer