Skip to content

Instantly share code, notes, and snippets.

@msdundar msdundar/syc.php
Created May 21, 2011

Embed
What would you like to do?
The Mail Php File
<?php
class Ayarlar
{
protected $dbh;
function __construct()
{
$dsn = 'mysql:dbname=clientinfo;host=localhost';
$user = 'root';
$password = '';
$karakter = array( PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES UTF8' );
try {
$this->dbh = new PDO($dsn, $user, $password, $karakter);
} catch (PDOException $e) {
echo 'Yine mi gol degil hakim bey ! ' . $e->getMessage();
}
}
}
class Kayit extends Ayarlar
{
protected $Username;
protected $Password;
protected $Email;
function SetUsername($username)
{
return $this->Username = mysql_real_escape_string($username);
}
function GetUsername()
{
return $this->Username;
}
function SetPassword($password)
{
return $this->Password = sha1(mysql_real_escape_string($password));
}
function SetEmail($email)
{
return $this->Email = mysql_real_escape_string($email);
}
function GetEmail()
{
return $this->Email;
}
function Kontrol()
{
$errors = array();
if((strlen($this->Username)) != 8 || is_numeric($this->Username) == FALSE)
{
$errors[] = "Hatalı öğrenci numarası !";
die('Hatalı öğrenci numarası !');
}
if(false === filter_var($this->Email, FILTER_VALIDATE_EMAIL))
{
$errors[] = "Hatalı mail !";
die('Hatalı e-posta adresi !');
}
return $errors;
}
function InsertUserToSql()
{
$error = $this->Kontrol();
if(count($error) > 0 )
{
return $error;
}
else
{
$stmt = $this->dbh->prepare("INSERT INTO canlidestek (ogrencino, passwd, eposta) VALUES (:username,
:password, :email)");
$stmt->bindParam(':username', $this->Username);
$stmt->bindParam(':password', $this->Password);
$stmt->bindParam(':email', $this->Email);
$stmt->execute();
$arr = array();
$arr = $stmt->errorInfo();
return $arr;
}
}
}
class Giris extends Kayit
{
function CheckLogin()
{
$stmt = $this->dbh->prepare("SELECT ogrencino, passwd FROM ikibindokuz WHERE ogrencino=:username AND passwd=:password");
$stmt->bindParam(':username', $this->Username);
$stmt->bindParam(':password', $this->Password);
$stmt->execute();
if($stmt->rowCount() > 0 )
{
session_start(); // sonradan ekledim - test aşamasında
$_SESSION['ogrencino'] = $this->Username;
}
else
{
die("Bilgilerinizi Hatalı Girdiniz !");
}
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.