Commit 337dc2cc by sopham

add userID to database

parent 5e5d4c66
Showing with 8 additions and 38 deletions
<?php <?php
session_start();
include_once "dbconnection.php"; include_once "dbconnection.php";
$query = "INSERT INTO toDoList (task) VALUES (?) "; //$query = "INSERT INTO toDoList (task) VALUES (?) ";
$query1 = "INSERT INTO toDoList (task, userID) VALUES (?,?) ";
$query = $link->prepare($query); $query1 = $link->prepare($query1);
$query -> bind_param('s', $_POST['task']); $query1 -> bind_param('si', $_POST['task'], $_SESSION['id']);
$query -> execute(); //$query -> bind_param('si', $_POST['task']);
$query1 -> execute();
$last_id = mysqli_insert_id($link); $last_id = mysqli_insert_id($link);
echo $last_id; echo $last_id;
$query -> close(); $query1 -> close();
$link -> close(); $link -> close();
?> ?>
<?php
error_reporting(0);
$user = $_POST['username'];
$pass = $_POST['password'];
//login
if(isset($_POST['submit'])){
if($user=="admin" && $pass=="admin"){
header('Location:index.php');
session_name($user);
session_start();
}
else{
echo "Wrong Username or/and Password";
}
}
//logout
if(isset($_POST['logout'])) {
session_name($user);
session_start();
session_unset();
session_destroy();
session_write_close();
setcookie(session_name(), '', 0,'/');
session_regenerate_id(true);
header('Location: login_page.php');
exit();
}
?>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment