如何将此代码放入我的程序中的注册码中,如果注册成功,将弹出?我与jquery新,所以我不知道如何做这个东西...请帮助我的人请。在php代码中插入jquery
<script>
$(document).ready(function() {
// show a dialog box when clicking on a link
$("#success").on('click', function(e) {
e.preventDefault();
$.Zebra_Dialog('<strong>Congratulations </strong>' +
'You are now successfully registered!');
});
});
</script>
这里是我的PHP代码:
<?php
if(isset($_POST['save'])) {
$fname = $_POST['fname'];
$lname = $_POST['lname'];
$position = $_POST['position'];
$username = $_POST['username'];
$password = $_POST['password'];
$dateregistered = date("Y-m-d H:i:s");
if (!$_POST['fname'] || !$_POST['lname'] || !$_POST['position'] || !$_POST['username'] || !$_POST['password']) {
echo "You did not complete all of the required fields!";
} else {
$query="INSERT INTO users (position, fname, lname, username,password,dateregistered) VALUES ('$position','$fname','$lname','$username','$password',CURRENT_TIMESTAMP) ";
mysql_query($query);
if($query)
echo "You Successfully Created an Account!";
}
}
?>
我想更换回声事情到jQuery代码...任何人都知道如何???
好,最简单的解决办法是要回显jQuery代码。 –
@YUNOWORK除了几乎是唯一的解决方案... – Ryan
好吧,用PHP向DOM添加代码并不能提供太多的可能性^^我想你可以使用DOMDocument,但是这太多努力只为一个小文本框。 –