我所擁有的是php在客戶端簽署表單後更新數據庫字段。這可以工作,但我希望它在確認用戶通過單擊「確定」進行簽名後重定向到新頁面。他們點擊取消,它會讓他們在同一頁面上。在php/mysql數據庫更新後彈出Javascript
<?php
$username = 'joeblow';
require_once ("/mypath/include/connnect_db.php");
?>
<p>Please only submit this after above form is completely signed.</p>
<form id="item_complete" method="post">
<input name="submit" type="submit" form="item_complete" value="Submit After Signing">
</form>
<?php
if(isset($_POST['submit'])) { //if the submit button is clicked
$complete = 'c';
$query = "UPDATE mytbale SET mycolumn='c' WHERE username='$username'";
mysqli_query($con,$query) or die("Cannot Update");
echo "<script> confirmFunction(); </script>";
}
require_once ("/mypath/include/disconnect_db.php");
?>
<script type="text/x-javascript">
function confirmFunction(){
var r=confirm("Confirm that you have signed the form!");
if (r==true){
window.open("http://smartpathrealty.com/smart-path-member-page/");
}
else {
}
}
</script>
我的問題是在php更新數據庫後不執行javascript函數。
我很感激您對此有任何建議或意見。
PHP在服務器上執行。 Javascript在客戶端執行。你想要的是不可能的。您可以**不** **服務器端PHP代碼觸發客戶端警報,然後等待客戶端進行響應。 –
用戶提交表單後,是否有重定向回頁面?我非常樂於接受建議。 – tashworth19191