0
我有兩個php文件,一個是register.php,其中我有html表單,我用jquery來驗證它。並在process.php我有PHP代碼插入數據在數據庫中的註冊表中,如果它的用戶名不會退出..通過隱藏註冊表單來顯示警報通知
我想通過隱藏HTML表單中的段落標記或div標記顯示alearts .PHP。 這些傳真號碼是 1.用戶名已存在 2.用戶註冊成功 3.註冊不成功。
請採取process.php 這部分看看
if($show>0)
{
die("user exits");
}
if($query)
die("registration successfull");
else
die("registration not successful");
我想通過隱藏的形式和diplaying該通知上顯示register.php文件這些警報...
這裏總之register.php代碼..
<script src='jquery-1.9.1.min.js' type="text/javascript"></script>
<script type="text/javascript" src="jquery.validate.js"></script>
<script >
$(document).ready(function(){
$("#formjs").validate({
rules:{
fname:{
required:true,
minlength:5,
maxlength:23
},
lastname:{
required:true,
minlength:5,
maxlength:23
},
and so onoooooooooooo
some part of form
</div>
<form id="formjs" name="formjs" method="post" action="process.php" >
<p>
<label for="name">Name *</label>
<input type="text" name="fname" id="fname" value="" />
</p>
<p>
<label for="lastnamme">LastName *</label>
<input type="text" name="lastname" id="lastname" />
</p>
<p>
<label for="username">Email Address *</label>
<input type="text" name="username" id="username" />
</p>
<p>
這裏是process.php完整的代碼...
<?php
if(isset($_POST['username']))
{
$ftname=$_POST['fname'];
$lastname=$_POST['lastname'];
$gender=$_POST['gender'];
$bday=$_POST['day'];
$byear=$_POST['year'];
$bmonth=$_POST['month'];
$username=$_POST['username'];
$password=$_POST['password1'];
$contact=$_POST['contact'];
include('config.php');
$Query = mysql_query("SELECT userid from Account where userid = '$username'") or die(mysql_error());
$show=mysql_num_rows($Query);
if($show>0)
{
die("user name already exits");
}
else
{
$query=mysql_query(" insert into Account (firstname,lastname,gender,bday,byear,bmonth,userid,password,contactno) values
('$ftname','$lastname','$gender','$bday','$byear','$bmonth','$username','$password','$contact')") or die(mysql_error());
if($query)
die("registration sucessfull");
else
die("registration not sucessfull");
//echo "<center>Thank you! You are now a member!</center>";
}
}
?>