tecnoteacher
Aktif Üye
- Mesajlar
- 154
arkadaşlar bir siteye üyelik sistemi kurmak istiyorum.Yönetici şifre verecek Bu şifre ile sisteme giriş yapılacak.PHP de bu konu ile ilgili hazır kod var mı acaba?Nasıl yapabilirim..
@mysql_connect ("$host", "$mysqladi", "$mysqlsifre") or die ("MySql Baglantisinda Hata");
@mysql_select_db ("$dbase") or die ("Üye Veritabanina Baglanilamadi");
@mysql_query("insert into userstable (`kadi`, `parola`) values ('".$HTTP_POST_VARS[ad]."', '".md5($HTTP_POST_VARS[pr])."')");
$sorgu = mysql_query("SELECT * FROM userstable WHERE kadi='$user' AND parola='".md5($pass)."'");
if (mysql_num_rows($sorgu)==0)
{
echo "<script>alert('Hatalı Kullanıcı Adı yada Parola Tekrar Deneyiniz...');location.href='giris.php'; </script>";
}Else
{
session_start();
session_register("isim");
$isim=@mysql_result($sorgu,0,"isim"); //Oturum aç ve kaydet
header ("location:sayfa.php");
}
session_start();
if (!session_is_registered("isim"))
{
header("Location:giris.php");
die("İzniniz Yok...");
}
<?php
$hostname_baglan = "localhost";
$database_baglan = "veritabani_adi";
$username_baglan = "root";
$password_baglan = "";
$baglan = mysql_pconnect($hostname_baglan, $username_baglan, $password_baglan) or trigger_error(mysql_error(),E_USER_ERROR);
?>
<?php require_once('baglan.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
?><?php
// *** Validate request to login to this site.
if (!isset($_SESSION)) {
session_start();
}
$loginFormAction = $_SERVER['PHP_SELF'];
if (isset($_GET['accesscheck'])) {
$_SESSION['PrevUrl'] = $_GET['accesscheck'];
}
if (isset($_POST['kullanici_adi'])) {
$loginUsername=$_POST['kullanici_adi'];
$password=$_POST['sifre'];
$MM_fldUserAuthorization = "";
$MM_redirectLoginSuccess = "../index.php";
$MM_redirectLoginFailed = "login.php";
$MM_redirecttoReferrer = false;
mysql_select_db($database_baglan, $baglan);
$LoginRS__query=sprintf("SELECT kullanici_adi, sifre FROM uyeler WHERE kullanici_adi=%s AND sifre=%s",
GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text"));
$LoginRS = mysql_query($LoginRS__query, $baglan) or die(mysql_error());
$loginFoundUser = mysql_num_rows($LoginRS);
if ($loginFoundUser) {
$loginStrGroup = "";
//declare two session variables and assign them
$_SESSION['MM_Username'] = $loginUsername;
$_SESSION['MM_UserGroup'] = $loginStrGroup;
if (isset($_SESSION['PrevUrl']) && false) {
$MM_redirectLoginSuccess = $_SESSION['PrevUrl'];
}
header("Location: " . $MM_redirectLoginSuccess );
}
else {
header("Location: ". $MM_redirectLoginFailed );
}
}
?><!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=iso-8859-9" />
<title>Login Sayfası</title>
</head>
<body>
<form id="form1" name="form1" method="POST" action="<?php echo $loginFormAction; ?>">
<table width="40%" align="center" bordercolor="#CCFFFF">
<tr>
<td colspan="2" bgcolor="#3399FF"><p align="center">BENİM SAYFAMA HOŞ GELDİNİZ<br />
Lütfen Kullanıcı Adı ve Şifrenizle Giriş Yapınız</p>
</td>
</tr>
<tr>
<td bgcolor="#CCFFFF"><div align="right">Kullanıcı Adı :</div></td>
<td bgcolor="#CCFFFF">
<div align="left">
<input name="kullanici_adi" type="text" id="kullanici_adi" size="20" />
</div>
</td>
</tr>
<tr>
<td bgcolor="#CCFFFF"><div align="right">Şifre :</div></td>
<td bgcolor="#CCFFFF"><div align="left">
<input name="sifre" type="password" id="sifre" size="20" />
</div></td>
</tr>
<tr>
<td bgcolor="#CCFFFF"> </td>
<td bgcolor="#CCFFFF"><label>
<input type="submit" name="button" id="button" value="Giriş Yap" />
</label></td>
</tr>
</table>
<div align="center"></div>
</form>
</body>
</html>
CREATE TABLE IF NOT EXISTS `uyeler` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`kullanici_adi` varchar(50) NOT NULL DEFAULT '',
`sifre` varchar(200) NOT NULL DEFAULT '',
PRIMARY KEY (`id`),
UNIQUE KEY `kullaniciadi` (`kullanici_adi`)
) ENGINE=MyISAM DEFAULT CHARSET=latin5 AUTO_INCREMENT=4 ;