| Login Система |
| Автор |
FeShaN (21.02.2005 14:26) |
 |
съобщение до автора |
|
| Погледнат |
3969 пъти |
 |
добави към любими |
|
| Оценка |
 |
 |
добави коментар |
|
| Гласове |
14 |
 |
изпрати на приятел |
|
| Коментари |
(7) |
 |
абонирай се за PHP |
|
|
|
|
|
|
|
| |
|
index.php
CODE1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
| <html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1251">
<title>Влезте в системата !</title>
</head>
<body>
<form action="checkuser.php" method="post" name="form1">
<table width="50%" border="0" align="center" cellpadding="4" cellspacing="0">
<tr>
<td width="22%">Потребителско име:</td>
<td width="78%"><input name="username" type="text" id="username"></td>
</tr>
<tr>
<td>Парола:</td>
<td><input name="password" type="password" id="password"></td>
</tr>
<tr>
<td> </td>
<td><input type="submit" name="Submit" value="Влез"></td>
</tr>
</table>
<div align="center"><br>
<a href="join_form.php">Регистрация</a></div>
</form>
</body>
</html> |
checkuser.php
CODE1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
| <meta http-equiv="Content-Type" content="text/html; charset=windows-1251">
<?
/* Check User Script */
session_start(); // Start Session
include 'config.php';
// Convert to simple variables
$username = $_POST['username'];
$password = $_POST['password'];
if((!$username) || (!$password)){
echo "???? ???????? ???????! <br />";
include 'index.php';
exit();
}
// check if the user info validates the db
$sql = mysql_query("SELECT * FROM users WHERE username='$username' AND password='$password'");
$login_check = mysql_num_rows($sql);
if($login_check > 0){
while($row = mysql_fetch_array($sql)){
foreach( $row AS $key => $val ){
$$key = stripslashes( $val );
}
// Register some session variables!
session_register('first_name');
$_SESSION['first_name'] = $first_name;
session_register('username');
$_SESSION['username'] = $username;
session_register('last_name');
$_SESSION['last_name'] = $last_name;
session_register('email_address');
$_SESSION['email_address'] = $email_address;
header("Location: sample.php");
}
} else {
echo "??? ?????? ! ???? ???????? ?????? ??? ?? ????????????? !<br />";
include 'index.php';
}
?> |
config.php
CODE1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
| <meta http-equiv="Content-Type" content="text/html; charset=windows-1251">
<?php
$sql_cfg = array("host" => "localhost","db_name" => "DataBaseName","password" => "Parola na mysqlUsera","username" => "MysqlUsera");
$startmoney=20;
$sitepath = ""; //Full site path with http...
$sitename = "Login Systeam"; //The name of the game :)
$adminemail = "feshan@gmail.com"; //Admin`s e-mail
$connection = mysql_pconnect($sql_cfg['host'],$sql_cfg['username'],$sql_cfg['password'])
or die ("?????? ? ????????? -=> $adminemail");
$db = mysql_select_db($sql_cfg['db_name'], $connection)
or die("?????? ? ????????? -=> $adminemail");
?> |
join_form.php
CODE1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
| <meta http-equiv="Content-Type" content="text/html; charset=windows-1251">
<?php
print "
<html>
<head>
<title>????? ?????</title>
</head>
<body>
<form name=form1 method=post action=register.php>
<table width=100% border=0 cellpadding=4 cellspacing=0>
<tr>
<td width=24% align=left valign=top>???</td>
<td width=76%><input name=first_name type=text id=first_name2></td>
</tr>
<tr>
<td align=left valign=top>???????</td>
<td><input name=last_name type=text id=last_name></td>
</tr>
<tr>
<td align=left valign=top>?????????? ????</td>
<td><input name=email_address type=text id=email_address></td>
</tr>
<tr>
<td align=left valign=top>????????????? ???</td>
<td><input name=username type=text id=username></td>
</tr>
<tr>
<td align=left valign=top>??????</td>
<td><input name=password type=text id=password></td>
</tr>
<tr>
<td align=left valign=top> </td>
<td><input type=submit name=Submit value=??????????? ??!></td>
</tr>
</table>
</form>
</body>
</html>
"; ?> |
register.php
CODE1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
| <meta http-equiv="Content-Type" content="text/html; charset=windows-1251">
<?
include 'config.php';
// Define post fields into simple variables
$first_name = $_POST['first_name'];
$last_name = $_POST['last_name'];
$email_address = $_POST['email_address'];
$username = $_POST['username'];
$password = $_POST['password'];
/* Lets strip some slashes in case the user entered
any escaped characters. */
$first_name = stripslashes($first_name);
$last_name = stripslashes($last_name);
$email_address = stripslashes($email_address);
$username = stripslashes($username);
$password = stripslashes($password);
/* Do some error checking on the form posted fields */
if((!$first_name) || (!$last_name) || (!$email_address) || (!$username)){
echo '?? ??? ?????? ??????? ?????????? ! <br />';
if(!$first_name){
echo "?? ??? ?????? ???.???? ????????? ?? !<br />";
}
if(!$last_name){
echo "?? ??? ?????? ???????.???? ????????? ?? !<br />";
}
if(!$email_address){
echo "?? ??? ?????? ??????????? ?? ?????.<br />";
}
if(!$username){
echo "?? ??? ?????? ????????????? ???.???? ????????? ?? !<br />";
}
include 'join_form.php'; // Show the form again!
/* End the error checking and if everything is ok, we'll move on to
creating the user account */
exit(); // if the error checking has failed, we'll exit the script!
}
/* Let's do some checking and ensure that the user's email address or username
does not exist in the database */
$sql_username_check = mysql_query("SELECT username FROM users WHERE username='$username'");
$username_check = mysql_num_rows($sql_username_check);
if(($username_check > 0)){
echo "Please fix the following errors: <br />";
if($username_check > 0){
echo "???? ????????????? ??? ? ?????!???? ???????? ????? !<br />";
unset($username);
}
include 'index.php'; // Show the form again!
exit(); // exit the script so that we do not create this account!
}
$sql = mysql_query("INSERT INTO users (first_name, last_name, email_address, username, password) VALUES('$first_name', '$last_name', '$email_address', '$username', '$password')") or die (mysql_error());
if(!$sql){
echo '???????? ?????? ??? ??????????????.???? ???????? ?? ???????????????? !';
} else {
$userid = mysql_insert_id();
// Let's mail the user!
$subject = "??????????? ? $sitename";
$message = "????????? $first_name $last_name,
??? ?? ????????????? ???????, $sitepath !
???????? ???? ????????? ?????? ??????? ???? ?? ?? ?????????:
????????????? ???: $username
??????: $password
????????? ??!
Wabmaster, $sitename
???? ? ??????????? ????????? ???? ?? ???????????!
?? ??????? ?? ???????? ? ????????????????";
mail($email_address, $subject, $message, "From: $sitename <$adminemail>" . phpversion());
echo '???????????? ???? ????????? ??????? ?? ?????? ????!';
}
?> |
sample.php
CODE1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
| <meta http-equiv="Content-Type" content="text/html; charset=windows-1251">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1251">
<?
session_start();
if ( empty( $first_name ) ) {
?> ????? ????? ????, ??????? ?? ??????? ? ????????? <a href="index.php">???</a>, ??? ?? ???????????? : <a href="join_form.php">???<br>
<?
} else {
include 'config.php';
$query = "select first_name from users where username='$username'";
$result = mysql_query($query);
while ($red = mysql_fetch_array($result)) { echo "????? ?????: $red[first_name]<br>"; } // ????? ???????? ?????? ??????? ?????????
?>
<br>
<a href="logout.php">?????</a>
<? } ?> |
logout.php
CODE1
2
3
4
5
6
7
8
9
10
11
12
13
| <meta http-equiv="Content-Type" content="text/html; charset=windows-1251">
<?
session_start();
if(!isset($_REQUEST['logmeout'])){
session_unset();
session_destroy();
if(!session_is_registered('first_name')){
echo "<center><font color=red><strong>????????? ?? ?????????!</strong></font></center><br />";
}
}
?> |
sql данни
CODE1
2
3
4
5
6
7
| CREATE TABLE users (
first_name varchar(25) NOT NULL default '',
last_name varchar(25) NOT NULL default '',
email_address varchar(25) NOT NULL default '',
username varchar(12) NOT NULL default '',
password varchar(25) NOT NULL default '',
); |
Ивинявайте че не съм превел коментарите на БГ но го писах за един чужд сайт и ме мързеше много бо ще ги оправя !
| За автора: FeShaN |
|
Ми готин съм :) |
| |
|
| 1 посетител чете този скрипт (0 потребители и 1 гост) |
|
|
Активни потребители:
---
|
| |
|
|
|
|