How to start a session for a user if he is registered or not 

/////////////// credentials included//////////////////
@ require_once (‘secret.php’);
/////////////// if id is matched from secret.php file session would start otherwise
 user would be redirected again to main index page     ////////
if (!isset($_SESSION[‘id’]))
////////////////// if id is available in secret .php now some of user credentials with reference to register_no against
will be brought  ;now user is logged in/////////
$sql = “SELECT * FROM sales WHERE register_no= 986522”;
$query = mysql_query($sql) or die(mysql_error());
$data2 = mysql_fetch_array($query);

//////////user_view and register_no fields will be retrieved from database; if they exist ///////
    $register_no = isset($_POST[‘register_no’]) ? $_POST[‘register_no’] : ”;
    $user_view = isset($_POST[‘user_view’]) ? $_POST[‘user_view’] : ”;