please help me in sorting out error as im unable to find it...
my requirement is there will be userid field and password field and "login" button after clicking button certain validations must be done whether he is an valid user or not (connect to database and check for valid user & password) if he is valid user he must login and goto another php file.....
im using winxp OS / XAMPP Windows Version 1.6.4 !
Problem: im getting errors im sending the errors & code plz sort out
Expand|Select|Wrap|Line Numbers
- Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at C:\xampp\htdocs\sunkalpid\login.php:8) in C:\xampp\htdocs\sunkalpid\login.php on line 9
- Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at C:\xampp\htdocs\sunkalpid\login.php:8) in C:\xampp\htdocs\sunkalpid\login.php on line 9
- Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in C:\xampp\htdocs\sunkalpid\login.php on line 24
Expand|Select|Wrap|Line Numbers
- <html>
- <head>
- <title>Untitled Document</title>
- </head>
- <body>
- <?php
- session_start();
- //Connect to database
- mysql_connect ( "localhost", "root", "sunkalpid")or die("Could not connect: ".mysql_error());
- mysql_select_db("emp") or die(mysql_error());
- $username = $_POST['username'];
- $password = md5($_POST['password']);
- $query = "SELECT * FROM users WHERE username=’$username’ and password=’$password’ ";
- $result = mysql_query($query);
- if (mysql_num_rows($result) != 1)
- {
- $error = "Bad Login";
- include "login.html";
- } else {
- $_SESSION['username'] = "$username";
- include "registerdisplay.html";
- }
- ?>
- </body>
- </html>
Regards
Priya.