Hi,
if user is not the registered user first he has to register and then login, my login page is working but i want to validate whether he is an registered user or not. i had written some code but its giving some problem , can any one help me plz...this is actually not a full code what i have given below.

<?php
include 'db.php';

$username = $_POST;
$password = $_POST ;


$q = "SELECT * FROM `userdetail` WHERE username='".$username."' AND password='".$password."'";
$result = mysql_query($q);


if(($
?>

It's better this way:

$q = "SELECT * FROM `userdetail` WHERE username='$username'";

$rs = mysql_query($q);
$rw = mysql_fetch_array($rs);

if($rw["password"]!=$password){
die('Acces denied'); // .. or something
}

Hello..

Use this code in your page with your database names...

you will get what you want..

<?
session_start();
include('functions.php');


if($_SERVER=="POST"){


$qer="select * from admin where username='".$_POST."' and password='".$_POST."'";
$res=mysql_query($qer);
$num=mysql_num_rows($res);
if($num==0)
{
$msg=1;
}
else if($num==1)
{
session_unregister("user_name");
session_register("user_name");
$_SESSION=$_POST;


session_unregister("adminid");
session_register("adminid");
$_SESSION=getdata("admin","id","username='".$_POST."' and password='".$_POST."'");


echo'<script language="javascript">window.location.href="welcome.php";</script>';
}
}
?>

And use this below code where ever you want to print like invalid user:
<? if(!empty($msg) && $msg==1){echo "Invalid user";}?>

Thanks,

ShantI

Edited 3 Years Ago by happygeek: fixed formatting

hi...

I am just continuing your code....

<?php
include 'db.php';

$username = $_POST;
$password = $_POST ;


$q = "SELECT * FROM userdetail WHERE username='$username' AND password='$password.'";
$result = mysql_query($q);
$numrows=mysql_num_rows($result);
if($numrows==0)
echo "invlid user";
else
echo "logged in successfully";
?>

This article has been dead for over six months. Start a new discussion instead.