-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsignup.php
91 lines (75 loc) · 1.96 KB
/
signup.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
<?php
require_once 'header.php';
echo <<<_END
<script>
function checkUser(user)
{
if(user.value=='')
{
O('info').innerHTML=''
return
}
params = "user="+user.value
request =new ajaxRequest()
request.open("POST","checkuser.php",true)
request.setRequsetHeader("Content-type","application/x-www-form-urlencoded")
request.setRequsetHeader("Content-length",params.length)
request.setRequsetHeader("Connection","close")
request.onreadystatechange=function(){
if(this.readyState==4 && this.status=200 && this.responseText!=null)
O('info').innerHTML = this.responseText
}
request.send(params)
}
function ajaxRequest()
{
try{var request = new XMLHttpRequest()}
catch(e1){
try {request=new ActiveXObject("Msxm12.XMLHTTP")}
catch(e2)
{
try {request = new ActiveXObject("Microsoft.XMLHTTP")}
catch(e3){request=false}
}
}
return request
}
</script>
<div class='main'><h3>Please enter your details to sign up</h3>
_END;
$error= $user =$pass="";
if(isset($_SESSION['user'])) destorySession();
if(isset($_POST['user']))
{
$user = sanitizeString($_POST['user']);
$pass = sanitizeString($_POST['pass']);
if($user==""||$pass=="")
{
$error= "Not all fields were entered<br><br>";
}
else
{
$result = queryMysql("SELECT * FROM members WHERE user='$user'");
if($result->num_rows)
$error="That username already exists<br><br>";
else
{
queryMysql("INSERT INTO members VALUES('$user','$pass')");
die("<h4>Acconunt created </h4> Please log in.<br><br>");
}
}
}
echo <<<_END
<form method ='post' action='signup.php'>$error
<span class ='fieldname'>Username</span>
<input type ='text' maxlength='16' name ='user' value='$user'
onBlur ='checkUser(this)'><span id='info'></span><br>
<span class ='fieldname'>Password</span>
<input type='text' maxlength ='16' name='pass' value='$pass'><br>
_END;
?>
<span class='fieldname'> </span>
<input type ='submit' value='Sign up'>
</form></div><br>
</body>
</html>