简体   繁体   中英

php register user type

Hi i try to make a 2 register form. First register form for normal user and second register page is for business user .

I am using one mysql table for users. this table for same like normaluser and business user . This is user type module. Normal user type is 0 it is ok but when the registered business user in my website his type same 0 not 1 .

I am asking this because normal user profile page is normal user profile. When normal user loged in my website he see automatically normal user profile and also when business user loged in my website he see business user profile. There are 2 profile page .

What can i do automatically user type 1 when business user registered and also when normal user registered in my website his user type is automatically 0 ? What i am adding in my code for user type automatiacally 1 for business user ?

My code is this :

This is my HTML code

<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>

And this is my PHP code:

<?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>");

               }

       }


?>

我注意到您的SQL中有“类型” ...对于企业用户,为什么不是1?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM