-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsemester.php
More file actions
32 lines (24 loc) · 1.09 KB
/
semester.php
File metadata and controls
32 lines (24 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
<?php
require "dbConfig.php";
$db = new dbConfig();
$newconnection=mysqli_connect($db->host,$db->username,$db->password,$db->databasename);
if(isset($_POST['username']) && isset($_POST['start_date'])){
$uname = $_POST['username'];
$quantity = $_POST['quantity'];
$start_date = $_POST['start_date'];
$end_date = $_POST['end_date'];
$meddelande = $_POST['meddelande'];
$value ='0';
$sql = "select * from semestertabell where username = '" . $uname . "'";
$result = mysqli_query($newconnection,$sql);
$row = mysqli_fetch_assoc($result);
if(mysqli_num_rows($result) == 0){
$sql = "INSERT INTO semestertabell ( username, quantity, start_date, end_date, meddelande, value)
VALUES ( '$uname','$quantity', '$start_date', '$end_date', '$meddelande','$value')";
$result = mysqli_query($newconnection,$sql);
if($result)
echo "Inserted successfully";
else
echo "Failed to insert to semestertabell";
}else echo "You already have an ongoing activity";
}else echo "You need to choose an available start date";