Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- include ('dbconnect.php');
- session_start();
- date_default_timezone_set('UTC');
- $error='';
- if (isset($_POST['register'])) {
- if (empty($_POST['user']) || empty($_POST['email']) || empty($_POST['pass']) || empty($_POST['conpass'])) {
- $error = "Please fill in all information.";
- } else {
- $user_name=$_POST['user'];
- $email=$_POST['email'];
- $pass=$_POST['pass'];
- $tsql = "SELECT * FROM Accounts WHERE UserID='$user_name' AND email='$email'";
- $tQuery = sqlsrv_query($tsql);
- $tResult = sqlsrv_fetch_array($tQuery);
- if($_POST['pass'] != $_POST['conpass']){
- $error = 'Password not match';
- }
- if($tResult) {
- $error = "Username or Email has been used";
- } else {
- $hash = md5( rand(0,1000) );
- $str1 = "INSERT INTO Accounts WHERE (email, UserID, MD5Password, dateregistered, lastlogindate, lastloginIP, ReferralID, hash) VALUES ('" . $email . "','" . $user_name . "','" . $pass . "','" . date("Y-m-d H:i:s", time()) . "','" . date("Y-m-d H:i:s", time()) . "','127.0.0.1','0','" . $hash . "')";
- $lastindex = sqlsrv_execute("SELECT IDENT_CURRENT('Accounts') + 1 as lastindex");
- $LastID = sqlsrv_fetch_array($lastindex);
- $str2 = "INSERT INTO UsersData WHERE (CustomerID, AccountType, dateregistered) VALUES ( '" . $LastID['lastindex'] . "', '2', '" . date("Y-m-d H:i:s", time()) . "')";
- if (sqlsrv_execute($conn, $str1) && sqlsrv_execute($conn, $str2)) {
- $_SESSION['register_user'] = $user_name;
- $error = 'Your account has been made, <br/> please verify it by clicking the activation link that has been send to your email.';
- $to = $email;
- $subject = 'Signup | Verification';
- $message = '
- Thanks for signing up!
- Your account has been created, you can login with the following credentials after you have activated your account by pressing the url below.
- Username: '.$name.'
- ------------------------
- Please click this link to activate your account:
- http://127.0.0.1/Undead/verify.php?email='.$email.'&hash='.$hash.'
- ';
- $headers = 'From:noreply@playundead.com' . "\r\n";
- mail($to, $subject, $message, $headers);
- } else {
- $error = 'System error';
- }
- }
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement