Jump to content

Recommended Posts

actually i want to make a code .. AIM IS THAT TEACHER FIRST LOG IN AND THEN MARK THE ATTENDANCE step 1)TEACHER FIST LOGIN .......2)TEACHER THEN CHOOSE ONE OF TWO BUTTON IN WHICH ONE IS OF ENTRY AND OTHER FOR EXIT...3)I ALSO WANT TO USE SESSION..IN THE MAIN.PHP i want to input username and password..and then redirect the page to attendance.php...also want to include session ...HELp me

 

[attachment deleted by admin]

In main.php you're calling header("location:attendance.php"); after output has been sent. header() cannot be called after output has been sent to the browser. You should move this block of code in main.php

<?php
if(!empty($_POST['submit']))
{
  $username=$_POST['username'];
  $pwd=$_POST['pwd'];
$_SESSION['user']=$username;
  //$_SESSION['user'];
  $_SESSION['pswd']=$pwd;
}
header("location:attendance.php");


?>

Into the same code block where you have session_start();.

 

Use this code for main.php

<?php
session_start();
//include "../sabkuch/dbconnect.php";

if(isset($_POST['submit']))
{
    $username = $_POST['username'];
    $pwd = $_POST['pwd'];
    
    $_SESSION['user'] = $username;
    $_SESSION['pswd'] = $pwd;
    
    header("location:attendance.php");
}

?>
<form name="login" method="post" action="#">
    <b>ENTER YOUR DETAILS BELOW</b><br/>
    <hr/>
    USERNAME:<input name="username" type="text" value=""><br/>

        PASSWORD:<input name="pwd" type="password" value=""><br/>
    <input name="submit" type="submit" value="LOGIN">

</form>

 

The next issue is in attendence.php, on  line 16 you're calling session_destroy();.  Calling this function will destroy the current session. You should only call this function in certain circumstances, such as when logging out the current user. If you leave it as is every time you go to main.php and fill in your username/password your session will always be reset.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.