-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathregistration.php
More file actions
63 lines (61 loc) · 1.54 KB
/
registration.php
File metadata and controls
63 lines (61 loc) · 1.54 KB
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
<?php
function registerUser ($username, $password){
$db = mysqli_connect( 'localhost', 'root', '', 'webtop' );
if (mysqli_connect_errno() != 0){
echo "Could not establish connection to database";
}
else {
//The actual function
$sqlUserName = "Select * FROM user WHERE Username = '$username'";
$result = $db->query($sqlUserName);
if($result && $result->num_rows)
echo "This username already exists";
else{
$sqlRegData =
"Insert INTO user (Username, Password)
values ('$username', '$password')";
$db->query($sqlRegData);
echo "User " . $username . " is registered. I think.";
}
}
}
?>
<html>
<head></head>
<body>
<form action="webtop.php?register" method="post">
<fieldset>
<legend>Registration</legend>
<table>
<tr>
<td>Username:</td>
<td><input type="text" name="newusername"></td>
</tr>
<tr>
<td>Password:</td>
<td><input type="password" name="newuserpassword"></td>
</tr>
<!--
Add all the other fields. This is boring.
<tr>
<td>First Name:</td>
<td><input type="text" name="vorname"></td>
<tr>
<tr>
<td>First Name:</td>
<td><input type="text" name="vorname"></td>
<tr>
<tr>
<td>Last Name:</td>
<td><input type="text" name="nachname"></td>
<tr>
-->
</table>
<p><input type="submit" value="Register">
<input type="reset" name="Reset"></p>
</fieldset>
</form>
<?php
if(isset($_POST['newusername']) && isset($_POST['newuserpassword']))
registerUser($_POST['newusername'], md5($_POST['newuserpassword']));
?>