-
Notifications
You must be signed in to change notification settings - Fork 0
/
register.php
123 lines (120 loc) · 4.25 KB
/
register.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
<?php include 'header/header.php';
if (logged_in ()) header('Location: index.php');
if (!isset($_POST) || sizeof($_POST) == 0) $page_valid = false; ?>
<form class = "form-horizontal" method = "POST" action = "register.php">
<div class = "control-group">
<label class = "control-label" for = "nume">Nume</label>
<div class = "controls">
<input type = "text" id = "nume" name = "nume" placeholder = "Nume" value = <?php if (param_exists_POST("nume")) echo $_POST['nume']; else echo ""; ?> >
</div>
</div>
<div class = "control-group">
<label class = "control-label" for = "prenume">Prenume</label>
<div class = "controls">
<input type = "text" id = "prenume" name = "prenume" placeholder = "Prenume" value = <?php if (param_exists_POST("prenume")) echo $_POST['prenume']; else echo ""; ?>>
</div>
</div>
<div class = "control-group">
<label class = "control-label" for = "email">Email</label>
<div class = "controls">
<input type = "text" id = "email" name = "email" placeholder = "Email" value = <?php if (param_exists_POST("email")) echo $_POST['email']; else echo ""; ?>>
<?php
if (isset($_POST) && sizeof($_POST) != 0)
if (!param_exists_post("email"))
{
validation_error ("Email-ul este obligatoriu !");
$page_valid = false;
}
else
if (!valid_email ($_POST['email']))
{
validation_error("Emailul nu este valid !");
$page_valid = false;
}
else
{
$picked_email = mysql_fetch_assoc(mysql_query("select * from users where email = '" . $_POST['email'] . "'"));
if (!empty($picked_email))
{
validation_error('Adresa ' . $_POST['email'] . ' este folosita deja');
$page_valid = false;
}
//echo "select * from users where email = '" . $_POST['email'] . "'";
}
?>
</div>
</div>
<div class = "control-group">
<label class = "control-label" for = "username">Username</label>
<div class = "controls">
<input type = "text" id = "username" name = "username" placeholder = "Username" value = <?php if (param_exists_POST("username")) echo $_POST['username']; else echo ""; ?>>
<?php
if (isset($_POST) && sizeof($_POST) != 0)
{
if (!param_exists_post("username"))
{
validation_error ("Username-ul este obligatoriu !");
$page_valid = false;
}
if (user_exists($_POST['username']))
{
validation_error("Username-ul este deja folosit !");
$page_valid = false;
}
}
?>
</div>
</div>
<div class = "control-group">
<label class = "control-label" for = "password">Password</label>
<div class = "controls">
<input type = "password" id = "password" name = "password" placeholder = "Password">
<?php
if (isset($_POST) && sizeof($_POST) != 0)
if (!param_exists_post("password"))
{
validation_error ("Parola este obligatorie !");
$page_valid = false;
}
?>
</div>
</div>
<div class = "control-group">
<label class = "control-label" for = "password2">Password</label>
<div class = "controls">
<input type = "password" id = "password2" name = "password2" placeholder = "Password">
<?php
if (isset($_POST) && sizeof($_POST) != 0)
if (!param_exists_post("password2"))
{
validation_error ("Reintroducerea parolei este obligatorie !");
$page_valid = false;
}
else
if ($_POST['password'] != $_POST['password2'])
{
validation_error ("Ati reintrodus gresit parola !");
$page_valid = false;
}
?>
</div>
</div>
<div class = "control-group">
<div class = "controls">
<input type = "submit" class = "btn" value = "Register">
</div>
</div>
</form>
<?php
if ($page_valid == true)
{
mysql_query("insert into users (username, password, email, first_name, last_name)
values ('".$_POST["username"]."' , '".sha1($_POST["password"])."' , '".$_POST["email"]."' , '".$_POST["prenume"]."'
, '".$_POST["nume"]."')");
echo '<label class = "text-success">A fost introdusa o noua linie in baza de date !</label>';
usleep(300000);
header('Location: login.php?username=' . $_POST['username'] . '&password='.$_POST['password']);
//echo 'Location: login.php?username=' . $_POST['username'] . '&password='.$_POST['password'];
}
?>
<?php include 'footer/footer.php' ?>