Gitlab@Informatics
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
promelon
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
65160377
promelon
Commits
929491e2
Commit
929491e2
authored
3 months ago
by
65160377
Browse files
Options
Downloads
Patches
Plain Diff
Initial commit
parent
36a9bb68
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
includes/signin.php
+51
-43
51 additions, 43 deletions
includes/signin.php
includes/signup.php
+15
-0
15 additions, 0 deletions
includes/signup.php
package-list.php
+15
-1
15 additions, 1 deletion
package-list.php
with
81 additions
and
44 deletions
includes/signin.php
+
51
−
43
View file @
929491e2
<?php
session_start
();
if
(
isset
(
$_POST
[
'signin'
]))
{
include
(
'db_config.php'
);
// เชื่อมต่อฐานข้อมูล
if
(
isset
(
$_POST
[
'signin'
]))
{
$email
=
$_POST
[
'email'
];
$password
=
$_POST
[
'password'
];
// ใช้ password_hash() กับฐานข้อมูลที่เก็บรหัสผ่าน
$sql
=
"SELECT EmailId, Password FROM tblusers WHERE EmailId = :email"
;
$query
=
$dbh
->
prepare
(
$sql
);
$query
->
bindParam
(
':email'
,
$email
,
PDO
::
PARAM_STR
);
$query
->
execute
();
$result
=
$query
->
fetch
(
PDO
::
FETCH_ASSOC
);
if
(
$result
&&
password_verify
(
$password
,
$result
[
'Password'
]))
{
$_SESSION
[
'login'
]
=
$email
;
echo
"<script type='text/javascript'> document.l
ocation
= '
package-list.php
'; </script>"
;
$_SESSION
[
'login'
]
=
$email
;
// เก็บข้อมูลผู้ใช้ที่ล็อกอิน
header
(
"L
ocation
:
package-list.php
"
);
// ไปที่หน้าต่อไป
}
else
{
echo
"<script>alert('Invalid Details');</script>"
;
}
}
if
(
!
isset
(
$_SESSION
[
'login'
]))
{
echo
"Please login first."
;
}
else
{
echo
"Welcome, "
.
$_SESSION
[
'login'
];
}
?>
<div
class=
"modal fade"
id=
"myModal4"
tabindex=
"-1"
role=
"dialog"
aria-labelledby=
"myModalLabel"
>
<div
class=
"modal-dialog"
role=
"document"
>
<div
class=
"modal-content modal-info"
>
<div
class=
"modal-header"
>
<button
type=
"button"
class=
"close"
data-dismiss=
"modal"
aria-label=
"Close"
><span
aria-hidden=
"true"
>
×
</span></button>
</div>
<div
class=
"modal-body modal-spa"
>
<div
class=
"login-grids"
>
<div
class=
"login"
>
<div
class=
"login-right"
>
<?php
session_start
();
// ลบ Session ที่เก็บข้อมูลผู้ใช้
session_unset
();
session_destroy
();
// ส่งผู้ใช้กลับไปที่หน้า Login
header
(
"Location: signin.php"
);
exit
();
?>
<!DOCTYPE html>
<html>
<head>
<title>
Sign In
</title>
</head>
<body>
<form
method=
"post"
>
<h3>
Signin with your account
</h3>
<input
type=
"text"
name=
"email"
id=
"email"
placeholder=
"Enter your Email"
required=
""
>
<input
type=
"password"
name=
"password"
id=
"password"
placeholder=
"Password"
value=
""
required=
""
>
<h4><a
href=
"forgot-password.php"
>
Forgot password
</a></h4>
<input
type=
"submit"
name=
"signin"
value=
"SIGNIN"
>
<input
type=
"text"
name=
"email"
placeholder=
"Enter your Email"
required
><br>
<input
type=
"password"
name=
"password"
placeholder=
"Password"
required
><br>
<input
type=
"submit"
name=
"signin"
value=
"SIGN IN"
><br>
</form>
</div>
<div
class=
"clearfix"
></div>
</div>
<p>
By logging in you agree to our
<a
href=
"page.php?type=terms"
>
Terms and Conditions
</a>
and
<a
href=
"page.php?type=privacy"
>
Privacy Policy
</a></p>
</div>
</div>
</div>
</div>
</div>
\ No newline at end of file
</body>
</html>
This diff is collapsed.
Click to expand it.
includes/signup.php
+
15
−
0
View file @
929491e2
...
...
@@ -42,6 +42,21 @@ $("#loaderIcon").hide();
error
:
function
(){}
});
}
if
(
isset
(
$_POST
[
'
register
'
]))
{
$email
=
$_POST
[
'
email
'
];
$password
=
$_POST
[
'
password
'
];
// เข้ารหัสรหัสผ่าน
$hashed_password
=
password_hash
(
$password
,
PASSWORD_DEFAULT
);
$sql
=
"
INSERT INTO tblusers (EmailId, Password) VALUES (:email, :password)
"
;
$query
=
$dbh
->
prepare
(
$sql
);
$query
->
bindParam
(
'
:email
'
,
$email
,
PDO
::
PARAM_STR
);
$query
->
bindParam
(
'
:password
'
,
$hashed_password
,
PDO
::
PARAM_STR
);
$query
->
execute
();
}
</script>
<div
class=
"modal fade"
id=
"myModal"
tabindex=
"-1"
role=
"dialog"
aria-labelledby=
"myModalLabel"
>
...
...
This diff is collapsed.
Click to expand it.
package-list.php
+
15
−
1
View file @
929491e2
...
...
@@ -92,3 +92,17 @@ foreach($results as $result)
<!-- //write us -->
</body>
</html>
<?php
session_start
();
// ถ้าผู้ใช้ไม่ได้เข้าสู่ระบบ ให้ส่งกลับไปที่หน้า login
if
(
!
isset
(
$_SESSION
[
'login'
]))
{
header
(
"Location: signin.php"
);
exit
();
}
// ถ้ามีการเข้าสู่ระบบแล้ว
echo
"Welcome, "
.
$_SESSION
[
'login'
];
// แสดงชื่อผู้ใช้ที่ล็อกอิน
?>
<a
href=
"logout.php"
>
Log Off
</a>
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment