forked from evannwong/471-WFH-Website
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadmin_add_rules.php
26 lines (23 loc) · 909 Bytes
/
admin_add_rules.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
<?php
session_start();
// Change this to your connection info.
$DATABASE_HOST = 'localhost';
$DATABASE_USER = 'shardarq_471p';
$DATABASE_PASS = 'password';
$DATABASE_NAME = 'shardarq_db_connect';
// Try and connect using the info above.
$con = mysqli_connect($DATABASE_HOST, $DATABASE_USER, $DATABASE_PASS, $DATABASE_NAME);
if ( mysqli_connect_errno() ) {
// If there is an error with the connection, stop the script and display the error.
exit('ADMIN: Failed to connect to MySQL: ' . mysqli_connect_error());
}
if ( !isset($_POST['descr'],$_POST['perm']) ) {
// Could not get the data that should have been sent.
exit('ADMIN: Please fill all fields!');
}
$userid=$_SESSION['id'];
$Description = $_POST["descr"];
$Permission = $_POST["perm"];
mysqli_query($con,"INSERT INTO `rules` (`id`, `Description`, `Permission`) VALUES ('', '$Description', '$Permission')");
header('Location: admindash.php');
?>