Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- include("../database/db_conection.php");
- if(isset($_POST['register']))
- {
- $user_name=$_POST['name'];
- $user_lastname=$_POST['lastname'];
- $user_email=$_POST['email'];
- $user_position=$_POST['position'];
- $user_country=$_POST['country'];
- $user_pass=$_POST['pass'];
- $user_copass=$_POST['copass'];
- $salt="h4T3hd9Fse";
- if($user_name=='')
- {
- //javascript use for input checking
- echo"<script>alert('Please enter the name')</script>";
- exit();//this use if first is not work then other will not show
- }
- if($user_position=='')
- {
- echo"<script>alert('Please enter the position')</script>";
- exit();
- }
- if($user_country=='')
- {
- echo"<script>alert('Please enter the country')</script>";
- exit();
- }
- if($user_pass=='')
- {
- echo"<script>alert('Please enter the password')</script>";
- exit();
- }
- if ($user_pass != $user_copass)
- {
- echo"<script>alert('Error... Passwords do not match')</script>";
- exit();
- }else{
- $user_pass=md5($salt.$user_pass);
- $user_copass=md5($salt.$user_copass);
- }
- if(!filter_var($user_email, FILTER_VALIDATE_EMAIL)){
- echo"<script>alert('Please enter the email')</script>";
- exit();
- }
- //here query check weather if user already registered so can't register again.
- $check_email_query="select * from users WHERE user_email='$user_email'";
- $run_query=mysqli_query($dbcon,$check_email_query);
- if(mysqli_num_rows($run_query)>0)
- {
- echo "<script>alert('Email $user_email is already exist in our database, Please try another one!')</script>";
- exit();
- }
- //insert the user into the database.
- $insert_user="insert into users (user_name,user_pass,user_email,user_lastname,user_position,user_country,user_copass) VALUE ('$user_name','$user_pass','$user_email','$user_lastname','$user_position','$user_country','$user_copass')";
- if(mysqli_query($dbcon,$insert_user))
- {
- echo"<script>window.open('../../index.php','_self')</script>";
- }
- }
- session_start();//session starts here
- include("database/db_conection.php");
- if(isset($_POST['login']))
- {
- $user_email=$_POST['email'];
- $user_pass=$_POST['pass'];
- $check_user="select * from users WHERE user_email='$user_email'AND user_pass='$user_pass'";
- $run=mysqli_query($dbcon,$check_user);
- if(mysqli_num_rows($run))
- {
- echo "<script>window.open('welcome.php','_self')</script>";
- $_SESSION['email']=$user_email;//here session is used and value of $user_email store in $_SESSION.
- }
- else
- {
- echo "<script>alert('Email or password is incorrect!')</script>";
- }
- }
Add Comment
Please, Sign In to add comment