Repository navigation
Expand file tree
/
Copy pathregistration.php
More file actions
65 lines (58 loc) · 1.92 KB
/
Copy pathregistration.php
File metadata and controls
65 lines (58 loc) · 1.92 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
64
65
<?php
require_once("../PHP-Project/DataBaseUsers.php");
require_once("../PHP-Project/component.php");
require_once("../PHP-Project/operation.php");
session_start();
$con = CreateDB1();
if (isset($_POST["RegisterBtn"])){
checkDataReg();
}
if (isset($_POST["LoginBtn"])){
checkDataLog();
}
/*function checkData(){
$con = mysqli_connect('localhost','root','','users');
$userName = textBoxValue("user");
$password = textBoxValue("password");
$s = "select * from users where userName = '$userName' ";
$result = mysqli_query( $con , $s);
//$num = mysqli_num_rows($result);
$row = mysqli_fetch_assoc($result);
}*/
function checkDataReg(){
$con = mysqli_connect('localhost','root','','users');
$userName = textBoxValue("user");
$password = textBoxValue("password");
$s = "select * from users where userName = '$userName' ";
$result = mysqli_query( $con , $s);
//$num = mysqli_num_rows($result);
$row = mysqli_fetch_assoc($result);
if ($row ) {
echo "User is taken, Login instead";
//TextNode("error","User is taken, Login instead");
}
else{
$sql = "INSERT INTO users(userName,password)
VALUES('$userName','$password')";
if (mysqli_query($GLOBALS['con'],$sql)){
header('location:index.php');
}
}
}
function checkDataLog(){
$con = mysqli_connect('localhost','root','','users');
$userName = textBoxValue("user");
$password = textBoxValue("password");
$s = "select * from users where userName = '$userName' AND password ='$password'";
$result = mysqli_query( $con , $s);
//$num = mysqli_num_rows($result);
$row = mysqli_fetch_assoc($result);
if ($row ) {
header('location:index.php');
}
else{
//"<script>window.togglePopUp();</script>";
//TextNode('error','User Not found, Register Instead !');
echo "User not found, Register Instead";
}
}