I'm a student and I was given a task to make a reservation system. I'm a bit new to php so I still need some guidance, my problem here is, when I try to insert data from a form, my page turns white blank just after I clicked the submit button.
I've tried googled for answers and some answers are because there are extra/lack of brackets, extra spaces in php coding and there are also a tip to put this coding in the beginning of php code error_reporting(-1);
to see what is the error but unfortunately, there are no right solutions.
By posting this I hope some of you can help me and see what's wrong with my coding.
Your help is much needed. Thank you so much in advance.
Page2.php:
<?php
session_start();
require('db.php');
include("auth.php");
$status = "";
if(isset($_POST['new']) && $_POST['new']==1){
$trn_date = date("Y-m-d H:i:s");
$checkBox = implode(',', $_POST['item']);
$microphones = $_REQUEST['microphones'];
$amplifers =$_REQUEST['amplifers'];
$loudspeakers = $_REQUEST['loudspeakers'];
$mixers =$_REQUEST['mixers'];
$catatan = $_REQUEST['catatan'];
$submittedby = $_SESSION["username"];
$ins_query="insert into pasystems
(`trn_date`,`item`,`microphones`,`amplifers`,`loudspeakers`,`mixers`,`catatan`,`submittedby`)values
('$trn_date','". $checkBox ."','$microphones','$amplifers','$loudspeakers','$mixers','$catatan','$submittedby')";
mysqli_query($con,$ins_query)
or die(mysql_error());
$status = "New Record Inserted Successfully.
</br></br><a href='view.php'>View Inserted Record</a>";
}
?>
html:
<form action="Page2.php" name="form" method="POST">
<input type="hidden" name="new" value="1" />
<ul class="errorMessages"></ul>
<div class="form-group row text-left">
<label for="example-date-input" class="col-2 col-form-label">Nama Peralatan: </label>
<div class="col-10">
<div class="form-group">
<div class="form-row">
<div class="col-md-3">
<div class="form-check text-left">
<label class="form-check-label">
<input class="form-check-input" name="item[]" type="checkbox" value="Microphones">
Microphones
</label>
</div>
</div>
<div class="">
<input class="form-control" type="number" name="microphones" value="0" id="example-number-input">
</div>
</div>
</div>
<div class="form-group">
<div class="form-row">
<div class="col-md-3">
<div class="form-check text-left">
<label class="form-check-label">
<input class="form-check-input" name="item[]" type="checkbox" value="Amplifiers">
Amplifiers
</label>
</div>
</div>
<div class="">
<input class="form-control" type="number" name="amplifiers" value="0" id="example-number-input">
</div>
</div>
</div>
<div class="form-group">
<div class="form-row">
<div class="col-md-3">
<div class="form-check text-left">
<label class="form-check-label">
<input class="form-check-input" name="item[]" type="checkbox" value="Loudspeakers">
Loudspeakers
</label>
</div>
</div>
<div class="">
<input class="form-control" type="number" name="loudspeakers" value="0" id="example-number-input">
</div>
</div>
</div>
<div class="form-group">
<div class="form-row">
<div class="col-md-3">
<div class="form-check text-left">
<label class="form-check-label">
<input class="form-check-input" name="item[]" type="checkbox" value="Mixers">
Mixers
</label>
</div>
</div>
<div class="">
<input class="form-control" type="number" name="mixers" value="0" id="example-number-input">
</div>
</div>
</div>
</div>
</div>
<div class="form-group row text-left">
<label for="exampleTextarea" class="col-2 col-form-label">Catatan: </label>
<div class="col-10">
<textarea class="form-control" name="catatan" id="exampleTextarea" rows="3"></textarea>
</div>
</div>
<p style="color:#FF0000;"><?php echo $status; ?></p>
<center><button type="submit" name="submit" class="btn btn-info">Submit</button></center>
</form>
I have edited my coding but it seems to still have a problem