Back to top
<?php $host="localhost"; // Host name $username="*****"; // Mysql username $password="****"; // Mysql password $db_name="******"; // Database name $tbl_name="jos_users"; // Table name ( Jomsocial mi da questa tabella) // Connect to server and select the 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 in main_login $username=$_POST['username']; $password=$_POST['password']; // protect MySQL injection $username = stripslashes($username); $password = stripslashes($password); $username = mysql_real_escape_string($username); $password = mysql_real_escape_string($password); // encrypt password $parts = explode( ':', $password ); $salt = $parts[1]; $encrypted_password=md5($password.$salt); //echo $encrypted_password; // To protect MySQL injection (more detail about MySQL injection) $username = stripslashes($username); $password = stripslashes($password); $username = mysql_real_escape_string($username); $password = mysql_real_escape_string($password); $sql="SELECT * FROM $tbl_name WHERE login='$username' and password='$password'"; $result = mysql_query($sql) or die(mysql_error()); // Mysql_num_row counting table row now if ($result) $count = mysql_num_rows($result); else $count = 0; { // Register $myusername, $mypassword and redirect to file "login_success.php" session_register("username"); session_register("password"); header("location:login_success.php"); } else { echo "Wrong Username or Password"; } ?>
Copyleft: Tutto il materiale pubblicato o comunque presente all'interno del sito www.joomla.it può essere utilizzato, diffuso e modificato liberamente. Hosting fornito gratuitamente da Joomlahost.it Disegno web da kreatif multimedia srl