Basically after clicking the submit button, I want a pop up box to pop up saying successful or fail, then clicking OK to confirm the message. At the moment i am getting a pop up box "undefined" followed by failed message pop up box. HELP PLEASE!
here is the script
<?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>
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…