Hi, I Need PHP login Form with database connection code. Also i need session id different page. Suppose when a.htm page loading that time pages should be check session id. If it's there then it'll go b.htm neither redirect to c.htm. Kindly anybody suggest me for this code, i'll really appreciate with him. Thanks Alok
<?php ob_start(); session_start(); $conn=mysql_connect("localhost","root",""); mysql_select_db("login"); if(isset($_POST['submit'])) { $result=mysql_query("select * from registered_user where username='" . $_POST['username'] . "' and password='" . $_POST['password'] . "'"); $num=mysql_num_rows($result); if($num < 1) { echo "You are not authenticated. Please login."; } else { $_SESSION['username']=$_POST["username"]; $_SESSION['password']=$_POST["password"]; header("location:wel.php"); } } ?> <form method="post" action="log.php"> UserName:<input type="text" name="username" /><br /> Password:<input type="text" name="password" /> <input type="submit" name="submit" value="Submit" /> </form> PHP:
If you're a beginner I wouldn't recommend login scripts until you've increased your abilities. The above post is littered with vulnerabilities and I would strongly recommend you do not use it.