Board index   FAQ   Search  
Register  Login
Board index PHP PHP Scripts

LOG IN CODE PROBLEM

Links for php scripts

Moderators: macek, egami, gesf

LOG IN CODE PROBLEM

Postby xflik » Mon Mar 14, 2011 5:10 am

<?php
session_start();

$username = $_POST ['username'];
$password = $_POST ['password'];

if($username&&$password)
{
$connection = mysql_connect("localhost","root","") or die ("Unable to connect");
mysql_select_db("login") or die ("Unable to connect DB");
$query = mysql_query("SELECT * FROM users WHERE username = '$username' AND password ='$password'");
$numrows = mysql_num_rows($query);
if($numrows != 0)
{
while ($row = mysql_fetch_assoc($query));
{
$dbusername = $row['$username'];
$dbpassword = $row['$password'];
}
if($username==$dbusername&&$password==$dbpassword)
{
echo "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;You are in!";

}
else
{
include('login.php');
die("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n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p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b>Please Enter Username and a Password!</b>");
}
?>

Undefined Index:username in checklogin.php on 4
Undefined Index:password in checklogin.php on 5

what is wrong in this code can you please help me to fix the code for my log in page..
xflik
New php-forum User
New php-forum User
 
Posts: 7
Joined: Fri Mar 11, 2011 1:54 am

Re: LOG IN CODE PROBLEM

Postby ionutica » Mon May 09, 2011 11:44 pm

It's simple:
$dbusername = $row['username'];
$dbpassword = $row['password'];
so no $ in $row[]
User avatar
ionutica
New php-forum User
New php-forum User
 
Posts: 4
Joined: Mon May 09, 2011 11:23 pm

Re: LOG IN CODE PROBLEM

Postby johnj » Tue May 10, 2011 12:40 am

a). Make sure that there are form variables named username and password
b). Make sure that the above variables have got a value. to verify that use isset().
johnj
php-forum Super User
php-forum Super User
 
Posts: 1805
Joined: Thu Mar 10, 2011 5:07 pm

Re: LOG IN CODE PROBLEM

Postby azhagu » Tue Jun 28, 2011 3:42 am

ionutica wrote:It's simple:
$dbusername = $row['username'];
$dbpassword = $row['password'];
so no $ in $row[]


refer this link http://www.techpdf.in/blog
azhagu
New php-forum User
New php-forum User
 
Posts: 13
Joined: Mon Jun 27, 2011 4:17 am


Return to PHP Scripts

Who is online

Users browsing this forum: No registered users and 2 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.