-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreaterc.php
More file actions
73 lines (56 loc) · 1.71 KB
/
Copy pathcreaterc.php
File metadata and controls
73 lines (56 loc) · 1.71 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
66
67
68
69
70
71
72
73
<?php
session_start();
$rcname="";
$contact="";
$district="";
$address="";
$errors = array();
$usern= htmlspecialchars($_SESSION["username"]);
/*
CREATE DATABASE CONNECTION
-------------*/
$db = mysqli_connect('localhost', 'root', '', 'care');
if (isset($_POST['reg_user'])){
// receive all input values from the form
$rcname=mysqli_real_escape_string($db,$_REQUEST['rcname']);
$contact=mysqli_real_escape_string($db,$_REQUEST['contact']);
$district=mysqli_real_escape_string($db,$_REQUEST['district']);
$address=mysqli_real_escape_string($db,$_REQUEST['address']);
// Number checks for length 10
if(strlen((string)$contact)!=10)
{
array_push($errors, "Number must have 10 digits");
}
//check district
if ($district == 'Select district') {
array_push($errors, "Please select your place");
}
if (count($errors) == 0)
{
/* Storing values*/
$sql="INSERT INTO rc_register (user_name, rcname, contact, district, address) VALUES ('$usern','$rcname','$contact','$district','$address')";
mysqli_query($db,$sql);
header('location:rcuserhome.php');
}
}
//ADD ITEMS
if (isset($_POST['additem']))
{
$item=mysqli_real_escape_string($db,$_REQUEST['item']);
$desc=mysqli_real_escape_string($db,$_REQUEST['desc']);
$qty=mysqli_real_escape_string($db,$_REQUEST['qty']);
$id=$_GET['id'];
echo "$id";
$add = "INSERT INTO rc_stock (rc_id,user_name,item,description,qty) VALUES ('$id','$usern','$item','$desc','$qty')";
mysqli_query($db,$add);
header('location:rcuseritem.php');
}
//DELETE ITEM
// if($_GET['itm_no']!='')
// {
// $item_no= $_GET['itm_no'];
// $itmdelete="DELETE FROM rc_stock WHERE item_no='$item_no'";
// mysqli_query($db,$itmdelete);
// header('location:rcuseritem.php');
// }
?>