-
Notifications
You must be signed in to change notification settings - Fork 0
/
signup.php
37 lines (32 loc) · 1.22 KB
/
signup.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
<?php
session_start();
require_once 'db.php';
require_once 'library.php';
if (isset($_POST['user_email']))
{
$email = htmlspecialchars($_POST['user_email']);
$password = htmlspecialchars($_POST['user_password']);
$confirm = htmlspecialchars($_POST['confirm_password']);
$username = htmlspecialchars($_POST['username']);
$isvalidemail = checkemail($email);
$isvalidpsswd = checkpassword($password, $confirm);
$isemailtaken = isemailtaken($email);
$password = sha1($password);
if ($isvalidemail == 0){
header('Location:index.php'); mysql_close($db); exit();}
if ($isvalidpsswd == 0){
header('Location:index.php'); mysql_close($db); exit();}
if ($isemailtaken == 0) {
header('Location:index.php'); mysql_close($db); exit();}
$query = "INSERT INTO users (email, password, username)
VALUES ('$email', '$password', '$username')";
$result = mysql_query($query) or die(mysql_error());
$query = "INSERT INTO user_selections (state, email, candidate)
VALUES ('DC', '$email', 'DONEGAN')";
$result = mysql_query($query) or die(mysql_error());
$_SESSION['user'] = $email;
setcookie('user',$email,314496000);
header('Location:home.php');
}
mysql_close($db);
?>