fork download
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title> PHP BASIC</title>
  5. </head>
  6. <body>
  7. <h2>HELLO/h2>
  8. <?php
  9. echo “hello”;
  10. ?>
  11. </body>
  12. </html>
  13.  
  14. // your code goes here
Success #stdin #stdout #stderr 0.03s 25684KB
stdin
<?php
session_start();
error_reporting(0);
include('includes/dbconnection.php');
if (strlen($_SESSION['clientmaid']) == 0) {
    header('location:logout.php');
} else {
    if (isset($_POST['submit'])) {
        $name = $_POST['name'];
        $age = intval($_POST['age']);
        $gender = $_POST['gender'];
        $crimeType = $_POST['crimeType'];
        $description = $_POST['description'];
        // Insert new offender into the database
        $sql = "INSERT INTO tblcriminals(Name, Age, Gender, CrimeType, Description) VALUES (:name, :age, :gender, :crimeType, :description)";
        $query = $dbh->prepare($sql);
        $query->bindParam(':name', $name, PDO::PARAM_STR);
        $query->bindParam(':age', $age, PDO::PARAM_INT);
        $query->bindParam(':gender', $gender, PDO::PARAM_STR);
        $query->bindParam(':crimeType', $crimeType, PDO::PARAM_STR);
        $query->bindParam(':description', $description, PDO::PARAM_STR);
        if ($query->execute()) {
            echo '<script>alert("New offender added successfully.")</script>';
            echo "<script>window.location.href='view_criminals.php'</script>";
        } else {
            echo '<script>alert("Error adding offender. Please try again.")</script>';
        }
    }
}
?>
<!DOCTYPE HTML>
<html>
<head>
    <title>Add New Offender</title>
    <link href="css/bootstrap.min.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<div class="container">
    <h2>Add New Offender</h2>
    <form method="post">
        <div class="form-group">
            <label for="name">Name:</label>
            <input type="text" class="form-control" id="name" name="name" required>
        </div>
        <div class="form-group">
            <label for="age">Age:</label>
            <input type="number" class="form-control" id="age" name="age" required>
        </div>
        <div class="form-group">
            <label for="gender">Gender:</label>
            <select class="form-control" id="gender" name="gender" required>
                <option value="">Select Gender</option>
                <option value="Male">Male</option>
                <option value="Female">Female</option>
                <option value="Other">Other</option>
            </select>
        </div>
        <div class="form-group">
            <label for="crimeType">Crime Type:</label>
            <input type="text" class="form-control" id="crimeType" name="crimeType" required>
        </div>
        <div class="form-group">
            <label for="description">Description:</label>
            <textarea class="form-control" id="description" name="description" rows="4" required></textarea>
        </div>
        <button type="submit" name="submit" class="btn btn-primary">Add Offender</button>
    </form>
</div>
<script src="js/bootstrap.min.js"></script>
</body>
</html>
<?php
// Include footer and other necessary parts
include_once('includes/footer.php');
?>
stdout
<!DOCTYPE html>
	<html>
	<head>
		<title> PHP BASIC</title>
	</head>
	<body>	
		<h2>HELLO/h2>
		“hello”	</body>
	</html>

// your code goes here
stderr
PHP Warning:  Use of undefined constant “hello” - assumed '“hello”' (this will throw an Error in a future version of PHP) in /home/CS7Uhv/prog.php on line 9