forked from adeelahmedmirza/groupChat---PHP-MySQL
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
57 lines (44 loc) · 1.02 KB
/
index.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
<?php
$con = mysqli_connect('localhost','root','');
mysqli_select_db($con, 'final-group-chat');
if(isset($_POST['insertUser']))
{
if($_POST['username'] != "")
{
$userName = $_POST['username'];
$query = "SELECT * FROM user WHERE user_name = '".$userName."'";
$result = mysqli_query($con, $query);
if(mysqli_num_rows($result)>0)
{
header('Location: groups.php?name='.$userName);
}
else
{
$query1 = "INSERT INTO `user` (`user_name`) VALUES ('$userName')";
if(!mysqli_query($con,$query1)){
echo "Error: Unable to Insert NewUser";
}
else{
echo "User Entered successfully";
}
}
}
else
{
echo "Error: Enter Name";
}
}
?>
<!DOCTYPE html>
<html>
<head>
<title>USER</title>
</head>
<body>
<form action="index.php" method="POST">
<label for="username">Enter Your Name:</label></br></br>
<input type="text" name="username" id="username"></br></br>
<button name="insertUser" type="submit">Submit</button>
</form>
</body>
</html>