-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwork.php
More file actions
40 lines (37 loc) · 1.09 KB
/
work.php
File metadata and controls
40 lines (37 loc) · 1.09 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
<?php
//need this to connect to database.
include('connetDB.php');
//need this to continue session.
session_start();
//checks to see if the user has signed.
if(!isset($_SESSION['user_id']) || !isset($_SESSION['logged_in']) || $_SESSION['type'] != "renter"){
//will send user back to sign-in.
header('location:rentSign.php');
exit;
}
//if user is signed in.
else{
if($_POST['sb']){
//stores the session's user name in variable.
$usr = $_SESSION['user_id'];
$workId = rand(11,100000000);
$d = $_POST['des'];
$nam =$_POST['item'];
//stores query in variable.
$q = 'INSERT INTO rentWork(rentUser,id) VALUES(?,?);
INSERT INTO workOrder(id,name,des) VALUES(?,?,?);';
//prepares sql statement.
$statement = $conn->prepare($q);
//bind the values to the statement.
$statement->bindValue(1,$usr,PDO::PARAM_STR);
$statement->bindValue(2,$workId,PDO::PARAM_STR);
$statement->bindValue(3,$workId,PDO::PARAM_STR);
$statement->bindValue(4,$nam,PDO::PARAM_STR);
$statement->bindValue(5,$d,PDO::PARAM_STR);
//executes the sql statement.
$statement->execute();
header('location:workOrder.php');
die;
}
}
?>