Skip to content
Snippets Groups Projects
Commit 3229d1ae authored by Akmal Fadlurohman's avatar Akmal Fadlurohman
Browse files

Menambahkan sistem sign up tanpa ajax

parent d4daab18
1 merge request!45OneHundred - 13515005 - Husnulzaki Wibisono Haryadi
-- Database PR-Ojek -- Database PR-Ojek
DROP TABLE IF EXISTS `user`;
CREATE TABLE IF NOT EXISTS `user` ( CREATE TABLE IF NOT EXISTS `user` (
`user_id` INT NOT NULL, `user_id` INT NOT NULL AUTO_INCREMENT,
`name` VARCHAR(50) NOT NULL, `name` VARCHAR(50) NOT NULL,
`email` VARCHAR(50) NOT NULL, `email` VARCHAR(50) NOT NULL,
`phone` VARCHAR(20) NOT NULL, `phone` VARCHAR(20) NOT NULL,
...@@ -13,11 +14,7 @@ CREATE TABLE IF NOT EXISTS `user` ( ...@@ -13,11 +14,7 @@ CREATE TABLE IF NOT EXISTS `user` (
PRIMARY KEY (`user_id`) PRIMARY KEY (`user_id`)
); );
LOCK TABLES `user` WRITE; DROP TABLE IF EXISTS `driver`;
INSERT INTO `user` VALUES ('1','Donald Trump','donaldducktrump@gmail.com','08136','donaldduck','123456','Not_Driver',DEFAULT);
UNLOCK TABLES;
CREATE TABLE IF NOT EXISTS `driver` ( CREATE TABLE IF NOT EXISTS `driver` (
`driver_id` INT NOT NULL, `driver_id` INT NOT NULL,
`total_score` DOUBLE(50,1) NOT NULL, `total_score` DOUBLE(50,1) NOT NULL,
...@@ -27,6 +24,7 @@ CREATE TABLE IF NOT EXISTS `driver` ( ...@@ -27,6 +24,7 @@ CREATE TABLE IF NOT EXISTS `driver` (
CONSTRAINT `driver_ibfk_1` FOREIGN KEY (`driver_id`) REFERENCES `user` (`user_id`) CONSTRAINT `driver_ibfk_1` FOREIGN KEY (`driver_id`) REFERENCES `user` (`user_id`)
); );
DROP TABLE IF EXISTS `driver_prefloc`;
CREATE TABLE IF NOT EXISTS `driver_prefloc` ( CREATE TABLE IF NOT EXISTS `driver_prefloc` (
`driver_id` INT NOT NULL, `driver_id` INT NOT NULL,
`pref_loc` VARCHAR(50) NOT NULL, `pref_loc` VARCHAR(50) NOT NULL,
......
<?php <?php
if ($_SERVER["REQUEST_METHOD"] == "POST") { if ($_SERVER["REQUEST_METHOD"] == "POST") {
if (!empty($_POST['user_name']) && !empty($_POST['user_password'])) { if (!empty($_POST['user_name']) && !empty($_POST['user_password'])) {
include '../db_pr-ojek.php'; include '../database/dbconnect.php';
$user = $_POST['user_name']; $user = $_POST['user_name'];
$pass = $_POST['user_password']; $pass = $_POST['user_password'];
$query=mysql_query("SELECT * FROM user WHERE username='".$user."' AND password='".$pass."'") or die(mysql_error()); $query=mysql_query("SELECT * FROM user WHERE username='".$user."' AND password='".$pass."'") or die(mysql_error());
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
if($user == $dbusername && $pass == $dbpassword) if($user == $dbusername && $pass == $dbpassword)
{ {
header("Location: ../profile_page/profile.html"); header("Location: ../order/order.html");
} }
} else { } else {
include("login.html"); include("login.html");
...@@ -29,11 +29,4 @@ ...@@ -29,11 +29,4 @@
mysql_close($conn); mysql_close($conn);
} }
} }
function clean_input($data) {
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
return $data;
}
?> ?>
...@@ -9,26 +9,45 @@ ...@@ -9,26 +9,45 @@
<h1>-- Sign up --</h1> <h1>-- Sign up --</h1>
<div> <div>
<form method="post"> <form name="sign_up" method="post" action="sign_up.php" onsubmit="return validate_password();">
Your name Your name*
<input type="text" name="real_name"><br/> <input type="text" name="full_name"><br/>
Username Username*
<input type="text" name="real_name"><br/> <input type="text" name="user_name"><br/>
Email Email*
<input type="Email" name="real_name"><br/> <input type="Email" name="user_email"><br/>
Password Password*
<input type="Password" name="real_name"><br/> <input type="Password" name="user_password"><br/>
Confirm password Confirm password*
<input type="Password" name="real_name"><br/> <input type="Password" name="confirm_password"><br/>
Phone number Phone number*
<input type="text" name="real_name"><br/> <input type="text" name="user_phone"><br/>
<input type="checkbox" name="is_driver" value="true">Also sign me up as a driver<br/>
<input type="button" value="Sign me up as driver" id="signAs_driver" style="width : 40%" onclick= "driver_signup();"><label id="driversign_status"><br></label>
<input type="text" name="is_driver" style="display:none">
<input type="submit" value="REGISTER"> <input type="submit" value="REGISTER">
</form> </form>
<p><br>* Required field</p>
</div> </div>
</div> </div>
<script>
function validate_password()
{
var password = document.sign_up.user_password.value;
var confirm_password = document.sign_up.confirm_password.value;
if (password !== confirm_password)
{
window.alert("The passwords you entered didn't match");
return false;
}
}
function driver_signup()
{
document.getElementById("driversign_status").innerHTML= "Signed as driver";
document.getElementById("signAs_driver").style.display = "none";
document.sign_up.is_driver.value = "Yes";
}
</script>
</body> </body>
</html> </html>
\ No newline at end of file
<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
if (!empty($_POST['full_name']) &&
!empty($_POST['user_name']) &&
!empty($_POST['user_email']) &&
!empty($_POST['user_password']) &&
!empty($_POST['confirm_password']) &&
!empty($_POST['user_phone']))
{
include '../database/dbconnect.php';
$fullname = $_POST['full_name'];
$username = $_POST['user_name'];
$email = $_POST['user_email'];
$password = $_POST['user_password'];
$phone = $_POST['user_phone'];
if(isset($_POST['is_driver']))
{
$status = 'driver';
}
else
{
$status = 'customer';
}
$query = mysql_query("INSERT INTO user (name,email,phone,username,password,status,pict) VALUES ('$fullname', '$email', '$phone', '$username', '$password', '$status',DEFAULT)") or die(mysql_error());
if($query)
{
header("Location: ../order/order.html");
}
mysql_close($conn);
/*else {
include("login.html");
echo "<script>
document.getElementById('error_credential').innerHTML = 'Invalid username or password!';
</script>";
header("Location: login.html");
}
*/
}
}
?>
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
</head> </head>
<body> <body>
<div class="frame"> <div class="frame">
<p>test</p> <p>Order</p>
</div> </div>
</body> </body>
</html> </html>
\ No newline at end of file
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment