Checking for sessions

Typically if the user doesn’t exist, you would go instead to a new user page which confirms that the details are correct, typically through an email response loop, and then once successful redirects to the products page.

yes first part is correct.not understood the second part of ur question

It’s not a question. You asked a question, Paul gave an answer.

below is the modified code


<?php 
session_start();
mysql_connect("localhost","root","") or die("mysql_error()");
mysql_select_db("shopping") or die("mysql_error()"); 
$result = mysql_query("SELECT username FROM login WHERE username='" . $_POST['username'] . "' AND password='" . $_POST['password'] . "'"); 
$rows=mysql_num_rows($result);
if(!isset($_SESSION['unique_id']))
{
$n = time();
$_SESSION['username'] = $_POST['username'];
header("Location:products.php");
} 
else 
{
header("Location:products.php");
}
?>

it is redirecting to the “products.php” page…
how to check that for not registered user

If you want someone here to write the code for you, that can be done, but it will most likely not be up to the standards that you require.

If you would like to learn how to write what you need though, then we can happily help you to learn about what you need to know.

Well first of all, what is it that you require for someone to be considered to have appropriately registered?

in my above code tell me how to register the username in the database

i am not getting u

@ravi951:There may be an issue with your command of English.
But the ‘tone’ of your posts is not very polite. You are asking for advice in the form of “TELL ME HOW TO DO IT”.
Although we all are willing and anxious to help anyone learn and succeed when they encounter difficulty, your posts evoke an attitude that contains;

  • no willingness to learn
  • an insistence that someone provide the answer
  • lack of attention or attempt to honestly understand what is being [carefully and delicately] explained to you

If I have misunderstood your intentions, correct me and accept my apologies. This message is NOT intended to demean or insult you. I wanted to provide you an objective perspective on the way you are presenting yourself.

Please, please carefully re-read this entire thread; take notes if you must in order to collect the valuable information that has been presented here.