-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsignUpForm.php
More file actions
60 lines (53 loc) · 2.21 KB
/
signUpForm.php
File metadata and controls
60 lines (53 loc) · 2.21 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="stylesheet" type="text/css" href="StyleSheet.css" />
<title>TV Trading Co., Ltd.</title>
</head>
<body>
<div id="title">
<h1>TV Trading Co., Ltd.</h1>stalking the beauty of trade since time immemorial .....
</div>
<hr>
<br />
<?php
$name = $_POST['name'];
$email = $_POST['email'];
$password = $_POST['password'];
$file = file_get_contents('./config.txt', FILE_USE_INCLUDE_PATH);
$str = preg_split("/[\s,\n]+/", $file);
$sql_host = $str[1];
$sql_user = $str[3];
$sql_password = $str[5];
$sql_db = $str[7];
$conn = mysqli_connect($sql_host, $sql_user, $sql_password, $sql_db);
if (mysqli_connect_errno()) {
echo "<font color='white'>Failed to connect to MySQL: " . mysqli_connect_error()."</font>";
}
$query = "SELECT `name` FROM `users` WHERE `email` = \"$email\"";
#echo($query);
$result = mysqli_query($conn, $query);
if(mysqli_num_rows($result) == 0) {
$query = "INSERT INTO `users` (name, email, password, balance) VALUES (\"$name\", \"$email\", \"$password\", 50000)";
$result = mysqli_query($conn, $query);
echo("<div id='transaction_status'><font color='green'>Player registration successful!</font></div>");
header('Location:login.html');
}
else {
echo("
<div id='sign_up_form'>
Email already exists! <br /> <br />
<form action='signUpForm.php' method='post'>
Name: <input type='text' name='name' />
Email: <input type='email' name='email' />
Password: <input type='password' name='password' />
<input type='submit' value='Sign Up' />
</form>
</div>
");
}
mysqli_close($conn);
?>
</body>
</html>