-
Notifications
You must be signed in to change notification settings - Fork 0
/
rego.php
41 lines (34 loc) · 1.2 KB
/
rego.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
<?php
// Start session
if(!session_id()){
session_start();
}
// Include the database config file
include ( 'db.php' );
if ( isset( $_SESSION["loggedin"] ) ){
echo "<script>window.location='index.php'</script>";
}
$email = isset( $_POST[ 'email' ] )? strip_tags( trim( $_POST[ 'email' ] )): '' ;
$password = isset( $_POST[ 'password' ] )? strip_tags( trim( $_POST[ 'password' ] )): '' ;
if ( $password !== '' && $email !== '' ){
$sql = "INSERT INTO customers ( `email`, `password`, `created` ) VALUES ( '$email', '$password', 'NOW()')";
if( $conn->query($sql) == TRUE ){
// register vars
// get id
$_SESSION['uid'] = $conn->lastInsertId($sql);
$_SESSION["first_name"] = '';
$_SESSION["last_name"] = '';
$_SESSION["email"] = $email;
$_SESSION["loggedin"] = TRUE;
$_SESSION["access"] = 0;
$_SESSION["address"] = '';
$_SESSION["phone"] = '';
echo "<script>alert('Account successfully added!'); window.location='index.php'</script>";
} else {
//add failed attempt to counter
echo "<script>alert('Account creation failed!'); window.location='registration.php'</script>";
}
} else {
echo "<script>alert('Account creation failed!'); window.location='registration.php'</script>";
}
?>