Show Code:
medium-create.php
<?php include 'session.php'; ?> <!DOCTYPE html>
<html>
<head>
<title>Alexandria</title>
<link href="style1.css" rel="stylesheet" type="text/css">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<?php include 'nav.php'; ?>
<?php include 'db-connect.php'; ?>
<main>
<?php
//handle initial create page
if( $_POST['medium_name']==''){
?>
<form method="post" action="medium-create.php">
<label>Medium Name: </label>
<input type="text" name="medium_name">
<input type="submit" value="Create">
</form>
<?php
}
//handle recursive form
else{
$medium_name=$_POST['medium_name'];
$sql='INSERT INTO t_mediums (medium_name)
VALUES ("'.$medium_name.'")';
if(mysqli_query($con,$sql)){
echo 'Medium has been created';
}
else{
echo "Error creating medium: " . mysqli_error($con);
}
}
?>
<?php mysqli_close($con); //Close Connection?>
</main>
</body>
</html>