-
Notifications
You must be signed in to change notification settings - Fork 0
/
admin_brand_adder.php
54 lines (49 loc) · 1.76 KB
/
admin_brand_adder.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
<?php
include('dbconnect.php');
$b_title = $_POST['b_name'];
$category=$_POST['category'];
$password = md5($_POST['password']);
$mobile = $_POST['mobile'];
$address1 = $_POST['address1'];
$address2 = $_POST['address2'];
$name = "/^[A-Z][a-zA-Z ]+$/";
$emailValidation = "/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9]+(\.[a-z]{2,4})$/";
$number = "/^[0-9]+$/";
echo "zaa";
echo $b_title;
echo $category;
if (empty($category)) {
echo "<div class='alert alert-danger alert-dismissible' role='alert'><button type='button' class='close' data-dismiss='alert' aria-label='Close'><span aria-hidden='true'>×</span></button>Please fill all the fields!</div>";
exit(0);
} else if (empty($b_title)) {
echo "<div class='alert alert-danger alert-dismissible' role='alert'><button type='button' class='close' data-dismiss='alert' aria-label='Close'><span aria-hidden='true'>×</span></button>Please fill all the fields!</div>";
exit(0);
} else {
if (!preg_match($name, $b_title)) {
echo "
<div class='alert alert-warning'>
<a href='#' class='close' data-dismiss='alert' aria-label='close'>×</a>
<b>Name: $b_title is not valid..!</b>
</div>
";
exit();
} else {
echo "
<div class='alert alert-warning'>
<a href='#' class='close' data-dismiss='alert' aria-label='close'>×</a>
<b>The product has been added</b>
</div>
";
$sql = "INSERT INTO brands (brand_title,cat_id) VALUES ('$b_title','$category')";
$run_query = mysqli_query($conn, $sql);
if ($run_query) {
echo "
<div class='alert alert-success'>
<a href='#' class='close' data-dismiss='alert' aria-label='close'>×</a>
Click <b><a href='index.php'>here</a></b> to go back to the main page.
</div>
";
}
}
}
?>