0% found this document useful (0 votes)
10 views6 pages

IM Review

The document outlines a web application for user registration, login, and session management for attendees and coordinators. It includes HTML forms for user input and PHP scripts for database interactions to store user data and manage sessions. The application provides functionality for users to register, log in, and access different features based on their roles.

Uploaded by

Gimar Hontiveros
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views6 pages

IM Review

The document outlines a web application for user registration, login, and session management for attendees and coordinators. It includes HTML forms for user input and PHP scripts for database interactions to store user data and manage sessions. The application provides functionality for users to register, log in, and access different features based on their roles.

Uploaded by

Gimar Hontiveros
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Register

<!DOCTYPE html>

<html>

<head>

<meta charset="utf-8">

<meta name="viewport" content="width=device-width, initial-scale=1">

<title></title>

</head>

<body>

<pre>

<form method="post">

<input type="text" name="txtUsername" placeholder="Username">

<input type="password" name="txtPassword" placeholder="Password">

<input type="text" name="txtFname" placeholder="Firstname">

<input type="text" name="txtLname" placeholder="Lastname">

<input type="date" name="txtBirthdate" placeholder="Birthdate">

<input type="text" name="txtBarangay" placeholder="Barangay">

<input type="submit" name="btnSubmit" value="Add">

</form>

</pre>

</body>

</html>

<?php

$con=mysqli_connect("localhost","root","","g4");
if(isset($_POST['btnSubmit'])){

$uname =$_POST['txtUsername'];

$pwd =$_POST['txtPassword'];

$fname =$_POST['txtFname'];

$lname =$_POST['txtLname'];

$bday =$_POST['txtBirthdate'];

$brngy =$_POST['txtBarangay'];

$sqlSelect = "select * from users where username='$uname'";

$results= mysqli_query($con,$sqlSelect);

if(mysqli_num_rows($results)==0){

$sql = "insert into users values('$uname','$pwd','$fname','$lname','$bday',2)";

mysqli_query($con,$sql);

$sql = "insert into attendee values('$uname','$brngy')";

mysqli_query($con,$sql);

echo "<script> alert('New record saved.');</script>";

}else{

echo "<script> alert('Username already existing.');</script>";

?>
Log in
<!DOCTYPE html>

<html>

<head>

<form method="post">

<div>

<div>

<input type="text" name="txtUsername" placeholder="Username" >

</div>

<div><input type="password" name="txtPassword" placeholder="Password"></div>

<div><input type="submit" name="btnLogin" value="Login"></div>

</div>

</form>

</body>

</html>

<?php

$con = mysqli_connect("localhost","root","","g4");

session_start();

if(isset($_POST['btnLogin'])){

$uname =$_POST['txtUsername'];

$pwd =$_POST['txtPassword'];
$sql="select * from users where username='$uname' and password='$pwd'";

$result = mysqli_query($con,$sql);

if(mysqli_num_rows($result)==1){

$row = mysqli_fetch_array($result);

$_SESSION['uname']=$row[0];

if($row[5]==2)

header("Location:attendee_index.php");

else if($row['roletype']==0)

header("Location:coordinator_index.php");

else

echo "Invalid credentials.";

?>
Log Off
<?php

session_start();

session_destroy();

header("Location:login.php");

?>

Attendee
<!DOCTYPE html>

<html>

<head>

<meta charset="utf-8">

<meta name="viewport" content="width=device-width, initial-scale=1">

<title></title>

</head>

<body>

<?php

session_start();

echo "Welcome Attendee ".$_SESSION['uname']."<br>";

?>

<a href="">Join</a>

<a href="">Joined Sports</a>


</body>

</html>

Coordinator
<!DOCTYPE html>

<html>

<head>

<meta charset="utf-8">

<meta name="viewport" content="width=device-width, initial-scale=1">

<title></title>

</head>

<body>

<?php

session_start();

echo "Welcome Coordinator ".$_SESSION['uname']."<br>";

?>

<a href="">Add a clinic</a>

<a href="">Add a coach</a>

<a href="logoff.php">Log off</a>

</body>

</html>

You might also like