PHP 函数成功与否的消息对话框
Message dialog if PHP function successful or not
我有一个 PHP 函数可以在将数据插入数据库之前检查一些数据。
现在,无论我在哪里调用函数,我的 php 函数中都会显示这些消息。例如:div。
我想要一个显示消息的消息框,而不是 div 中的小消息。我怎样才能做到这一点?谢谢
if($u_l_name == $dbuser_last_name and $u_name == $dbuser_first_name)
{
echo "Record Exists Already";
}
else
{
$stmt2 = $this->link->prepare("INSERT INTO employers (user_password, user_first_name, user_last_name, user_DOB, user_address, user_email, user_phone, user_gender, user_position, user_contract_type, user_contract_hours) VALUES (?,?,?,?,?,?,?,?,?,?,?)");
$stmt2->bind_param("ssssssssssi", $u_password, $u_name, $u_l_name, $u_DOB, $u_address, $u_email, $u_phone, $u_gender, $u_position, $u_contract_type, $u_contract_hours);
$stmt2->execute();
$stmt2->close();
echo "Record Added Succesfully";
}
函数调用:
<?php
if(isset($_POST['submitButton']))
{
$admin_query->addEmployerData($u_password, $u_name, $u_l_name, $u_DOB, $u_address, $u_email, $u_phone, $u_gender, $u_position, $u_contract_type, $u_contract_hours);
}
?>
你是指Javascriptalert方法吗?如果是的话,你可以这样做:
$message;
if($u_l_name == $dbuser_last_name and $u_name == $dbuser_first_name)
{
$message = "Record Exists Already";
}
else
{
$stmt2 = $this->link->prepare("INSERT INTO employers (user_password, user_first_name, user_last_name, user_DOB, user_address, user_email, user_phone, user_gender, user_position, user_contract_type, user_contract_hours) VALUES (?,?,?,?,?,?,?,?,?,?,?)");
$stmt2->bind_param("ssssssssssi", $u_password, $u_name, $u_l_name, $u_DOB, $u_address, $u_email, $u_phone, $u_gender, $u_position, $u_contract_type, $u_contract_hours);
$stmt2->execute();
$stmt2->close();
$message = "Record Added Succesfully";
}
echo "<script>alert('$message')</script>";
我有一个 PHP 函数可以在将数据插入数据库之前检查一些数据。 现在,无论我在哪里调用函数,我的 php 函数中都会显示这些消息。例如:div。 我想要一个显示消息的消息框,而不是 div 中的小消息。我怎样才能做到这一点?谢谢
if($u_l_name == $dbuser_last_name and $u_name == $dbuser_first_name)
{
echo "Record Exists Already";
}
else
{
$stmt2 = $this->link->prepare("INSERT INTO employers (user_password, user_first_name, user_last_name, user_DOB, user_address, user_email, user_phone, user_gender, user_position, user_contract_type, user_contract_hours) VALUES (?,?,?,?,?,?,?,?,?,?,?)");
$stmt2->bind_param("ssssssssssi", $u_password, $u_name, $u_l_name, $u_DOB, $u_address, $u_email, $u_phone, $u_gender, $u_position, $u_contract_type, $u_contract_hours);
$stmt2->execute();
$stmt2->close();
echo "Record Added Succesfully";
}
函数调用:
<?php
if(isset($_POST['submitButton']))
{
$admin_query->addEmployerData($u_password, $u_name, $u_l_name, $u_DOB, $u_address, $u_email, $u_phone, $u_gender, $u_position, $u_contract_type, $u_contract_hours);
}
?>
你是指Javascriptalert方法吗?如果是的话,你可以这样做:
$message;
if($u_l_name == $dbuser_last_name and $u_name == $dbuser_first_name)
{
$message = "Record Exists Already";
}
else
{
$stmt2 = $this->link->prepare("INSERT INTO employers (user_password, user_first_name, user_last_name, user_DOB, user_address, user_email, user_phone, user_gender, user_position, user_contract_type, user_contract_hours) VALUES (?,?,?,?,?,?,?,?,?,?,?)");
$stmt2->bind_param("ssssssssssi", $u_password, $u_name, $u_l_name, $u_DOB, $u_address, $u_email, $u_phone, $u_gender, $u_position, $u_contract_type, $u_contract_hours);
$stmt2->execute();
$stmt2->close();
$message = "Record Added Succesfully";
}
echo "<script>alert('$message')</script>";