我有一个 html 注册表单和一个连接到数据库的 php 代码。现在如果注册成功并添加到数据库中,我如何通过弹出框提醒用户注册成功?
html代码只是一个简单的表单代码,所以这里是php代码:
<?php
if(isset($_POST['submit'])){
$fname = $_POST['firstname'];
$lname = $_POST['lastname'];
$mname = $_POST['middlename'];
$birthday = $_POST['year'] . '/' . $_POST['month'] . '/' . $_POST['day'];
$sex = $_POST['sex'];
$age = $_POST['age'];
$address = $_POST['address'];
$telephone = $_POST['telephone'];
$occupation = $_POST['occupation'];
$telephone = $_POST['telephone'];
$cfname = $_POST['contactfirstname'];
$clname = $_POST['contactlastname'];
mysql_connect('localhost', 'root', '');
mysql_select_db('HMIS');
$query = "INSERT INTO `patientrecords` VALUES('','$lname','$fname','$mname','$birthday','$sex','$address','$telephone','$occupation','$clname','$cfname')";
if(mysql_query($query)){
echo "Registered";
}else{
echo "Error!". mysql_error();
}
}
?>
只有单击某个按钮时,我才能执行 javascript 警报框。但是在 php 代码中你不需要一个按钮.. 所以.. 你是怎么做的?