Log In Student With Unique Id

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • hanspeare
    New Member
    • May 2014
    • 20

    Log In Student With Unique Id

    Good day Admins,

    I have now variables

    $learner_id
    $student_paswor d

    The learner_id and student_passwor d are being used as their log in accounts. While the student_id is being used as their unique id and it is auto-incremented.

    Here are my codes.

    Student_login_h andler.php

    Code:
    <?php
    session_start();
    include 'Connect.php';
    $flag = "";
    $learner_id = $_POST['learner_id'];
    $student_password =  $_POST['student_password'];
    $query = "select last_login_date from student_information where learner_id='$learner_id' and student_password='$student_password'";
    $result = mysql_query($query,$link_id);
    if(mysql_error() != null){
    die(mysql_error());
    }
    if($date = mysql_fetch_array($result))
    {
    $lastdate = $date['last_login_date'];
    $date2 = date("d-m-Y h:i A",strtotime($lastdate));
    $_SESSION["user_id"] = $_POST["student_id"];
    $_SESSION["lastlogin"] =$date2;
    $_SESSION["type"] = "Student";
    mysql_query("UPDATE student_information SET last_login_date=now() where student_id='$GET[id]'",$link_id);
    if(mysql_error() != null){
    die(mysql_error());
    }
    header("location:  Student_Home.php?id={$student_id}"); 
    die();
    }
    else
    {
    $flag = "invalid";
    header("location:Student_login.php?flag=$flag");
    die();
    } 
    ?>
    Here is my Student_login.p hp

    Code:
    <td width="35%" align="left" class="style7 style1">Learner Id : </td>
               <td width="65%" align="left"><input name="learner_id" type="text" id="learner_id" action="Student_Home.php" method="post"></td>
            </tr>
            <tr bgcolor="#E1E1E1" class="stylesmall">
               <td align="left" class="style7 style1">Password:</td>
               <td align="left"><input name="student_password" type="password" id="student_password"></td>
            </tr>
            <tr bgcolor="#E1E1E1">	
               <td colspan="2" align="center">&nbsp;
    		     <?php if(!empty($_GET['flag']) && $_GET['flag'] == "invalid") { ?>
                 <span class="stylered style1">Invalid Learner Id or Password</span>
    			 <?php }?></td>
            </tr>
            <tr bgcolor="#E1E1E1">
               <td colspan="2" align="center">
    		        <p><input name="login" class="style10" type="submit" id="login" value="Login"></p>
    This is so far what i've got and it's wrong. Help me to modify this gentlemen to achieve the objectives given above.

    It directs me to URL
    http://localhost/a/S...nt_Home.php ?id=

    which i expect to be

    http://localhost/a/S..._Home.php?i d=51 (51 is the auto-incremented student_id, bears unique id of student)

    Please help me modify the codes.
  • androidapp
    New Member
    • Jun 2014
    • 10

    #2
    There is no need to redirect to different URL, just set a session for this studentid.

    Comment

    • hanspeare
      New Member
      • May 2014
      • 20

      #3
      Hello android app,

      i suppose your not only that android app. Maybe that is what i am missing.

      I would be delighted if you help me to make that session and declared that student_id variable.

      Please modify my codes. I dont really have an idea where to start with that except for what i have posted.
      Please :-(

      Comment

      Working...