Hello ive got this code of the net just wanted some1 2check it 2make sure, also ive got these two peices of code the ones ive highlighted them in red, but dnt understand wa it means by saying put this code in first line of web page any ideas, ive got the basic loggin form which is linked from homepage. any 1 got any ideas?? thanks dave
// Put this code in first line of web page.
<?
session_start();
session_destroy();
?>
// Check if session is not registered , redirect back to student login.
// Put this code in first line of web page.
<?
session_start();
if(!session_is_registered(myusername)){
header("location:StudentLogin.php");
}
?>
<html>
<body>
Login Successful
</body>
</html>-----------------------------------------------------------------------------------------------
<?php
$host="host"; // Host name
$username="dk"; // Mysql username
$password="d"; // Mysql password
$db_name=""; // Database 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;
$mypassword=$_POST;
// encrypt password
$encrypted_mypassword=md5($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 members WHERE username='$myusername' and password='$encrypted_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:login_success.php");
}
else {
echo "Wrong Username or Password";
}
?>