4
<title>Extreme Dating - Create User</title>
5
<link rel="stylesheet" type="text/css" href="css/main.css"/>
6
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
10
if(isset($_POST['hiddenStuff']) && $_POST['hiddenStuff'] == "Something Strange") {
11
$password = sha1($_POST['passwd']."salt");
12
//If there is a $_POST that indicates that the add userscript should be run.
15
if(isset($_FILES["image"]["tmp_name"])){
16
$tmpFile = $_FILES["image"]["tmp_name"];
17
//echo $_FILES["image"]["tmp_name"];
18
$handle = fopen($tmpFile,"r");
19
$fileSize = $_FILES['image']['size'];
22
//echo $_FILES["image"]["tmp_name"];
23
$output = fread($handle, filesize($tmpFile));
24
$output = base64_encode ($output);
29
while (($buffer = fgets($handle, 4096)) !== false) {
30
//$buffer = str_replace("&", "&", $buffer);
31
//$buffer = str_replace("<", "<", $buffer);
32
//$buffer = str_replace(">", ">", $buffer);
36
$output .= "Error: unexpected fgets() fail\n";
44
if (isset($_SESSION['userType']) && $_POST['isSuperUser'] == true && $_SESSION['userType'] == 1) {
45
$query = "INSERT INTO Users (
59
'{$_POST['firstName']}',
60
'{$_POST['surName']}',
67
$query = "INSERT INTO Users (
80
'{$_POST['firstName']}',
81
'{$_POST['surName']}',
89
} catch (PDOException $err) {
92
echo "<body> <h1> New user added! </h1> </body>";
94
header("Location:./index.php");
101
<h1> Create a new user </h1>
103
<form action="./adduser.php" method="POST" enctype="multipart/form-data">
106
if(isset($_SESSION['userType']) && $_SESSION['userType'] == 1 ) {
107
//you are a superuser!
108
//you can add other superusers.
111
<td> <label for="user"> Is the user a Super User? </label> </td>
112
<td> <input type="checkbox" name="isSuperUser" id="super" /> </td>
118
<td> <label for="name"> User Name </label> </td>
119
<td> <input type="input" name="name" id="name" /> </td>
122
<td> <label for="passwd"> Password </label> </td>
123
<td> <input type="password" name="passwd" id="passwd" /> </td>
126
<td> <label for="firstname"> First Name </label> </td>
127
<td> <input type="input" name="firstName" id="firstname" /> </td>
130
<td> <label for="surname"> Sur Name </label> </td>
131
<td> <input type="input" name="surName" id="surname" /> </td>
134
<td> <label for="email"> E-mail </label> </td>
135
<td> <input type="input" name="eMail" id="email" /> </td>
138
<td> <label for="city"> City </label> </td>
139
<td> <input type="input" name="city" id="city" /> </td>
142
<td> <label for="file"> City </label> </td>
143
<td> <input type="file" name="image" id="image" /> </td>
146
<td><input name="hiddenStuff" value="Something Strange" type="hidden"/></td>
147
<td><input id="inputbutton1" type="submit" action="./adduser.php" value="Registera mig"/></td>