Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- session_start();
- $dbHost = 'gznster';
- $dbUser = 'root';
- $dbPass = '123';
- $GLOBALS['dbConn'] = @odbc_connect("Driver={SQL Server};Server={$GLOBALS['dbHost']};",$GLOBALS['dbUser'],$GLOBALS['dbPass']) or die('Database Connection Error!');
- if(!$GLOBALS['dbConn']){
- exit("Connection failed:".odbc_errormsg());
- }
- // initializing variables
- $username = "";
- $email = "";
- $errors = array();
- $serverName = "gznster";
- $connectionInfo = array( "Database"=>"registration", "UID"=>"root", "PWD"=>"123");
- $conn = sqlsrv_connect( $serverName, $connectionInfo);
- // REGISTER USER
- // LOGIN USER
- if (isset($_POST['reg_user'])) {
- //$username = mysqli_real_escape_string($db, $_POST['username']);
- $username = isset($_POST['username']) ? trim($_POST['username']) : '';
- if (empty($username)) {
- array_push($errors, "Username is required");
- //$errors[] = 'Please provide a user name.';
- }
- if (count($errors) == 0) {
- $query = "SELECT * FROM registration.registation.databaseusers WHERE username=?";
- //$results = mysqli_query($db, $query);
- $stmt = odbc_prepare($GLOBALS['dbConn'],$query);
- $args = array($username);
- if(!odbc_execute($stmt,$args)){
- $errors[] = 'Failed to determine if this username already exists in the database.';
- }elseif($row = odbc_fetch_array($stmt)){
- $errors[] = 'User name already exists, please choose a different user name.';
- }
- //insert username into events
- $oko = "INSERT INTO users (username, email)
- VALUES('$username', '$email')";
- //mysqli_query($db, $oko);
- $stmt = odbc_prepare($GLOBALS['dbConn'],$oko);
- $_SESSION['username'] = $username;
- $monol = "UPDATE users INNER JOIN databaseusers USING (username) SET users.email = databaseusers.email";
- // mysqli_query($db, $monol);
- $stmt = odbc_prepare($GLOBALS['dbConn'],$monol);
- //ijij
- // if (mysqli_num_rows($results) == 1) {
- // $_SESSION['username'] = $username;
- // $_SESSION['success'] = "You are now logged in";
- // header('location: index.php');
- // }else {
- // array_push($errors, "Wrong username/password combination");
- // }
- $_SESSION['username'] = $username;
- $sql = "INSERT INTO PS_UserData.dbo.Users_Master
- (UserID,Pw,JoinDate,Admin,AdminLevel,UseQueue,Status,Leave,LeaveDate,UserType,Point,EnPassword,UserIp)
- VALUES (?,?,GETDATE(),0,0,0,0,0,GETDATE(),'N',0,'',?)";
- $stmt = odbc_prepare($GLOBALS['dbConn'],$sql);
- $args = array($username);
- if(odbc_execute($stmt,$args)){
- $_SESSION['success'] = "You are now logged in";
- header('location: index.php');
- }else {
- array_push($errors, "Wrong username/password combination");
- }
- }
- }
- // ...
- // ...
- // LOGIN USER
- if (isset($_POST['login_user'])) {
- $username = mysqli_real_escape_string($db, $_POST['username']);
- if (empty($username)) {
- array_push($errors, "Username is required");
- }
- if (count($errors) == 0) {
- $query = "SELECT * FROM users WHERE username='$username'";
- $results = mysqli_query($db, $query);
- //insert username into events
- $oko = "INSERT INTO event (username, email)
- VALUES('$username', '$email')";
- mysqli_query($db, $oko);
- $_SESSION['username'] = $username;
- //set similar rows in EVENT
- $monol = "UPDATE event INNER JOIN users USING (username) SET event.email = users.email";
- mysqli_query($db, $monol);
- //
- $monoll = "delete from ac";
- mysqli_query($db, $monoll);
- $monolll = "insert into ac select username,count(username) from event group by username";
- mysqli_query($db, $monolll);
- //ijij
- if (mysqli_num_rows($results) == 1) {
- $_SESSION['username'] = $username;
- $_SESSION['success'] = "You are now logged in";
- header('location: index.php');
- }else {
- array_push($errors, "Wrong username/password combination");
- }
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement