Expand|Select|Wrap|Line Numbers
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- <title>Untitled Document</title>
- </head>
- <body>
- <?php
- ob_start();
- $host="localhost"; // Host name
- $username="root"; // Mysql username
- $password="dhanshi"; // Mysql password
- $db_name="adi"; // Database name
- $tbl_name="users"; // 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['name'];
- $mypassword=$_POST['pass'];
- // To protect 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 name='$myusername' and pass=md5('$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
- $r=mysql_fetch_array($result);
- $value=$r['value'];
- if($count==1){
- session_register("myusername");
- session_register("mypassword");
- //echo $value;
- //echo '<META HTTP-EQUIV="Refresh" Content="0; URL=login_success.php">';
- switch($value)
- {
- case "1";
- case "2";
- echo '<META HTTP-EQUIV="Refresh" Content="0; URL=tl.php">';
- break;
- case "3";
- echo '<META HTTP-EQUIV="Refresh" Content="0; URL=l2.php">';
- break;
- case "4";
- echo '<META HTTP-EQUIV="Refresh" Content="0; URL=l3.php">';
- default:
- echo '<META HTTP-EQUIV="Refresh" Content="0; URL=l3.php">';
- exit;
- }
- }
- else {
- echo '<META HTTP-EQUIV="Refresh" Content="0; URL=wrong.php">';
- }
- ob_end_flush();
- ?>
Warning: session_register() [function.session-register]: Cannot send session cache limiter - headers already sent (output started at C:\xampp\htdocs\adi\check.php:8) in C:\xampp\htdocs\adi\check.php on line 42.
Line 8 and 42 is highlighted here.
Can this problem be solved?