Skip to content

Commit

Permalink
finish users signup simple process #7
Browse files Browse the repository at this point in the history
  • Loading branch information
Deshan555 committed Nov 12, 2022
1 parent 83abba4 commit ce974a9
Show file tree
Hide file tree
Showing 2 changed files with 189 additions and 43 deletions.
100 changes: 57 additions & 43 deletions signup.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,66 +43,44 @@

<div class="card-body p-4 p-lg-5 text-black">

<form method="post" action="assets/php/actions.php?signup">
<form method="post" id="signup_form" action="signup_action.php">

<div class="d-flex justify-content-center">

<img class="mb-4" src="assets/images/login_request/small_logo.png" alt="" height="45">

</div>

<h6 style="text-transform: uppercase; color: grey;" class="mt-2 mb-1"><b>Join With Us</b></h5>
<h6 style="text-transform: uppercase; color: grey;" class="mt-2 mb-1"><b>Join With Us</b></h6>

<!--<h1 class="h5 mb-3 fw-normal">Create new account</h1>-->
<?php if(isset($_GET['error_message'])){ ?>

<p id="error_message" class="text-center alert-danger"><?php echo $_GET['error_message'];?></p>

<?php }?>



<div class="d-flex">

<div class="form-floating mt-1 col-6 text-muted h6" style="font-size:small;">

<input type="text" name="first_name" class="form-control form-control-lg0" placeholder="username/email">
<input type="text" name="full_name" class="form-control form-control-lg0" placeholder="username/email">

<label for="floatingInput">Full Name</label>

</div>

<div class="form-floating mt-1 col-6 text-muted h6" style="font-size:small;">

<input type="text" name="last_name" class="form-control form-control-lg0" placeholder="username/email">
<input type="text" name="user_name" class="form-control form-control-lg0" placeholder="username/email">

<label for="floatingInput">User Name</label>

</div>

</div>

<div class="d-flex gap-5 my-3">

<div class="form-check text-muted h6" style="font-size:small;">

<input class="form-check-input" type="radio" name="gender" id="exampleRadios1">

<label class="form-check-label" for="exampleRadios1">

Basic User

</label>
</div>

<div class="form-check text-muted h6" style="font-size:small;">

<input class="form-check-input" type="radio" name="gender" id="exampleRadios3"
>

<label class="form-check-label" for="exampleRadios3">

Club Or Organization

</label>

</div>

</div>

<div class="form-floating mt-2 text-muted h6" style="font-size:small;">

<input type="email" name="email" class="form-control form-control-lg0" placeholder="username/email">
Expand All @@ -111,31 +89,25 @@

</div>

<!--<?=showError('email')?>-->

<div class="form-floating mt-2 text-muted h6" style="font-size:small;">

<input type="password" name="password" class="form-control form-control-lg0" placeholder="Password">
<input type="password" name="password" class="form-control form-control-lg0" placeholder="Password" id="pass" onchange="verify_len();">

<label for="floatingInput">Password</label>

</div>

<!--<?=showError('username')?>-->

<div class="form-floating mt-2 text-muted h6" style="font-size:small;">

<input type="password" name="retype_password" class="form-control form-control-lg0" id="floatingPassword" placeholder="Retype Password">
<input type="password" name="retype_password" class="form-control form-control-lg0" id="retype_pass" placeholder="Retype Password" onchange="verify_form();">

<label for="floatingPassword">Retype password</label>

</div>

<!--<?=showError('password')?>-->

<div class="pt-1 mb-4 mt-2">

<button class="btn btn-dark btn-lg btn-block" type="submit">SIGNUP</button>
<button class="btn btn-dark btn-lg btn-block" type="submit" name="signup_btn">SIGNUP</button>

</div>

Expand All @@ -155,7 +127,49 @@

<script type="text/javascript" src="assets/js/mdb.min.js"></script>

<script type="text/javascript"></script>
<script type="text/javascript">

/*function verify_form()
{
var password = document.getElementById('pass').value;

var retype_password = document.getElementById('retype_pass').value;

if(password !== retype_password)
{
document.getElementById("error_message").innerHTML = "Password Not Match";

console.log('password missmatch');

return false;
}
else{
return true;
}
}*/


function verify_len()
{
var password = document.getElementById('pass').value;

if(password.length <= 8)
{
document.getElementById("error_message").innerHTML = 'password too short';
}
else{
document.getElementById("error_message").innerHTML = '';
}
}

/*document.getElementById('signup_btn').addEventListener('click'),(e)=>
{
e.preventDefault();

verify_form();
}*/

</script>

</body>

Expand Down
132 changes: 132 additions & 0 deletions signup_action.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@

<?php

include('config.php');

if(isset($_POST['signup_btn']))
{
$full_name = $_POST['full_name'];

$user_name= $_POST['user_name'];

$user_type = 1;

$email_address= $_POST['email'];

$facebook = "www.facebook.com";

$whatsapp = "www.webwhatsapp.com";

$bio = "tell use more about you";

$fallowers = 0;

$fallowing = 0;

$post_count = 0;

$image = "assets/images/default.png";

$password= $_POST['password'];

$password_confirm= $_POST['retype_password'];

//echo $full_name;

if($password != $password_confirm)
{
$message_error = "error message";

header('location: signup.php?error_message=Passwords can not verify');

exit;
}

// check user availibility

$sql_query = "SELECT User_ID FROM USERS WHERE USER_NAME = '$user_name' OR EMAIL = '$email_address';";

//echo $sql_query;

$stmt = $conn->prepare($sql_query);

//$stmt->bind_param("ss",$user_name, $email_address);

$stmt->execute();

$stmt->store_result();

if($stmt->num_rows() > 0)
{
echo 'user name already exists';

header('location: signup.php?error_message=user already exists');

exit;

}else{

$encrypted_password = md5($password);

$insert_query = "INSERT INTO users (FULL_NAME,USER_NAME,USER_TYPE,PASSWORD_S,EMAIL,IMAGE,FACEBOOK,WHATSAPP,BIO,FALLOWERS,FALLOWING,POSTS) VALUES
('$full_name', '$user_name', '$user_type', '$encrypted_password', '$email_address', '$image', '$facebook', '$whatsapp', '$bio', $fallowers, $fallowing, $post_count);";

$stmt->prepare($insert_query);

if($stmt->execute())
{
$data_select = "SELECT FULL_NAME,USER_NAME,USER_TYPE,EMAIL,IMAGE,FACEBOOK,WHATSAPP,BIO,FALLOWERS,FALLOWING,POSTS FROM users WHERE USER_NAME = '$user_name';";

$stmt = $conn->prepare($data_select);

$stmt->execute();

$stmt->bind_result($full_name, $user_name, $user_type, $email_address, $image, $facebook, $whatsapp, $bio, $fallowers, $fallowing, $post_count);

$stmt->fetch();

//$_SESSION['id'] = $User_ID;

$_SESSION['username'] = $user_name;

$_SESSION['fullname'] = $full_name;

$_SESSION['email'] = $email_address;

$_SESSION['usertype'] = $user_type;

$_SESSION['facebook'] = $facebook;

$_SESSION['whatsapp'] = $whatsapp;

$_SESSION['bio'] = $bio;

$_SESSION['fallowers'] = $fallowers;

$_SESSION['fallowing'] = $fallowing;

$_SESSION['postcount'] = $post_count;

$_SESSION['img_path'] = $image;

header("location: index.php");

}else{

header("location: signup.php?error_message=error occured");

exit;
}
}

}else
{
header("location: signup.php?error_message=error occured");

exit;
}



?>

0 comments on commit ce974a9

Please sign in to comment.