Okay, so im trying to do this login script for my college project. Why am I getting these errors:
The PHP behind this is as follows:Code:Warning: session_register() [function.session-register]: Cannot send session cookie - headers already sent by (output started at /homepages/4/d399133263/htdocs/checklogin.php:8) in /homepages/4/d399133263/htdocs/checklogin.php on line 62 Warning: session_register() [function.session-register]: Cannot send session cache limiter - headers already sent (output started at /homepages/4/d399133263/htdocs/checklogin.php:8) in /homepages/4/d399133263/htdocs/checklogin.php on line 62 Warning: Cannot modify header information - headers already sent by (output started at /homepages/4/d399133263/htdocs/checklogin.php:8) in /homepages/4/d399133263/htdocs/checklogin.php on line 64 Warning: Unknown: Your script possibly relies on a session side-effect which existed until PHP 4.2.3. Please be advised that the session extension does not consider global variables as a source of data, unless register_globals is enabled. You can disable this functionality and this warning by setting session.bug_compat_42 or session.bug_compat_warn to off, respectively in Unknown on line 0
Code:<?php ob_start(); $host="MYDB; // Host name $username="DBUSER"; // Mysql username $password="Password"; // Mysql password $db_name="db404370762"; // 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"); // Define $myusername and $mypassword $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){ session_register("myusername"); session_register("mypassword"); header("location:login_success.php"); } else { echo "Wrong Username or Password"; } ob_end_flush(); ?>
The code that is in Bold is line 62, 63 and 64. Please help! What am I doing wrong here?
-Fortune


LinkBack URL
About LinkBacks
Reply With Quote
