php注册用户类型

时间:2013-12-06 01:04:26

标签: php mysql database

您好我尝试制作2注册表格。 普通用户首次注册表单第二次注册页面适用于业务用户

我正在为用户使用一个mysql表。此表适用于与normaluser和业务用户相同。 这是用户类型模块。 普通用户类型为0 可以,但是当我的网站中注册的商业用户类型相同0而不是1 时。

我问这是因为普通用户个人资料页面是普通的用户个人资料。当普通用户在我的网站上闲逛时,他会自动看到正常的用户个人资料,而且当业务用户在我的网站中显示时,他会看到业务用户资料。有2个个人资料页面。

当业务用户注册时,如果普通用户在我的网站注册,他的用户类型自动为0,我该怎么办? 我在我的代码中为业务用户自动添加了用户类型1

我的代码是:

这是我的HTML代码

<form method="post" action="kaydol.php">
<div class="registiration_form1">
<div class="name_surname">
  <div class="name">
  <input onfocus="this.value=''" type="text"  name="vname" autocomplete="off" value="NAME"/> </div>
  <div class="surname">
 <input onfocus="this.value=''" type="text"   name="vsurname" autocomplete="off" value="USERNAME"/>
</div>
</div>
<div class="email"><input onfocus="this.value=''" type="text" name="vemail" value="E-Mail"/></div>
<div class="email-tekrar"><input onfocus="this.value=''" type="text"  name="vemailagain" value="Re-Email" /></div>
<div class="password"><input onfocus="this.value=''" type="password"  name="vpassword" value="PASSWORD" /></div>
<div class="dogum_tarihi_text">      
BIRTHDAY
</div>
<div class="birthday_div">
<div class="d"><select> <option value="" selected>Day</option></select></div>
<div class="m"><select> <option value="" selected>MO</option></select></div>
<div class="y"><select> <option value="" selected>YEAR</option></select></div>
<div class="neden"><a href="#">....... ?</a></div>
</div>
<div class="ekt">Cinsiyet</div>
<div class="erkek_kadin"><div class="erkek"><div class="check"><input type="radio" name="gender"
<?php if (isset($gender) && $gender=="female") echo "checked";?>
value="female"></div><div class="k_etxt">Erkek</div></div>
<div class="kadin"><div class="check"><input type="radio" name="gender"
<?php if (isset($gender) && $gender=="male") echo "checked";?>
value="male"></div><div class="k_etxt">Kadın</div></div></div>
<div class="attantion">Hesap Aç düğmesine tıklayarak, <a href="#">Çerez Kullanımı</a> dahil <a href="#">Veri Kullanımı İlkemizi</a> okuduğunu ve <a href="#">Koşullarımızı</a> kabul etmiş olursun.</div>
<div class="kaydol">
  <div class="kaydol_buton">
  <input type="submit" name="submit"  value="Hesap Aç"/> </div>

</div>

</div>
</form>

这是我的PHP代码:

<?php 
  include("includes/connect.php");

     if(isset($_POST['submit'])){ 
         $name = $_POST['name'];
         $surname = $_POST['surname'];
         $business_name = $_POST['business_name'];
         $email = $_POST['email'];
         $emailagain  = $_POST['emailagain'];
         $password = $_POST['password'];
         $business_category = $_POST['business_category'];
         $country = $_POST['country'];
         $city = $_POST['city'];
         $type = $_POST['type'];


       if($name==''){
           echo"<div class='error_name'>Write name!</div>";
           exit();
           }
        if($surname==''){
           echo"<div class='error_name'>Write surname!</div>";
           exit();
           }
        if($business_name==''){
           echo"<div class='error_name'>Write name write business name!</div>";
           exit();
           }
        if($email==''){
           echo"<div class='error_name'>write email!</div>";
           exit();
           }
        if($_POST['email'] !== $_POST['emailagain']){
       echo"<div class='error_name'>it is not much!</div>";
       exit();
       }
        $check_email = "SELECT * FROM users WHERE email='$email'";
        $run = mysql_query($check_email);
         if(mysql_num_rows($run)>0){
             echo "<div class='error_name'>this email alredy exist!</div>";
             exit();
             }
           $query ="INSERT INTO `users` (`name`,`surname`,`business_name`, `email`,`emailagain`,`password`,`business_category`,`country`,`city`,`type`) VALUES ('$name','$surname','$business_name', '$email','$emailagain','$password','$business_category','$country','$city','type')";

           $result = mysql_query($query) or die(mysql_error());

           if($result){
               echo("<center><h1>Success!</h1></center>");

               }
           else {

               echo("<center><h1>Something wrong!</h1></center>");

               }

       }


?>

1 个答案:

答案 0 :(得分:0)

我注意到你的SQL中有“type”...为什么业务用户不是1?

$query ="...VALUES ('$name','$surname','$business_name', '$email','$emailagain','$password','$business_category','$country','$city','type')";