Location: PHPKode > scripts > Register User > register-user/class_register.php
<?php

/**
 *  Klasa wywolujaca polaczenie bazy danych
 */
 
require_once ("class_connect_db.php");

class Register {
	
	
	/**
	 * metoda dodawania uzytkownika do bazy danych
	 */
	
	public function AddUser($login, $password, $first, $last, $address, $zip,
	$city, $age, $sex, $phone, $email) {
		
		//
		
		$sql =  "SELECT login FROM register where login ='$login'";
		$result = mysql_query($sql);
		
		/**
		 * warunek sprawdzajacy podany login
		 */
		
		if (mysql_numrows($result) > 0) { 
			
			echo ("User is already exist");
			
			}  
	
			else {
	
	//
	
		$sql = "INSERT INTO register (login, password, first, last, address, zip,
		city, age, sex, phone, email) VALUES
		('".$login."', '". sha1($password)."', '".$first."', '".$last."', '".$address."', 
		'".$zip."', '".$city."', '".$age."', '".$sex."', '".$phone."', '".$email."')";
		
		mysql_query($sql);
		
			}
	}

}

?>
Return current item: Register User