exit(); /*session_start(); if(!isset($_SESSION['user'])) session_register("user");*/ include('functions.php'); include('login.php'); if(isset($_POST['register'])) { RegisterUser(); } function RegisterUser() { if(isset($_POST['username']) and isset($_POST['password']) and isset($_POST['email'])) { if(($_POST['username']!="") && ($_POST['password']!="") && ($_POST['email']!="")) //do not allow empty variables. { $username = $_POST['username']; $password = $_POST['password']; $email = $_POST['email']; $dbUser="bestofgo_bogv"; $dbPassword="gvid911"; $database="bestofgo_bestofgo"; mysql_connect("localhost", $dbUser, $dbPassword); mysql_select_db($database) or die( "Unable to select database"); $query = sprintf("SELECT * FROM users WHERE username='%s'", mysql_real_escape_string($username)); $result = mysql_query($query); if(mysql_numrows($result) > 0) //username exists { echo "Username exists."; return false; } else { $query = sprintf("INSERT INTO users (username, password, email, score, rights) VALUES ('%s', '%s', '%s', 0, 0)", mysql_real_escape_string($username), mysql_real_escape_string($password), mysql_real_escape_string($email)); $result = mysql_query($query); $query = sprintf("SELECT * FROM users WHERE username='%s'", mysql_real_escape_string($username)); $result = mysql_query($query); $_SESSION['user']['userid'] = mysql_result($result, 0,"userid"); $_SESSION['user']['rights'] = mysql_result($result, 0,"rights"); $_SESSION['user']['username'] = mysql_result($result, 0,"username"); $_SESSION['user']['score'] = mysql_result($result, 0,"score"); UploadAvatar(); //Upload and save avatar, if any.. return true; } } } } function UploadAvatar() { if (isset($_SESSION['user']['userid'])) { $avatarFile = $_FILES['avatar']['tmp_name']; $fileInfo = pathinfo($avatarFile); if (is_uploaded_file($avatarFile) and ($_FILES['avatar']['type'] == 'image/jpeg')) { // Set a maximum height and width $width = 80; $height = 80; // Get new dimensions list($width_orig, $height_orig) = getimagesize($avatarFile); if ($width && ($width_orig < $height_orig)) { $width = ($height / $height_orig) * $width_orig; } else { $height = ($width / $width_orig) * $height_orig; } // Resample $image_p = imagecreatetruecolor($width, $height); $image = imagecreatefromjpeg($avatarFile); imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width, $height, $width_orig, $height_orig); // Output $path = "avatars/" . $_SESSION['user']['userid'] . ".jpg"; if (!imagejpeg($image_p, $path, 100)) //Overwrites file if exists { echo "Error Uploading File."; exit(); } } } } ?>
Your e-mail will only be used to send you the password when you forget it, and will never be shown to other users.
} ?> if(!$_SESSION['user']['userid']) { ?> } else { echo 'You are now registered. Go back'; } ?>