[go: up one dir, main page]

0% found this document useful (0 votes)
209 views8 pages

Source Code To Edith

The document contains PHP code to implement a sign up and login system for a ticketing application. It includes code to: 1) Connect to a MySQL database and select the appropriate database 2) Insert user data into a database table on sign up if the username is available 3) Authenticate login attempts by querying the database and comparing credentials 4) Direct to different pages depending on the user role after successful login

Uploaded by

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

Source Code To Edith

The document contains PHP code to implement a sign up and login system for a ticketing application. It includes code to: 1) Connect to a MySQL database and select the appropriate database 2) Insert user data into a database table on sign up if the username is available 3) Authenticate login attempts by querying the database and comparing credentials 4) Direct to different pages depending on the user role after successful login

Uploaded by

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

SIGN UP

<?php
$ser="localhost";
$user="root";
$pass="";
$db="newtestdb";
$con=mysqli_connect($ser, $user, $pass, $db) or die("Connection Failed");

session_start();

$Name = $_POST['FirstName'];
$Department = $_POST['Department'];
$Employee_id= $_POST['ID'];
$PhoneNumber = $_POST['number'];
$username = $_POST['Username'];
$password = $_POST['Password'];

$sql1="SELECT * FROM person WHERE username='$username'";


$result=mysqli_query($con,$sql1);
if(!$result){
echo "<script type='text/javascript'>alert('Database Error
Occured')</script>";
}

if (mysqli_num_rows($result) == 0) {
$sql = "INSERT INTO person
(id,Employee_id,Name,Department,username,password,PhoneNumber,Active)
Values
('0','$Employee_id','$Name','$Department','$username','$password','$PhoneNumber'
,'0')";
$result=mysqli_query($con,$sql);
if(!$result){
echo "<script type='text/javascript'>alert('Failed to Sign
up')</script>";
}
else {
if (mysqli_affected_rows($con) == 1) {
echo "<script
type='text/javascript'>alert('Your account is send. Pls. wait for
Activation')</script>";
} else
{
echo "<script
type='text/javascript'>alert('Sorry You could not be registered due to a system
error. We apologize for any inconvenience.')</script>";
}
}
}else
{
echo "<script type='text/javascript'>alert('Username is already
taken')</script>";
}

header("refresh:1; url=log sign up.php");

?>
TRACKING
<?php
session_start();

?>
<!DOCTYPE html>
<html>
<head>
<title>Ticketing System</title>
<link rel="stylesheet" type="text/css" href="log track.css">
<link rel="shortcut icon" href="CSC logo1.png" type="image/x-icon" />

</head>
<body>

<div class="navbar">
<img src="ticket logo.png">
</div>

<div class="log1">
<a href="log infinal.php"> <img src="bootmr.jpg"><p>Log in</p></a>
</div>
<div class="log4">
<a href="log sign up.php"><img src="bootmr.jpg"><p>Sign up</p></a>
</div>
<div class="log5">
<a href="logtrack.php"><img src="bootmr1.jpg"><p>Tacking</p></a>
</div>
<div class="cover1"></div>

<div class="sign1"><p>Tracking</p></div>
<div class="sign11"><p>Trace your Request</p></div>
<div class="logo1"><img src="track.png"></div>

<div class="singin">

<form action="track.php" method="POST">


<input type="firstname" id="Trackingnum" name="Trackingnum"
placeholder="Tracking num" required>
<input type="IDnum" id="ID num" name="ID" placeholder="Employee ID"
required>

<input type="submit" name="submit" value="Log in" id="alert();">


</form>

</div>

</body>
</html>

SIGN UP
<?php
$ser="localhost";
$user="root";
$pass="";
$db="newtestdb";
$con1=mysqli_connect($ser, $user, $pass, $db) or die("Connection Failed");

session_start();

$mess='Your Username and Passowrd are Incorrect!';


if ($_POST ['submit']){
$username = $_POST['username'];
$password = $_POST['password'];

if ($username){
if($password){
$password = ($password);
$con2="SELECT * FROM person WHERE username=
'$username'";
$query= mysqli_query($con1, $con2);
$numrows = mysqli_num_rows ($query);
if($numrows ==1){
$row= mysqli_fetch_assoc($query);
$dbusername= $row['username'];
$dbname= $row['Name'];
$dbdept= $row['Department'];
$dbnumber= $row['PhoneNumber'];
$dbpassword= $row['password'];
$dbid = $row ['Employee_id'];
$dbActive = $row ['Active'];
if($username==$dbusername){
if($password == $dbpassword){
if ($dbActive==1){
$_SESSION['number']= $dbnumber;
$_SESSION['department']= $dbdept;
$_SESSION['name']= $dbname;
$_SESSION['employeeid']=$dbid;
$_SESSION ['username']=
$dbusername;
if ($dbid == A010){

$_SESSION ['username']=
$dbusername;
header('Location:
techchristian1.php');
}
elseif($dbid ==A024){
$_SESSION ['username']=
$dbusername;
header('Location: techdexter1.php');
}
elseif ($dbid == C028){
$_SESSION ['username']=
$dbusername;
header('Location: admin3.php');
}
else{
$_SESSION['number']= $dbnumber;
$_SESSION['department']= $dbdept;
$_SESSION['name']= $dbname;
$_SESSION['employeeid']=$dbid;
$_SESSION ['username']=
$dbusername;
header('Location: Home.php');
}
}
else{
echo "<script
type='text/javascript'>alert('Your account is not yet activated. Pls. go to CSC Office
to Activate')</script>";
header("refresh:1; url=log
infinal.php");
}
}
else{
echo "<script
type='text/javascript'>alert('Your username and password is incorrect')</script>";
header("refresh:1; url=log
infinal.php");
}
}
else{
echo "<script
type='text/javascript'>alert('Your username and password is incorrect')</script>";
header("refresh:1; url=log infinal.php");

}
}
else{

echo "<script type='text/javascript'>alert('Your


username and password is incorrect')</script>";
header("refresh:1; url=log infinal.php");
}
}
else{
echo "<script type='text/javascript'>alert('Your username and
password is incorrect')</script>";
header("refresh:1; url=log infinal.php");
}
}
else{
echo "<script type='text/javascript'>alert('Your username and
password is incorrect')</script>";
header("refresh:1; url=log infinal.php");
}
}
else {
echo "<script type='text/javascript'>alert('Your username and
password is incorrect')</script>";
header("refresh:1; url=log infinal.php");
}

?>

You might also like