-
Notifications
You must be signed in to change notification settings - Fork 4
/
updateworker.php
43 lines (33 loc) · 1.16 KB
/
updateworker.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
<?php
require 'connect.php';
// Get the posted data.
if ($_SERVER["REQUEST_METHOD"] == "POST") {
//identifiants mysql
$servername = "localhost:50";
$username = "root";
$password = "";
$dbname = "elmouna";
if (isset($_GET['id'])) {
if (!empty($_POST)) {
// This part is similar to the create.php, but instead we update a record and not insert
$id = isset($_GET['id']) ? $_GET['id'] : '';
$username = isset($_POST['username']) ? $_POST['username'] : '';
$pass= isset($_POST['pass']) ? $_POST['pass'] : '';
$type = isset($_POST['type']) ? $_POST['type'] : '';
}
// Update.
$sql = "UPDATE worker SET username = ?,pass = ?,type = ? WHERE id = ? ";
$statement = $conn->prepare($sql);
//$statement = mysqli_query($conn, ); // lerrur hne
//$statement->execute();
//Associer les valeurs et exécuter la requête d'insertion
$statement->bind_param( 'ssss', $username, $pass, $type, $id);
if($statement->execute()){
print "ADD Worker " . $username;
}else{
//print $mysqli->error;
}
}
}
header('Location: datatable2.php');
?>