User
Pass
2FA
 
 

Login Script

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Freakz Forum Index -> Trash Bin -> Trash -> Programming / Scripting / Database
Author Message1180
LolzyTM

[Mentally Stable]



Status: Offline
(since 08-11-2012 15:22)
Joined: 24 Feb 2011
Posts: 31, Topics: 19
Location: Romania

Reputation: 86.2
Votes: 2

Post Posted: 22-01-2012, 14:19:55 | Translate post to: ... (Click for more languages)

Salut am urmator script de login:

Login.php
Code:

<form name="form1" style="width:100;" method="post" action="login2.php">
Username: &nbsp;<input name="myusername" type="text" id="myusername" />
<br />

Password:
<input name="mypassword" type="text" id="mypassword">
<br />
<input type="submit" name="Submit" value="Login">
</form>


Login2.php
Code:

<?php
$host="********"; // Host name
$username="*****"; // Mysql username
$password="******"; // Mysql password
$db_name="******"; // Database name
$tbl_name="members"; // Table name

// Connect to server and select databse.
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");

// username and password sent from form
$myusername=$_POST['myusername'];
$mypassword=$_POST['mypassword'];

// To protect MySQL injection (more detail about MySQL injection)
$myusername = stripslashes($myusername);
$mypassword = stripslashes($mypassword);
$myusername = mysql_real_escape_string($myusername);
$mypassword = mysql_real_escape_string($mypassword);

$sql="SELECT * FROM $tbl_name WHERE username='$myusername' and password='$mypassword'";
$result=mysql_query($sql);

// Mysql_num_row is counting table row
$count=mysql_num_rows($result);
// If result matched $myusername and $mypassword, table row must be 1 row

if($count==1){
// Register $myusername, $mypassword and redirect to file "login_success.php"
session_register("myusername");
session_register("mypassword");
header("location:admin.php");
}
else {
echo "User sau Password gresit!";
}
?>

admin.php
Code:
<?
session_start();
if(!session_is_registered(myusername)){
header("location:login.php");
}
?>


Ok ce vreau eu cum fac ca in admin.php sa imi scrie " Esti logat cu user-ul: User" User sa fie numele user-ului cum pot sa fac ? Cine ma poate ajuta ii sunt recunoscator... Ms mult

0 0
  
Back to top
View user's profile Send private message
nr913
[Banned user]


Banned


Status: Offline
(since 24-10-2013 10:06)
Joined: 24 Apr 2009
Posts: 4224, Topics: 223
Location: România

Reputation: 60.3
Votes: 156

 
Post Posted: 22-01-2012, 15:20:05 | Translate post to: ... (Click for more languages)

admin.php
Code:
<?
session_start();
if(!session_is_registered(myusername)){
header("location:login.php");
}

echo "Esti logat cu user-ul: {$_SESSION['myusername']}<br/>";
?>


Attitude - A little thing that makes a BIG difference
0 0
  
Back to top
View user's profile Send private message
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Freakz Forum Index -> Trash Bin -> Trash -> Programming / Scripting / Database  


The time now is 03-12-2024, 07:12:59
Copyright info

Based on phpBB ro/com
B

 
 
 







I forgot my password


This message appears only once, so
like us now until it's too late ! :D
x