-
Notifications
You must be signed in to change notification settings - Fork 0
/
validsign.php
46 lines (39 loc) · 1.12 KB
/
validsign.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<?php
//Function To Validate Data
function validate($data)
{
$data= trim(stripslashes(htmlspecialchars($data)));
return $data;
}
//Display Error
$usernameN=$emailN=$passwordN="";
//Empty Fields And Validation
if(!$_POST["usernameN"]){
$nameerror="Please enter Username.<br>Do not include whitespaces in your username.<br>";
}
else{
$usernameN=validate($_POST["usernameN"]);
}
if(!$_POST["emailN"]){
$emailerror="Please enter your Email<br>";
}
else{
$emailN=validate($_POST["emailN"]);
}
if(!$_POST["passwordN"]){
$passerror="please enter your Password.<br>";
}
else{
$passwordN=validate($_POST["passwordN"]);
}
//Comparing Credentials
if($usernameN && $emailN && $passwordN){
$passwordN=password_hash($passwordN,PASSWORD_DEFAULT);
$queryN="INSERT INTO users (id,username,email,password)
VALUES (NULL ,'$usernameN','$emailN','$passwordN')";
if(mysqli_query($conn,$queryN)){
$_SESSION['loggedin']=TRUE;
header('location:'.$_SESSION['redirect']);
}
}
?>