Jump to content
Stef's Super Nerd Community
Sign in to follow this  
phpNOvice

Log In Student With Unique Id

Recommended Posts

Good day Admins,

 

I have now variables

 

$learner_id

$student_pasword

$student_id

 

The learner_id and student_password 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_handler.php


<?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();
} 
?>

 

 
 

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/Student_Home.php?id=

 

which i expect to be 

 

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

Edited by phpNOvice

Share this post


Link to post
Share on other sites

 

 

My problem is with the correct learner id and student password they cant directly enter to their Student_Home.php bearing the URL like

http://localhost/a/S..._Home.php?id=51

 

I'm sorry, I'm not sure if I understand the problem? If you provided them a URL to directly access their account, that would mean anyone else with the same URL would be able to access their account too? If you want to keep it secure, they will need to enter their username and password.

Share this post


Link to post
Share on other sites

Hello there Sir Ben,

 

Uhh Yes, they have to log in to their user account using their learner_id and student_password. 

Im sorry for that,

 

Here is my Student_login.php

<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"> 
		     <?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> 

I have updated my previous comment because from time to time i am also working with these codes with your guidance.

Edited by phpNOvice

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  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.

Loading...
Sign in to follow this  

×
×
  • Create New...