3v4l.org

run code in 300+ PHP versions simultaneously
<?php include "connect.php"; session_start(); date_default_timezone_set('UTC'); if($_SESSION['user']){ } else{ header("location:index.php"); } if($_SERVER['REQUEST_METHOD'] = "POST") //Added an if to keep the page secured { $details = $con->real_escape_string($_POST['details']); $time = strftime("%X");//time $date = strftime("%B %d, %Y");//date $decision ="no"; $con->select_db("main") or die("Cannot connect to database"); //Connect to database foreach($_POST['public'] as $each_check) //gets the data from the checkbox { if($each_check !=null ){ //checks if the checkbox is checked $decision = "yes"; //sets teh value } } $con->query("INSERT INTO list (details, date_posted, time_posted, public) VALUES ('$details','$date','$time','$decision')"); //SQL query header("location: home.php"); } else { header("location:home.php"); //redirects back to hom } ?>

preferences:
87.17 ms | 402 KiB | 5 Q