Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ######## Code for UserRegistration.php
- <?php
- $DB_HOST="localhost";//declaring server
- $DB_USER="root";// declaring server's username
- $DB_PASSWORD="";//declaring server's password
- $DB_NAME="lights";// declaring the DAtabase name
- $con = mysqli_connect($DB_HOST,$DB_USER,$DB_PASSWORD,$DB_NAME);//establishing a connection with database
- if($_SERVER['REQUEST_METHOD']=='POST')//checking if the request made is using the method post
- {
- $F_name = $_POST['f_name'];//using the post method we are getting the value of 'f_name' and storing it in $F_name.The $_POST variable is used to collect values from a form with method="post". Information sent from a form with the POST method is invisible to others and has no limits on the amount of information to send;
- $L_name = $_POST['L_name'];//using the post method we are getting the value of 'L_name' and storing it in $L_name.The $_POST variable is used to collect values from a form with method="post". Information sent from a form with the POST method is invisible to others and has no limits on the amount of information to send;
- $email = $_POST['email']; //using the post method we are getting the value of 'email' and storing it in $emails.The $_POST variable is used to collect values from a form with method="post". Information sent from a form with the POST method is invisible to others and has no limits on the amount of information to send;
- $password = $_POST['password'];//using the post method we are getting the value of 'password' from the app and storing it in $password.The $_POST variable is used to collect values from a form with method="post". Information sent from a form with the POST method is invisible to others and has no limits on the amount of information to send;
- $key = $_POST['product_key'];// //using the post method we are getting the value of 'product_key' and storing it in $key.The $_POST variable is used to collect values from a form with method="post". Information sent from a form with the POST method is invisible to others and has no limits on the amount of information to send;
- $CheckSQL = "SELECT * FROM userlogintable WHERE user_email='$email'";//A simple MySQL query;
- $check = mysqli_fetch_array(mysqli_query($con,$CheckSQL));//as stated above mysqli_query executes a mysql statement and mysqli_fetch_array stores it in numeric or associative array;
- if(isset($check)) //checking if there already exist a email in the table
- {
- echo 'Email Already Exist'; // if condition above is true "Email Already Exist" is printed on screen and on app toast message appears
- }
- if($key != "M14SK19SN25LS07D")// validating the key
- {
- echo 'Product Key is wrong';// if the product key is wrong the following message is displayed using toast message in the app.
- }
- else// if every "if" statement above is false then the value is inserted in the table named userlogintable
- {
- $Sql_Query = "INSERT INTO `userlogintable` (`first_name`,`last_name`,`user_email`,`user_password`) values ('$F_name','$L_name','$email','$password')";
- if(mysqli_query($con,$Sql_Query))
- {
- echo 'Registration Successfully';
- }
- else
- {
- echo 'Something went wrong';
- }
- }
- }
- mysqli_close($con);//closing connection
- ?>
Add Comment
Please, Sign In to add comment