forked from lite-david/BITStrade
-
Notifications
You must be signed in to change notification settings - Fork 0
/
join.php
48 lines (42 loc) · 1022 Bytes
/
join.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
<?php
session_start();
if(isset($_POST['submit']))
{
function validate($a)
{
$a=trim($a);
$a=strip_tags($a);
$a=mysql_real_escape_string($a);
return $a;
}
$nick=validate($_POST['nick']);
$password=validate($_POST['password']);
if( $nick && $password)
{
$connect=mysql_connect("127.0.0.1","root","") or die("Could not connect");
mysql_select_db("bitstrade");
$signup=mysql_query("SELECT * FROM users WHERE nick='$nick'");
$a=mysql_fetch_assoc($signup);
while($a=mysql_fetch_assoc($signup))
{
$dbnick = $a['nick'];
$dbpassword = $a['password'];
}
if($dbnick == $nick)
{
header("location:signup.php?notify=Nick already exists.Give a new one");
}
else
{
mysql_query("INSERT INTO users(nick,password) VALUES ('$nick','$password')");
$_SESSION['nick']=$nick;
$_SESSION['password']=$password;
header("location:members.php");
}
}
else
{
header("location:index.php? notify=Please fill both fields");
}
}
?>