-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.php
69 lines (63 loc) 路 2.12 KB
/
server.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
<?php
session_start();
$conn = mysqli_connect('localhost','root','','ecommerce') or die(mysqli_error($conn));
// add new client
if(isset($_POST['save'])){
$first = $_POST['firest'];
$last = $_POST['last'];
$email = $_POST['email'];
$adresse = $_POST['adresse'];
$telephone = $_POST['telephone'];
$password = $_POST['password'];
$stmt = $conn->prepare("select email FROM client where email='".$email."'");
$stmt->execute();
$result = $stmt->get_result();
$row_in4 = $result->fetch_assoc();
$array4 = $row_in4['email'];
if($array4 == $email){
$_SESSION['validate'] = true;
header("location: sin-up.php");
}
else{
$req = "INSERT INTO client (nom,prenom,adresse,telephone,email,pass) values ('$first','$last','$adresse','$telephone','$email','$password')";
$res = mysqli_query($conn, $req);
$_SESSION['button'] = true;
$_SESSION['user'] = $first;
$_SESSION['admin'] = true;
header("location: index.php");
}
}
if(isset($_POST['save-in'])){
$email = $_POST['email'];
$password = $_POST['password'];
// user
$stmt = $conn->prepare("select nom FROM client where email='".$email."'");
$stmt->execute();
$result = $stmt->get_result();
$row_in3 = $result->fetch_assoc();
$array3 = $row_in3['nom'];
$_SESSION['user'] = $array3;
// email
$stmt = $conn->prepare("select email FROM client where email='".$email."'");
$stmt->execute();
$result = $stmt->get_result();
$row_in = $result->fetch_assoc();
$array = $row_in['email'];
// password
$stmt = $conn->prepare("select pass FROM client where pass='".$password."'");
$stmt->execute();
$result = $stmt->get_result();
$row_in2 = $result->fetch_assoc();
$array2 = $row_in2['pass'];
if( $password==$array2 && $email==$array){
$_SESSION['button'] = true;
// $_SESSION['user'] = "karim";
header("location: index.php");
}
else{
$_SESSION['button'] = false;
$_SESSION['validate_in'] = true;
header("location: sgin-in.php");
}
}
?>