Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- include ('includes/config.php');
- $user_ip = $_SERVER['REMOTE_ADDR'];
- $username = isset($_POST['username']) ? trim($_POST['username']) : '';
- $password = isset($_POST['password']) ? trim($_POST['password']) : '';
- $password2 = isset($_POST['password2']) ? trim($_POST['password2']) : '';
- $errors = array();
- $success = false;
- // Process the POST data.
- if(isset($_POST) && !empty($_POST)){
- // Validate user name.
- if(empty($username)){
- $errors[] = 'Please provide a user name.';
- }else if(strlen($username) < 3 || strlen($username) > 16){
- $errors[] = 'User name must be between 3 and 16 characters in length.';
- }else if(ctype_alnum($username) === false){
- $errors[] = 'User name must consist of numbers and letters only.';
- }else{
- // Check if username already exists in the database.
- $sql = "SELECT szUserID FROM TGLOBAL_GSP.dbo.TACCOUNT WHERE szUserID = ?";
- $stmt = odbc_prepare($connection,$sql);
- $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.';
- }
- }
- // Validate user password.
- if(empty($password)){
- $errors[] = 'Please make password.';
- }else if(strlen($password) > 16){
- $errors[] = 'Password is too long.';
- }else if($password != $password2){
- $errors[] = 'Password must be same.';
- }
- if(empty($errors[0])){
- $password = md5($password); // šifrování hesla
- $result = odbc_exec($connection, "SELECT * FROM TGLOBAL_GSP.dbo.TACCOUNT"); // vyčtení záznamů
- $row = odbc_num_rows($result); // zjištění počtu řádek
- $ml = $row + 1;
- $sql = "INSERT INTO TGLOBAL_GSP.dbo.TACCOUNT (dwUserID, szUserID,szPasswd,bCheck) VALUES ($ml, '$username', '$password', 1)";
- odbc_exec($connection,$sql);
- echo "<script type='text/javascript'>alert('Account ". $username ." Succesfully Created')</script>";
- }else echo "<script type='text/javascript'>alert('". $errors[0] ."')</script>";
- if(!empty($errors[0])){$_SESSION['reg_error'] = $errors['0'];}
- echo'<meta http-equiv="refresh" content="5; URL=./index.php">';
- //header("Location: http://www.v4story.eu");
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement