Kanina pa ako nag de-debug mga sir patulong naman po haha
error message:
Code for add:
add form:
script function
db tables:
services
appointments
pa spoonfeed po mga master, salamat po!
error message:
Code:
Fatal error: Uncaught PDOException: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ') VALUES ('asdsd', '', '123', 'Oral Prypholaxis/Cleaning',)' at line 1 in C:\New folder\htdocs\SoftEng\Appointment.php:35 Stack trace: #0 C:\New folder\htdocs\SoftEng\Appointment.php(35): PDOStatement->execute(Array) #1 {main} thrown in C:\New folder\htdocs\SoftEng\Appointment.php on line 35
Code for add:
Code:
<?php
session_start();
include("config.php");
if(!isset($_SESSION['user'])){
header("location: login.php");
}
$user_check=$_SESSION['user'];
$sql="SELECT * FROM users WHERE username='$user_check'";
$stmt=$conn->query($sql);
$row=$stmt->fetch(PDO::FETCH_ASSOC);
$login_user=$row['username'];
$login_access=$row['acc_type'];
$login_id = $row['user_id'];
//code for Add
if (isset($_POST['services'])) {
if(isset($_POST['con_serv'])){
$name_serv=$_POST['con_serv'];
$sql="SELECT * FROM services WHERE services='$name_serv'";
$stmt=$conn->query($sql);
$row=$stmt->fetch(PDO::FETCH_ASSOC);
$sql = "INSERT INTO appointments (name, appointment_id, contact, services,) VALUES (:name, :appo, :con, :services,)";
$stmt = $conn->prepare($sql);
$stmt->execute([
':name' => $_POST['con_name'],
':appo' => $_POST['con_appointments'],
':con' => $_POST['con_contact'],
':services' => $_POST['con_serv']
]);
echo '<script>alert("Submitted Succesfully! ");</script>';
}
}
add form:
Code:
<section class="signup">
<div class="container">
<div class="signup-content">
<div class="signup-form">
<h2 class="form-title">Please fill up the form.</h2>
<form method="POST" class="register-form" id="register-form">
<div class="form-group">
<label for="name"><i class="zmdi zmdi-account material-icons-name"></i></label>
<input hidden="" type="text" name="name" id="Name" placeholder="Name" readonly="" value='<?php echo $login_user ?>' />
</div>
<div class="form-group">
<label for="name"><i class="zmdi zmdi-account material-icons-name"></i></label>
<input hidden="" type="text" name="user" id="user" placeholder="User ID" readonly="" value='<?php echo $login_id ?>' />
</div>
<div class="form-group">
<label for="username"><i class="zmdi zmdi-account"></i></label>
<input type="text" name="address" id="address" placeholder="Name" />
</div>
<div class="form-group">
<label for="username"><i class="zmdi zmdi-phone"></i></label>
<input type="number" name="contact" id="contact" placeholder="Contact Number" />
</div>
<div class="form-group">
<select name="con_serv" id="prod" class="form-control" required>
<option value="" readonly>-------Select Services-------</option>
<?php
$sql="SELECT * FROM services";
$stmt=$conn->query($sql);
while($row=$stmt->fetch(PDO::FETCH_ASSOC)){
?>
<option value="<?php echo $row['services'] ?>"><?php echo $row['services']." (Available Doctor: )";?><?php echo $row['doctors']?></option>
<?PHP } ?>
</select>
</div>
<div class="form-group form-button">
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#addModal" onclick="onButtonClick(Name.value,appo.value,con.value,services.value,doctors.value)">Submit</button>
</div>
</form>
</div>
</div>
</section>
</div>
</div>
<!--------------------- Modal to order confirmation----------------------->
<div class="modal fade" tabindex="-1" role="dialog" id="addModal">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Order Confirmation</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<!-- FORM -->
<form action="" method="POST">
<div class="form-group">
<input type="hidden" name="con_name" class="form-control" readonly="" placeholder="Name" required>
</div>
<div class="form-group">
<input type="hidden" name="con_appointments" class="form-control" readonly="" placeholder="UserID" required>
</div>
<div class="form-group">
<input required="" type="text" name="con_name" class="form-control" placeholder="Name" required>
</div>
<div class="form-group">
<input required="" type="number" name="con_contact" class="form-control" placeholder="Contact" required>
</div>
<div class="form-group">
<select name="con_serv" id="prodd" class="form-control" required>
<option value="" readonly>-------Select Services-------</option>
<?php
$sql="SELECT * FROM services";
$stmt=$conn->query($sql);
while($row=$stmt->fetch(PDO::FETCH_ASSOC)){
?>
<option value="<?php echo $row['services'] ?>"><?php echo $row['services']." (Available Doctor: )";?><?php echo $row['doctors']?></option>
<?PHP } ?>
</select>
</div>
</div>
<div class="modal-footer">
<button type="submit" class="btn btn-primary" name="services">Confirm</button>
<button type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
</div>
script function
JavaScript:
<!-- Importing the Jquery and Bootstrap libraries-->
<script src="bootstrap/jquery/jquery-3.6.0.js"></script>
<script src="bootstrap/js/bootstrap.js"></script>
<script>
function onButtonClick(name, appo, contact,services) {
$('input[name="con_name"]').val(name);
$('input[name="con_appointments"]').val(appo);
$('input[name="con_contact"]').val(contact);
$('#prod').val(services);
}
</script>
db tables:
services
appointments
pa spoonfeed po mga master, salamat po!
Attachments
-
You do not have permission to view the full content of this post. Log in or register now.
Last edited: