-
Notifications
You must be signed in to change notification settings - Fork 1
/
reg.php
62 lines (60 loc) · 1.56 KB
/
reg.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
<?php
session_start();
include('connection.php');
$nume = $_POST['nume'];
$prenume = $_POST['prenume'];
$email = $_POST['email'];
$fac = $_POST['facultate'];
$matricol = $_POST['matricol'];
$semestru = $_POST['sem'];
$username = $_POST['username'];
$password = md5($_POST['pass']);
if($nume == '') {
$errmsg_arr[] = 'Nu ai introdus nume';
$errflag = true;
}
if($prenume == '') {
$errmsg_arr[] = 'Nu ai introdus prenume';
$errflag = true;
}
if($email == '') {
$errmsg_arr[] = 'Nu ai introdus email';
$errflag = true;
}
if($fac == '') {
$errmsg_arr[] = 'Nu ai introdus facultatea';
$errflag = true;
}
if($matricol == '') {
$errmsg_arr[] = 'Nu ai introdus matricol';
$errflag = true;
}
if($semestru == '') {
$errmsg_arr[] = 'Nu ai introdus semestrul';
$errflag = true;
}
if($username == '') {
$errmsg_arr[] = 'Nu ai introdus username';
$errflag = true;
}
if($password == '') {
$errmsg_arr[] = 'Nu ai introdus parola';
$errflag = true;
}
if($errflag) {
$_SESSION['ERRMSG_ARR'] = $errmsg_arr;
session_write_close();
header("location: signup.php");
exit();
}
$result = mysql_query("SELECT max(idaccount) AS maxid FROM account");
$row = mysql_fetch_array($result);
$newid = $row["maxid"] + 1;
$result2 = mysql_query("SELECT max(idstudent) AS maxid FROM student");
$row2 = mysql_fetch_array($result2);
$newid2 = $row2["maxid"] + 1;
mysql_query("INSERT INTO account VALUES ('$newid','$username','$password','S')");
mysql_query("INSERT INTO student VALUES ('$newid2','$nume','$prenume','$email','$matricol','$semestru',101,'$newid')");
header("location: index.html");
mysql_close($con);
?>