Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // Importing DBConfig.php file.
- include 'DBConfig.php';
- // Creating connection.
- $con = mysqli_connect($HostName,$HostUser,$HostPass,$DatabaseName);
- // Getting the received JSON into $json variable.
- $json = file_get_contents('php://input');
- // decoding the received JSON and store into $obj variable.
- $obj = json_decode($json,true);
- $ime=$obj['imee'];
- $prez=$obj['prezz'];
- $email = $obj['email'];
- $password = $obj['password'];
- $code = md5(uniqid(rand()));
- //Checking Email is already exist or not using SQL query.
- $CheckSQL = "SELECT * FROM user WHERE username='$email'";
- // Executing SQL Query.
- $check = mysqli_fetch_array(mysqli_query($con,$CheckSQL));
- if(isset($check)){
- $EmailExistMSG = 'Email Already Exist, Please Try Again !!!';
- // Converting the message into JSON format.
- $EmailExistJson = json_encode($EmailExistMSG);
- // Echo the message.
- echo $EmailExistJson ;
- }
- else{
- // Creating SQL query and insert the record into MySQL database table.
- $Sql_Query = "insert into user (name,lastname,username,password,token,userStatus) values ('$ime','$prez','$email','$password','$code','N')";
- if(mysqli_query($con,$Sql_Query)){
- // If the record inserted successfully then show the message.
- $MSG = 'User Registered Successfully' ;
- $message = "
- Pozdrav $name,
- <br /><br />
- Dobrodosli u Kvisko!<br/>
- Da biste dovšili registraciju potrebno je da kliknete na link ispod!<br/>
- <br /><br />
- <strong><a href='http://vucko.x3.rs/dev-sajt/kvisko/verify.php?code=$code'>Kliknite ovde za aktivaciju</a></strong>
- <br /><br />
- Hvala,";
- $subject = "Registracija korisnika";
- require_once('mailer/class.phpmailer.php');
- $mail = new PHPMailer();
- $mail->IsSMTP();
- $mail->SMTPDebug = 0;
- $mail->SMTPAuth = true;
- $mail->SMTPSecure = "tls";
- $mail->Host = "smtp.gmail.com";
- $mail->Port = 587;
- $mail->AddAddress($email);
- $mail->Username="miloszv94@gmail.com";
- $mail->Password="Vuckovic94";
- $mail->SetFrom('miloszv94@gmail.com','Kvisko');
- $mail->AddReplyTo("miloszv94@gmail.com","Kvisko");
- $mail->Subject = $subject;
- $mail->MsgHTML($message);
- $mail->Send();
- // Converting the message into JSON format.
- $json = json_encode($MSG);
- // Echo the message.
- echo $json ;
- }
- else{
- $MSG = 'NIej bas' ;
- $json = json_encode($MSG);
- echo $json ;
- //echo 'Try Again';
- }
- }
- mysqli_close($con);
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement