الفريق العربي للبرمجةأرشيف المنتديات · 2000 – 2023
نسخة أرشيفية للقراءة فقط — التسجيل والمشاركة مغلقان، والمحتوى محفوظ كما كان.

سكريبت تسجيل و تسجيل الدخول في مرحلته الأولى عن طريق برمجة الكائنات

مغلق
بدأه vivid في 24 ديسمبر 2007 · 5 رد · 694 مشاهدة · في منتدى تطوير المواقع بـ PHP
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

لقد قمت بعمل سكريبت تسجيل و تسجيل دخول في مرحلته الأولى عن طريق برمجة الكائنات. أخذ مني يومين لكن الحمد لله لقد اشتغل الاسكريبت على أكمل وجه. و الآن أنا بصدد أضافة لوحة تحكم الإدارة حتى أبدأ في إضافة المقالات. ليصبح سكريبت مقالات مصغر. الرجاء من لديهم علم أكثر مني ببرمجة الكائنات المساعدة في عملية النقد و التوجيه حتى أستفيد أكثر من تجربتهم.

تم إطلاق برمجتي ذات المصدر المفتوح بصورة رسمية

Rufaa v1.0 Alpha 1

البرمجة ستكون متاحة للتحميل حال إعتماد النسخة

#2
CREATE TABLE `users_membership_table` (
  `u_id` mediumint(5) unsigned NOT NULL auto_increment,
  `u_name` varchar(30) NOT NULL,
  `u_f_name` varchar(30) NOT NULL,
  `u_l_name` varchar(30) NOT NULL,
  `u_pwd` varchar(30) NOT NULL,
  `u_email` varchar(40) NOT NULL,
  `u_ip` varchar(16) NOT NULL,
  `u_reg_date` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
  PRIMARY KEY  (`u_name`),
  UNIQUE KEY `user_id` (`u_id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=4;

classes/BHL_DB.php
................................................................................
.................................................................

<?php

class BHL_DB {

	protected $DB_SERVER;
	protected $DB_USER;
	protected $DB_PASS;
	protected $DB_NAME;
	protected $connection;
	protected $db_select;

	function __construct(){
		$this->DB_SERVER = "localhost";
		$this->DB_USER = "root";
		$this->DB_PASSS = "";
		$this->DB_NAME = "bahala";
		$this->connection = mysql_connect($this->DB_SERVER, $this->DB_USER, $this->DB_PASS)or die('Can not connect to BHL, try again' . mysql_error());
		$this->db_select = mysql_select_db($this->DB_NAME, $this->connection) or die('<font color = blue>Can not connect to website <strong><font color = red>DATABASE </font></strong>may be your server is slow down. Feel free to access the website later!</font>');
	}
}
$transaction = new BHL_DB();



?>

classes/GetUserNameReg.php
................................................................................
........................................................
<?php

class GetUserNameReg extends RegistrationInfo
{
	public function __construct(){
	parent::__construct($USER_MEM_TBL, $U_IP);
	}
	public function getUSER_DB_TBL(){
		return $this->USER_MEM_TBL;
	}
	public function getU_IP(){
		return $this->U_IP;
	}
}
?>

classes/MakingMechanismForData.php
................................................................................
...................................................
<?php

class MakingMechanismForData extends RegUserInfo{
		public function __construct(){
		parent::__Construct($USER_MEM_TBL, $USER_MEM_TBL, $USERNAME, $FIRSTNAME, $LASTNAME, $PWD, $PWD2, $EMAIL, $U_IP, $Date);
		}
	public function MakeMechanism($USERNAME, $FIRSTNAME, $LASTNAME, $PWD, $PWD2, $EMAIL){
		if(isset($_POST['submit'])){
			if($this->USERNAME == "" || strlen($this->USERNAME) <= 3){
				die('Hey, Your <font color = red><strong>username</strong></font> should not be empty and it should 3 characters!');

				}				
			if($this->FIRSTNAME == ""){
				die('Hey, Your <font color = red><strong>firstname</strong></font> should not be empty!');
				}
			if($this->LASTNAME == ""){
				die('Hey, Your <font color = red><strong>lastname</strong></font> should not be empty!');
				}
			if($this->PWD != $this->PWD2 || strlen($this->PWD) <= 5){
				die('Hey, Either your <font color = red><strong>password</strong></font> empty or did not match!');
				}
			if($this->EMAIL == "" || !eregi("^([[:alnum:]]|_|\.|-)+@([[:alnum:]]|\.|-)+(\.)([a-z]{2,4})$", $_POST['email'])){	
				die('Hey, Your <font color = red><strong>email</strong></font> should not be empty!');
				}
					return "{$this->USERNAME}".
							"{$this->FIRSTNAME}".
							"{$this->LASTNAME}".
							"{$this->PWD}".
							"{$this->EMAIL}";
						}	

						}
}
?>

classes/RegDataInsertion.php
................................................................................
.................................................................
<?php

class RegDataInsertion extends MakingMechanismForData{
	public function __construct(){
		parent::__construct($USER_MEM_TBL, $USER_MEM_TBL, $USERNAME, $FIRSTNAME, $LASTNAME, $PWD, $PWD2, $EMAIL, $U_IP, $Date);
	}
	public function DBInsertion($USER_MEM_TBL, $USERNAME, $FIRSTNAME, $LASTNAME, $PWD, $PWD2, $EMAIL, $U_IP, $Date){
 $query = "INSERT INTO `$this->USER_MEM_TBL` (`u_name`, `u_f_name`,`u_l_name`, `u_pwd`, `u_email`, `u_ip`, `u_reg_date`) VALUES ('".mysql_real_escape_string($this->USERNAME)."', '".mysql_real_escape_string($this->FIRSTNAME)."','".mysql_real_escape_string($this->LASTNAME)."', '".mysql_real_escape_string(md5($this->PWD))."', '".mysql_real_escape_string($this->EMAIL)."','".$this->U_IP."','".$this->Date."')";
$result = mysql_query($query);

}
}
?>

classes/RegistrationInfo.php
................................................................................
...................................................
<?php

abstract class RegistrationInfo
{
	protected $USER_MEM_TBL; //refer to database user table
	protected $U_IP; // refer to user ip

	abstract public function getUSER_DB_TBL();
	abstract public function getU_IP();

	public function __construct($USER_MEM_TBL, $U_IP)
	{
		$this->USER_MEM_TBL 				= "users_membership_table";
		$this->U_IP 						= isset($_SERVER['HTTP_X_FORWARDED_FOR']) ? $_SERVER['HTTP_X_FORWARDED_FOR'] : $_SERVER['REMOTE_ADDR'];
		}
}
?>

classes/RegUserInfo.php
................................................................................
...........................................
<?php

class RegUserInfo extends RegistrationInfo
{
	public $USERNAME;
	public $FIRSTNAME;
	public $LASTNAME;
	public $PWD;
	public $PWD2;
	public $EMAIL;

	public function __construct($USERNAME, $FIRSTNAME, $LASTNAME, $PWD, $PWD2, $EMAIL, $USER_MEM_TBL, $U_IP){
		parent:: __construct($USER_MEM_TBL, $U_IP);
		$this->USERNAME = trim($_POST['username']);
		$this->FIRSTNAME = trim($_POST['fname']);
		$this->LASTNAME = trim($_POST['lname']);
		$this->PWD = trim($_POST['password']);
		$this->PWD2 = trim($_POST['password2']);
		$this->EMAIL = trim($_POST['email']);
		$this->USER_MEM_TBL 				= "users_membership_table";
		$this->U_IP 						= isset($_SERVER['HTTP_X_FORWARDED_FOR']) ? $_SERVER['HTTP_X_FORWARDED_FOR'] : $_SERVER['REMOTE_ADDR'];
		}

	public function getUserNameInfo(){
		return $this->USERNAME;
	}
	public function getUserFirstNameInfo(){
		return $this->FIRSTNAME;
		}
	public function getUserLastNameInfo(){
		return $this->LASTNAME;
	}	
	public function getUserPasswordInfo(){
		return $this->PWD;
	}
	public function getUserConfirmPasswordInfo(){
		return $this->PWD2;
		}
	public function getUserEmailAddInfo(){
		return $this->EMAIL;
		}
	public function getUSER_DB_TBL(){
		return $this->USER_MEM_TBL;
	}
	public function getREG_Date(){
		return $this->Date;
		}
		public function getU_IP(){	
			$this->U_IP = $U_IP;
	}
	}
?>

classes/UserChecking.php
................................................................................
.........................................
<?php

class UserChecking extends MakingMechanismForData{
		public function __construct(){
		parent::__construct();
		}
	public function RegChecking($USERNAME){
			$check = mysql_query("SELECT u_name FROM `$this->USER_MEM_TBL` WHERE u_name = '$this->USERNAME'") or die(mysql_error());
			$check2 = mysql_num_rows($check);
			if ($check2 != 0)
				die("<font color = blue>Sorry, the <strong><font color = red>'.$this->USERNAME.'</font></strong> is already in use.!</font></br> <strong><font color = red><a href=\"UserRegistrationAccess.php\">click here to try again</font></strong></a>");
				}
				}
?>

classes/UsersLogin.php
................................................................................
.....................................
<?php

session_start();

class UsersLogin extends RegUserInfo{

	public function __construct(){
		parent::__construct($USERNAME, $FIRSTNAME, $LASTNAME, $PWD, $PWD2, $EMAIL, $USER_MEM_TBL, $U_IP);
}
	public function UserAccess($USERNAME, $FIRSTNAME, $LASTNAME, $PWD, $PWD2, $EMAIL, $USER_MEM_TBL, $U_IP){	
		if(!isset($this->USERNAME) || !$this->PWD){
			die('Hey, You have to fill your login information!');
			}
			return $this->USERNAME;
			return $this->PWD;
			}
	public function UserAccessIns($USERNAME, $FIRSTNAME, $LASTNAME, $PWD, $PWD2, $EMAIL, $USER_MEM_TBL, $U_IP){
		$query = "SELECT * FROM `".$this->USER_MEM_TBL."` WHERE u_name = '".$this->USERNAME."'"or die('Can not connect to BHL, try again' . mysql_error());
	$result = mysql_query($query)or die('Can not connect to BHL, try again' . mysql_error());

		if(mysql_num_rows($result) == 0){
			die('no');
		}
		$row = mysql_fetch_array($result);
		if(!$row == 1){
			die('noooooo');
			}
		$_SESSION['u_name'] = $row['u_name'];
		$_SESSION['u_f_name'] = $row['u_f_name'];
		header("Location: loggedin.php");
		exit();
}
}
?>

UserRegistration.php
................................................................................
.........................................
<?php
function __autoload($class_name){
	require_once("classes/$class_name.php");
}
$transaction = new BHL_DB();
$person = new GetUserNameReg();
$person->getUSER_DB_TBL();
$person->getU_IP();
$const = new RegUserInfo($USERNAME, $FIRSTNAME, $LASTNAME, $PWD, $PWD2, $EMAIL, $USER_MEM_TBL, $U_IP);
$Insertdata = new MakingMechanismForData();
$Insertdata->MakeMechanism($USERNAME, $FIRSTNAME, $LASTNAME, $PWD, $PWD2, $EMAIL);
$person3 = new UserChecking();
$person3->RegChecking($USERNAME);
$person4 = new RegDataInsertion();
$person4->DBInsertion($USER_MEM_TBL, $USERNAME, $FIRSTNAME, $LASTNAME, $PWD, $PWD2, $EMAIL, $U_IP, $Date)
?>


UserRegistrationAccess.php
................................................................................
.......................................
<?php

require_once('UserRegistration.php');
require_once ('regform.html');


?>

logging.php
................................................................................
.............................................
<?php


require_once('login.htm');
		function __autoload($class_name){
	require_once("classes/$class_name.php");
	}
$transaction1 = new BHL_DB();
$person5 = new UsersLogin($USERNAME, $FIRSTNAME, $LASTNAME, $PWD, $PWD2, $EMAIL, $USER_MEM_TBL, $U_IP);
$person5->UserAccess($USERNAME, $FIRSTNAME, $LASTNAME, $PWD, $PWD2, $EMAIL, $USER_MEM_TBL, $U_IP);
$person5->UserAccessIns($USERNAME, $FIRSTNAME, $LASTNAME, $PWD, $PWD2, $EMAIL, $USER_MEM_TBL, $U_IP);
$co = new RegUserInfo($USERNAME, $FIRSTNAME, $LASTNAME, $PWD, $PWD2, $EMAIL, $USER_MEM_TBL, $U_IP);
$co->getUSER_DB_TBL();


?>

loggedin.php
................................................................................
.........................................
<?php
function __autoload($class_name){
	require_once("classes/$class_name.php");

	}
$const = new RegUserInfo($USERNAME, $FIRSTNAME, $LASTNAME, $PWD, $PWD2, $EMAIL, $USER_MEM_TBL, $U_IP);
print "You are login";
$transaction = new BHL_DB();
$query = "SELECT * FROM `".$this->USER_MEM_TBL."` WHERE u_name = '".$this->USERNAME."'"or die('Can not connect to BHL, try again' . mysql_error());
	$result = mysql_query($query)or die('Can not connect to BHL, try again' . mysql_error());

		if(mysql_num_rows($result) == 0){
			die('no');
		}
		$row = mysql_fetch_array($result);
		if(!$row == 1){
			die('noooooo');
			}
		echo $this->USERNAME = $row['u_name'];
		echo $this->FIRSTNAME = $row['u_f_name'];
?>

regform.html
................................................................................
.............................................

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled 1</title>
<style type="text/css">
.style1 {
	border: 2px solid #2E2E23;
	background-color: #9FA8CE;
	font-size: 12px;
	font-style: italic;
	font-family: Verdana, Arial, Helvetica, sans-serif;
	color: #000000;
}
</style>
</head>

<body style="background-color: #455189">
<h2><div align="center"><strong>REGISTER</strong></h2>
<form action="<?php echo $_SERVER['PHP_SELF'];?>" method="post">
<table style="width: 500px; height: 200px" align="center" class="style1">
<tr>
<td>USER NAME: </td>
<td><input type="text" name="username" size="20" maxlength="40"
value="<?php if (isset($_POST['username'])) echo $_POST['username'];
?>" /></td><td><p class="style1">At least 4 characters</p></td>
</tr>
<tr>
<td>FIRST NAME: </td>
<td><input type="text" name="fname" size="20" maxlength="40"
value="<?php if (isset($_POST['fname'])) echo $_POST['fname'];
?>" /></td><td><p class="style1">At least 4 characters</p></td>
</tr>
<tr>
<td>LAST NAME: </td>
<td><input type="text" name="lname" size="20" maxlength="40"
value="<?php if (isset($_POST['lname'])) echo $_POST['lname'];
?>" /></td><td><p class="style1">At least 4 characters</p></td>
</tr>
<tr>
<td>PASSWORD: </td>
<td><input type="password" name="password" size="22" maxlength="40"
/></td><td><p class="style1">At least 4 characters</p></td>
</tr>
<tr>
<td>VERIFY PASSWORD: </td>
<td><input type="password" name="password2" size="22" maxlength="40"
/></td>
</tr>
<tr>
<td>EMAIL ADDRESS: </td>
<td><input type="text" name="email" size="20" maxlength="40"
value="<?php if (isset($_POST['email'])) echo $_POST['email']; ?>" /></td>
</tr>
<tr>
<td> </td>
<td><input type="submit" name="submit" value="REGISTER" /></td>
</tr>
</table>
<p>
<input type="hidden" name="submitted" value="TRUE" />
</p>
</form>
</body>
</html>

login.htm
................................................................................
................................................

<h2>REGISTER</h2>
<form action="<?php echo $_SERVER['PHP_SELF'];?>" method="post">
<table width="60%" border="1" cellspacing="2" cellpadding="2">
<tr>
<td>USER NAME: </td>
<td><input type="text" name="username" size="15" maxlength="30"
value="<?php if (isset($_POST['username'])) echo $_POST['username'];
?>" /></td>
</tr>
<tr>
<td>PASSWORD: </td>
<td><input type="password" name="password" size="15" maxlength="20"
/></td>
</tr>
<tr>
<td> </td>
<td><input type="submit" name="submit" value="Login" /></td>
</tr>
</table>
<p>
<input type="hidden" name="submitted" value="TRUE" />
</p>
</form>

تم تعديل هذه المشاركة بواسطة vivid في 24 ديسمبر 2007 في 11:15

تم إطلاق برمجتي ذات المصدر المفتوح بصورة رسمية

Rufaa v1.0 Alpha 1

البرمجة ستكون متاحة للتحميل حال إعتماد النسخة

#3

نسيت التعليقات حتى نطور معك

''‏اللهم إني أسالك إيمانا دائما وأسألك قلبا خاشعا وأسألك علما ‏نافعا وأسألك يقينا صادقا وأسألك دينا قيما وأسألك العافية من كل ‏بلية''

'‏اللهم أغفر للمؤمنين و المؤمنات و المسلمين و المسلمات الأحياء ‏منهم و الأموات'

www.it-scoop.com

#4
SIFE-C كتب:
نسيت التعليقات حتى نطور معك

منتظر تعليقاتكم

الآن قطعت شوط كبير في إضافة و تعديل بعض الـ bugs

تم إطلاق برمجتي ذات المصدر المفتوح بصورة رسمية

Rufaa v1.0 Alpha 1

البرمجة ستكون متاحة للتحميل حال إعتماد النسخة

#5

لم تضمن التعليقات داخل السورس حتى نفهم أجزائه

''‏اللهم إني أسالك إيمانا دائما وأسألك قلبا خاشعا وأسألك علما ‏نافعا وأسألك يقينا صادقا وأسألك دينا قيما وأسألك العافية من كل ‏بلية''

'‏اللهم أغفر للمؤمنين و المؤمنات و المسلمين و المسلمات الأحياء ‏منهم و الأموات'

www.it-scoop.com

#6

أوكي الآن انا فهمتك انت قاصد بي التعليق ايه

مع انه الاسكريبت واضح جدا

و لو ركزت شوية حا تفهمه

لكن أوعدك خلال يومين حا أنزل التعليقات في التعديل الجديد

لأني عملت تعديلات و اضافات كثيرة

دي النسخة في شكل ملفات

حملها من المرفقات

BHL.rar

تم تعديل هذه المشاركة بواسطة vivid في 26 ديسمبر 2007 في 20:01

تم إطلاق برمجتي ذات المصدر المفتوح بصورة رسمية

Rufaa v1.0 Alpha 1

البرمجة ستكون متاحة للتحميل حال إعتماد النسخة

هذا الموضوع مغلق.

مواضيع مشابهة

عدد الزوار حالياً

المتواجدون خلال آخر دقيقتين · يتحدّث كل ٣٠ ثانية

—الإجمالي—أعضاء مسجّلون—زوار بدون تسجيل

جارٍ التحقق من المتواجدين…