基本上点击提交按钮后,我想要一个弹出框弹出说成功或失败,然后点击确定确认消息。目前我得到一个弹出框“未定义”,然后是失败的消息弹出框。 请帮忙!
这是脚本
<?php
include ('config.php');
if (isset($_POST['name'])) {
$name = "name";
$query = "INSERT INTO pop ('id','name') VALUES ('','$name')";
$result = mysql_query($query,$cn);
if ($result) {
echo "<script type='text/javascript'>alert('submitted successfully!')</script>";
}
else
{
echo "<script type='text/javascript'>alert('failed!')</script>";
}
}
?>
<html>
<head>
</head>
<body>
<form action="" method="post">
Name:<input type="text" id="name" name="name"/>
<input type="submit" value="submit" name="submit" onclick="alert();"/>
</form>
</body>