PHP Oracle不将数据插入数据库
我正在尝试通过输入标签将数据插入到Oracle数据库中,该输入标签在表标签中,但由于某种原因,数据没有插入。在表单标签中使用了多个表标签。但是,数据没有插入数据库和提交按钮后要显示的警报消息,也没有显示任何消息。我通过与OCI库链接到ORACLE数据库来使用PHP。也将XAMPP服务器用于网站。
<?php
session_start(); // this NEEDS TO BE AT THE TOP of the page before any output etc
if ($_GET == NULL) {
$uname = $_SESSION['uname'];
} else {
$uname = $_GET['un'];
}
$trainer = $_SESSION['uname'];
$showuname = $_SESSION['uname'];
$conn = oci_connect('brownfalcon_gms', 'saif0rrahman', 'localhost/xe')
or die(oci_error());
if (!$conn) {
echo "sorry";
} else {
$sql1 = "Select Diet_Id from Member where username='$uname'";
$stid1 = oci_parse($conn, $sql1);
$r1 = oci_execute($stid1);
$mem = oci_fetch_array($stid1, OCI_ASSOC + OCI_RETURN_NULLS);
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
if (isset($_POST['breakfast_vitamin']) && isset($_POST['breakfast_protein']) && isset($_POST['breakfast_carbohydrate']) && isset($_POST['breakfast_minerals']) && isset($_POST['breakfast_fat']) && isset($_POST['breakfast_calory']) && isset($_POST['lunch_vitamin']) && isset($_POST['lunch_protein']) && isset($_POST['lunch_carbohydrate']) && isset($_POST['lunch_minerals']) && isset($_POST['lunch_fat']) && isset($_POST['lunch_calory']) && isset($_POST['dinner_vitamin']) && isset($_POST['dinner_protein']) && isset($_POST['dinner_carbohydrate']) && isset($_POST['dinner_minerals']) && isset($_POST['dinner_fat']) && isset($_POST['dinner_calory']) && isset($_POST['pre_wrk_protein']) && isset($_POST['pre_wrk_carbohydrate']) && isset($_POST['pre_wrk_calory']) && isset($_POST['post_wrk_protein']) && isset($_POST['post_wrk_carbohydrate']) && isset($_POST['post_wrk_calory'])) {
$sql = "Select * from Diet_Chart order by Diet_Id desc";
$stid = oci_parse($conn, $sql);
$r = oci_execute($stid);
$row = oci_fetch_array($stid, OCI_ASSOC + OCI_RETURN_NULLS);
if (isset($mem['Diet_Id'])) {
$diet_id = $row['Diet_Id'];
$b_vitamin = $_POST['breakfast_vitamin'];
$b_protein = $_POST['breakfast_protein'];
$b_carbohydrate = $_POST['breakfast_carbohydrate'];
$b_minerals = $_POST['breakfast_minerals'];
$b_fat = $_POST['breakfast_fat'];
$b_calory = $_POST['breakfast_calory'];
$l_vitamin = $_POST['lunch_vitamin'];
$l_protein = $_POST['lunch_protein'];
$l_carbohydrate = $_POST['lunch_carbohydrate'];
$l_minerals = $_POST['lunch_minerals'];
$l_fat = $_POST['lunch_fat'];
$l_calory = $_POST['lunch_calory'];
$d_vitamin = $_POST['dinner_vitamin'];
$d_protein = $_POST['dinner_protein'];
$d_carbohydrate = $_POST['dinner_carbohydrate'];
$d_minerals = $_POST['dinner_minerals'];
$d_fat = $_POST['dinner_fat'];
$d_calory = $_POST['dinner_calory'];
$pr_wrk_protein = $_POST['pre_wrk_protein'];
$pr_wrk_carbohydrte = $_POST['pre_wrk_carbohydrate'];
$pr_wrk_calory = $_POST['pre_wrk_calory'];
$po_wrk_protein = $_POST['post_wrk_protein'];
$po_wrk_carbohydrte = $_POST['post_wrk_carbohydrate'];
$po_wrk_calory = $_POST['post_wrk_calory'];
$sql = "update Diet_Chart set B_VITAMIN='$b_vitamin',B_PROTEIN='$b_protein',B_CARBOHYDRATE='$b_carbohydrate',B_FAT='$b_fat',B_MINERALS='$b_minerals',B_CALORIES='$b_calory', L_VITAMIN='$l_vitamin',L_PROTEIN='$l_protein',L_CARBOHYDRATE='$l_carbohydrate',L_FAT='$l_fat',L_MINERALS='$l_minerals',L_CALORIES='$l_calory', D_VITAMIN='$d_vitamin',D_PROTEIN='$d_protein',D_CARBOHYDRATE='$d_carbohydrate',D_FAT='$d_fat',D_MINERALS='$d_minerals',D_CALORIES='$d_calory',PR_WRK_CARBOHYDRATE='$pr_wrk_carbohydrate',PR_WRK_PROTEIN='$pr_wrk_protein',PR_WRK_CALORIES='$pr_wrk_calory, PST_WRK_CARBOHYDRATE='$po_wrk_carbohydrate',PST_WRK_PROTEIN='$po_wrk_protein',PST_WRK_CALORIES='$po_wrk_calory' where Diet_Id='$diet_id'";
$stid2 = oci_parse($conn, $sql);
$r2 = oci_execute($stid2);
} else {
$diet_id = $row['Diet_Id'] + 1;
$b_vitamin = $_POST['breakfast_vitamin'];
$b_protein = $_POST['breakfast_protein'];
$b_carbohydrate = $_POST['breakfast_carbohydrate'];
$b_minerals = $_POST['breakfast_minerals'];
$b_fat = $_POST['breakfast_fat'];
$b_calory = $_POST['breakfast_calory'];
$l_vitamin = $_POST['lunch_vitamin'];
$l_protein = $_POST['lunch_protein'];
$l_carbohydrate = $_POST['lunch_carbohydrate'];
$l_minerals = $_POST['lunch_minerals'];
$l_fat = $_POST['lunch_fat'];
$l_calory = $_POST['lunch_calory'];
$d_vitamin = $_POST['dinner_vitamin'];
$d_protein = $_POST['dinner_protein'];
$d_carbohydrate = $_POST['dinner_carbohydrate'];
$d_minerals = $_POST['dinner_minerals'];
$d_fat = $_POST['dinner_fat'];
$d_calory = $_POST['dinner_calory'];
$pr_wrk_protein = $_POST['pre_wrk_protein'];
$pr_wrk_carbohydrte = $_POST['pre_wrk_carbohydrate'];
$pr_wrk_calory = $_POST['pre_wrk_calory'];
$po_wrk_protein = $_POST['post_wrk_protein'];
$po_wrk_carbohydrte = $_POST['post_wrk_carbohydrate'];
$po_wrk_calory = $_POST['post_wrk_calory'];
$sql = "insert into diet_chart (DIET_ID,B_VITAMIN,B_FAT,B_PROTEIN,B_MINERALS,B_CARBOHYDRATE,B_CALORIES,
L_VITAMIN,L_FAT,L_PROTEIN,L_MINERALS,L_CARBOHYDRATE,L_CALORIES,
D_VITAMIN,D_FAT,D_PROTEIN,D_MINERALS,D_CARBOHYDRATE,D_CALORIES,
PR_WRK_CARBOHYDRATE,PR_WRK_PROTEIN,PR_WRK_CALORIES,
PST_WRK_CARBOHYDRATE,PST_WRK_PROTEIN,PST_WRK_CALORIES) values($diet_id, '$b_vitamin', '$b_fat', '$b_protein', '$b_minerals','$b_carbohydrate','$b_calory','$l_vitamin', '$l_fat', '$l_protein', '$l_minerals','$l_carbohydrate','$l_calory','$d_vitamin', '$d_fat', '$d_protein', '$d_minerals','$d_carbohydrate','$d_calory','$pr_wrk_protein','$pr_wrk_carbohydrate','$pr_wrk_calory','$po_wrk_protein','$po_wrk_carbohydrate','$po_wrk_calory')";
$stid3 = oci_parse($conn, $sql);
$r3 = oci_execute($stid3);
$sql = "update Member set Diet_Id='$diet_id' where username='$uname'";
$stid4 = oci_parse($conn, $sql);
$r4 = oci_execute($stid4);
}
echo "<div class='alert alert-success' role='alert'>This is a success alert—check it out!</div>";
}
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Diet Chart Update</title>
<!-- Google Font: Source Sans Pro -->
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,400i,700&display=fallback">
<!-- Font Awesome Icons -->
<link rel="stylesheet" href="plugins/fontawesome-free/css/all.min.css">
<!-- overlayScrollbars -->
<link rel="stylesheet" href="plugins/overlayScrollbars/css/OverlayScrollbars.min.css">
<!-- Theme style -->
<link rel="stylesheet" href="dist/css/adminlte.min.css">
</head>
<body class="hold-transition dark-mode sidebar-mini layout-fixed layout-navbar-fixed layout-footer-fixed">
<div class="wrapper">
<!-- Preloader -->
<div class="preloader flex-column justify-content-center align-items-center">
<img class="animation__wobble" src="dist/img/AdminLTELogo.png" alt="AdminLTELogo" height="60" width="60">
</div>
<!-- Navbar -->
<nav class="main-header navbar navbar-expand navbar-dark">
<!-- Left navbar links -->
<ul class="navbar-nav">
<li class="nav-item">
<a class="nav-link" data-widget="pushmenu" href="#" role="button"><i class="fas fa-bars"></i></a>
</li>
</ul>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav ml-auto navbar-right-top">
<li class="nav-item">
<a href=" index.php" type="button" class="btn btn-secondary">Logout</a>
</li>
</ul>
</div>
<!-- Right navbar links -->
</nav>
<!-- /.navbar -->
<!-- Main Sidebar Container -->
<aside class="main-sidebar sidebar-dark-primary elevation-4">
<!-- Brand Logo -->
<a href="#" class="brand-link">
<img src="dist/img/AdminLTELogo.png" alt="AdminLTE Logo" class="brand-image img-circle elevation-3" style="opacity: .8">
<span class="brand-text font-weight-light">Fitness Mania</span>
</a>
<!-- Sidebar -->
<div class="sidebar">
<!-- Sidebar user panel (optional) -->
<div class="user-panel mt-3 pb-3 mb-3 d-flex">
<div class="image">
<img src="dist/img/user2-160x160.jpg" class="img-circle elevation-2" alt="User Image">
</div>
<div class="info">
<a href="employee_profile.php" class="d-block">
<?php echo $trainer ?>
</a>
</div>
</div>
<!-- Sidebar Menu -->
<nav class="mt-2">
<ul class="nav nav-pills nav-sidebar flex-column" data-widget="treeview" role="menu" data-accordion="false">
<!-- Add icons to the links using the .nav-icon class
with font-awesome or any other icon font library -->
<li class="nav-item menu-open">
<a href="#" class="nav-link active">
<i class="nav-icon fas fa-tachometer-alt"></i>
<p>
Dashboard
<i class="right fas fa-angle-left"></i>
</p>
</a>
<ul class="nav nav-treeview">
<li class="nav-item">
<a href="trainer_db.php" class="nav-link active">
<i class="far fa-circle nav-icon"></i>
<p>Trainer</p>
</a>
</li>
</ul>
</li>
<li class="nav-item">
<a href="#" class="nav-link">
<i class="nav-icon far fa-envelope"></i>
<p>
Mailbox
<i class="fas fa-angle-left right"></i>
</p>
</a>
<ul class="nav nav-treeview">
<li class="nav-item">
<a href="pages/mailbox/mailbox.html" class="nav-link">
<i class="far fa-circle nav-icon"></i>
<p>Inbox</p>
</a>
</li>
<li class="nav-item">
<a href="pages/mailbox/compose.html" class="nav-link">
<i class="far fa-circle nav-icon"></i>
<p>Compose</p>
</a>
</li>
</ul>
</li>
<li class="nav-item">
<a href="#" class="nav-link">
<i class="nav-icon fas fa-book"></i>
<p>
Pages
<i class="fas fa-angle-left right"></i>
</p>
</a>
<ul class="nav nav-treeview">
<li class="nav-item">
</li>
<li class="nav-item">
<a href="employee_profile.php" class="nav-link">
<i class="far fa-circle nav-icon"></i>
<p>Profile</p>
</a>
</li>
</ul>
</li>
</ul>
</li>
</ul>
</nav>
<!-- /.sidebar-menu -->
</div>
<!-- /.sidebar -->
</aside>
<!-- Content Wrapper. Contains page content -->
<div class="content-wrapper">
<!-- Content Header (Page header) -->
<div class="content-header">
<div class="container-fluid">
<div class="row mb-2">
<div class="col-sm-6">
<h1 class="m-0">Diet Chart</h1>
</div><!-- /.col -->
<div class="col-sm-6">
<h5 class="m-0 float-right">
<?php
if (!isset($mem['Diet_Id'])) {
echo "DIET ID: NULL";
} else {
echo "DIET ID: " . $mem['Diet_Id'];
}
?>
</h5>
</div><!-- /.col -->
</div><!-- /.row -->
</div><!-- /.container-fluid -->
</div>
<!-- /.content-header -->
<form action="diet.php" method="post">
<div class="container">
<table class="table">
<h3>Breakfast</h3>
<thead>
<tr>
<th>Vitamin</th>
<th>Protein</th>
<th>Carbohydrate</th>
<th>Minerals</th>
<th>Fat</th>
<th>Calory</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<input class="form-control" type="number" min="1" max="100" name="breakfast_vitamin" form="my_form">
</td>
<td>
<input class="form-control" type="number" min="1" max="100" name="breakfast_protein" form="my_form">
</td>
<td>
<input class="form-control" type="number" min="1" max="100" name="breakfast_carbohydrate" form="my_form">
</td>
<td>
<input class="form-control" type="number" min="1" max="100" name="breakfast_minerals" form="my_form">
</td>
<td>
<input class="form-control" type="number" min="1" max="100" name="breakfast_fat" form="my_form">
</td>
<td>
<input class="form-control" type="number" min="1" max="100" name="breakfast_calory" form="my_form">
</td>
</tr>
</tbody>
</table>
<table class="table">
<h3>Lunch</h3>
<thead>
<tr>
<th>Vitamin</th>
<th>Protein</th>
<th>Carbohydrate</th>
<th>Minerals</th>
<th>Fat</th>
<th>Calory</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<input class="form-control" type="number" min="1" max="100" name="lunch_vitamin" form="my_form">
</td>
<td>
<input class="form-control" type="number" min="1" max="100" name="lunch_protein" form="my_form">
</td>
<td>
<input class="form-control" type="number" min="1" max="100" name="lunch_carbohydrate" form="my_form">
</td>
<td>
<input class="form-control" type="number" min="1" max="100" name="lunch_minerals" form="my_form">
</td>
<td>
<input class="form-control" type="number" min="1" max="100" name="lunch_fat" form="my_form">
</td>
<td>
<input class="form-control" type="number" min="1" max="100" name="lunch_calory" form="my_form">
</td>
</tr>
</tbody>
</table>
<table class="table">
<h3>Dinner</h3>
<thead>
<tr>
<th>Vitamin</th>
<th>Protein</th>
<th>Carbohydrate</th>
<th>Minerals</th>
<th>Fat</th>
<th>Calory</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<input class="form-control" type="number" min="1" max="100" name="dinner_vitamin" form="my_form">
</td>
<td>
<input class="form-control" type="number" min="1" max="100" name="dinner_protein" form="my_form">
</td>
<td>
<input class="form-control" type="number" min="1" max="100" name="dinner_carbohydrate" form="my_form">
</td>
<td>
<input class="form-control" type="number" min="1" max="100" name="dinner_minerals" form="my_form">
</td>
<td>
<input class="form-control" type="number" min="1" max="100" name="dinner_fat" form="my_form">
</td>
<td>
<input class="form-control" type="number" min="1" max="100" name="dinner_calory" form="my_form">
</td>
</tr>
</tbody>
</table>
<table class="table">
<h3>Pre Workout</h3>
<thead>
<tr>
<th>Protein</th>
<th>Carbohydrate</th>
<th>Calory</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<input class="form-control" type="number" min="1" max="100" name="pre_wrk_protein" form="my_form">
</td>
<td>
<input class="form-control" type="number" min="1" max="100" name="pre_wrk_carbohydrate" form="my_form">
</td>
<td>
<input class="form-control" type="number" min="1" max="100" name="pre_wrk_calory" form="my_form">
</td>
</tr>
</tbody>
</table>
<table class="table">
<h3>Post Workout</h3>
<thead>
<tr>
<th>Protein</th>
<th>Carbohydrate</th>
<th>Calory</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<input class="form-control" type="number" min="1" max="100" name="post_wrk_protein" form="my_form">
</td>
<td>
<input class="form-control" type="number" min="1" max="100" name="post_wrk_carbohydrate" form="my_form">
</td>
<td>
<input class="form-control" type="number" min="1" max="100" name="post_wrk_calory" form="my_form">
</td>
</tr>
</tbody>
</table>
</div>
<div class="text-center">
<button type="submit" class="btn btn-primary">Submit</button>
</div>
</form>
<div style="margin-bottom:20px ;"></div>
</div>
<aside class="control-sidebar control-sidebar-dark">
</aside>
<!-- Main Footer -->
<footer class="main-footer">
<strong>Copyright © 2022 <a href="#">Gym Management System</a>.</strong>
All rights reserved.
<div class="float-right d-none d-sm-inline-block">
<b>Version</b> 3.2.0-rc
</div>
</footer>
</div>
<!-- ./wrapper -->
<!-- REQUIRED SCRIPTS -->
<!-- jQuery -->
<script src="plugins/jquery/jquery.min.js"></script>
<!-- Bootstrap -->
<script src="plugins/bootstrap/js/bootstrap.bundle.min.js"></script>
<!-- overlayScrollbars -->
<script src="plugins/overlayScrollbars/js/jquery.overlayScrollbars.min.js"></script>
<!-- AdminLTE App -->
<script src="dist/js/adminlte.js"></script>
<!-- PAGE PLUGINS -->
<!-- jQuery Mapael -->
<script src="plugins/jquery-mousewheel/jquery.mousewheel.js"></script>
<script src="plugins/raphael/raphael.min.js"></script>
<script src="plugins/jquery-mapael/jquery.mapael.min.js"></script>
<script src="plugins/jquery-mapael/maps/usa_states.min.js"></script>
<!-- ChartJS -->
<script src="plugins/chart.js/Chart.min.js"></script>
<!-- AdminLTE for demo purposes -->
<script src="dist/js/demo.js"></script>
<!-- AdminLTE dashboard demo (This is only for demo purposes) -->
<script src="dist/js/pages/dashboard2.js"></script>
</body>
</html>
I'm trying insert the data into the oracle database by input tag which is inside the table tag but the the data is not inserting for some reason. Used multiple table tags inside the form tag. But data is not inserting into the database and the alert message which I'm wanting to show after the submit button, isn't showing any message also. I'm using PHP by linking up with OCI library to connect Oracle database. Also using the Xampp server for the website.
<?php
session_start(); // this NEEDS TO BE AT THE TOP of the page before any output etc
if ($_GET == NULL) {
$uname = $_SESSION['uname'];
} else {
$uname = $_GET['un'];
}
$trainer = $_SESSION['uname'];
$showuname = $_SESSION['uname'];
$conn = oci_connect('brownfalcon_gms', 'saif0rrahman', 'localhost/xe')
or die(oci_error());
if (!$conn) {
echo "sorry";
} else {
$sql1 = "Select Diet_Id from Member where username='$uname'";
$stid1 = oci_parse($conn, $sql1);
$r1 = oci_execute($stid1);
$mem = oci_fetch_array($stid1, OCI_ASSOC + OCI_RETURN_NULLS);
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
if (isset($_POST['breakfast_vitamin']) && isset($_POST['breakfast_protein']) && isset($_POST['breakfast_carbohydrate']) && isset($_POST['breakfast_minerals']) && isset($_POST['breakfast_fat']) && isset($_POST['breakfast_calory']) && isset($_POST['lunch_vitamin']) && isset($_POST['lunch_protein']) && isset($_POST['lunch_carbohydrate']) && isset($_POST['lunch_minerals']) && isset($_POST['lunch_fat']) && isset($_POST['lunch_calory']) && isset($_POST['dinner_vitamin']) && isset($_POST['dinner_protein']) && isset($_POST['dinner_carbohydrate']) && isset($_POST['dinner_minerals']) && isset($_POST['dinner_fat']) && isset($_POST['dinner_calory']) && isset($_POST['pre_wrk_protein']) && isset($_POST['pre_wrk_carbohydrate']) && isset($_POST['pre_wrk_calory']) && isset($_POST['post_wrk_protein']) && isset($_POST['post_wrk_carbohydrate']) && isset($_POST['post_wrk_calory'])) {
$sql = "Select * from Diet_Chart order by Diet_Id desc";
$stid = oci_parse($conn, $sql);
$r = oci_execute($stid);
$row = oci_fetch_array($stid, OCI_ASSOC + OCI_RETURN_NULLS);
if (isset($mem['Diet_Id'])) {
$diet_id = $row['Diet_Id'];
$b_vitamin = $_POST['breakfast_vitamin'];
$b_protein = $_POST['breakfast_protein'];
$b_carbohydrate = $_POST['breakfast_carbohydrate'];
$b_minerals = $_POST['breakfast_minerals'];
$b_fat = $_POST['breakfast_fat'];
$b_calory = $_POST['breakfast_calory'];
$l_vitamin = $_POST['lunch_vitamin'];
$l_protein = $_POST['lunch_protein'];
$l_carbohydrate = $_POST['lunch_carbohydrate'];
$l_minerals = $_POST['lunch_minerals'];
$l_fat = $_POST['lunch_fat'];
$l_calory = $_POST['lunch_calory'];
$d_vitamin = $_POST['dinner_vitamin'];
$d_protein = $_POST['dinner_protein'];
$d_carbohydrate = $_POST['dinner_carbohydrate'];
$d_minerals = $_POST['dinner_minerals'];
$d_fat = $_POST['dinner_fat'];
$d_calory = $_POST['dinner_calory'];
$pr_wrk_protein = $_POST['pre_wrk_protein'];
$pr_wrk_carbohydrte = $_POST['pre_wrk_carbohydrate'];
$pr_wrk_calory = $_POST['pre_wrk_calory'];
$po_wrk_protein = $_POST['post_wrk_protein'];
$po_wrk_carbohydrte = $_POST['post_wrk_carbohydrate'];
$po_wrk_calory = $_POST['post_wrk_calory'];
$sql = "update Diet_Chart set B_VITAMIN='$b_vitamin',B_PROTEIN='$b_protein',B_CARBOHYDRATE='$b_carbohydrate',B_FAT='$b_fat',B_MINERALS='$b_minerals',B_CALORIES='$b_calory', L_VITAMIN='$l_vitamin',L_PROTEIN='$l_protein',L_CARBOHYDRATE='$l_carbohydrate',L_FAT='$l_fat',L_MINERALS='$l_minerals',L_CALORIES='$l_calory', D_VITAMIN='$d_vitamin',D_PROTEIN='$d_protein',D_CARBOHYDRATE='$d_carbohydrate',D_FAT='$d_fat',D_MINERALS='$d_minerals',D_CALORIES='$d_calory',PR_WRK_CARBOHYDRATE='$pr_wrk_carbohydrate',PR_WRK_PROTEIN='$pr_wrk_protein',PR_WRK_CALORIES='$pr_wrk_calory, PST_WRK_CARBOHYDRATE='$po_wrk_carbohydrate',PST_WRK_PROTEIN='$po_wrk_protein',PST_WRK_CALORIES='$po_wrk_calory' where Diet_Id='$diet_id'";
$stid2 = oci_parse($conn, $sql);
$r2 = oci_execute($stid2);
} else {
$diet_id = $row['Diet_Id'] + 1;
$b_vitamin = $_POST['breakfast_vitamin'];
$b_protein = $_POST['breakfast_protein'];
$b_carbohydrate = $_POST['breakfast_carbohydrate'];
$b_minerals = $_POST['breakfast_minerals'];
$b_fat = $_POST['breakfast_fat'];
$b_calory = $_POST['breakfast_calory'];
$l_vitamin = $_POST['lunch_vitamin'];
$l_protein = $_POST['lunch_protein'];
$l_carbohydrate = $_POST['lunch_carbohydrate'];
$l_minerals = $_POST['lunch_minerals'];
$l_fat = $_POST['lunch_fat'];
$l_calory = $_POST['lunch_calory'];
$d_vitamin = $_POST['dinner_vitamin'];
$d_protein = $_POST['dinner_protein'];
$d_carbohydrate = $_POST['dinner_carbohydrate'];
$d_minerals = $_POST['dinner_minerals'];
$d_fat = $_POST['dinner_fat'];
$d_calory = $_POST['dinner_calory'];
$pr_wrk_protein = $_POST['pre_wrk_protein'];
$pr_wrk_carbohydrte = $_POST['pre_wrk_carbohydrate'];
$pr_wrk_calory = $_POST['pre_wrk_calory'];
$po_wrk_protein = $_POST['post_wrk_protein'];
$po_wrk_carbohydrte = $_POST['post_wrk_carbohydrate'];
$po_wrk_calory = $_POST['post_wrk_calory'];
$sql = "insert into diet_chart (DIET_ID,B_VITAMIN,B_FAT,B_PROTEIN,B_MINERALS,B_CARBOHYDRATE,B_CALORIES,
L_VITAMIN,L_FAT,L_PROTEIN,L_MINERALS,L_CARBOHYDRATE,L_CALORIES,
D_VITAMIN,D_FAT,D_PROTEIN,D_MINERALS,D_CARBOHYDRATE,D_CALORIES,
PR_WRK_CARBOHYDRATE,PR_WRK_PROTEIN,PR_WRK_CALORIES,
PST_WRK_CARBOHYDRATE,PST_WRK_PROTEIN,PST_WRK_CALORIES) values($diet_id, '$b_vitamin', '$b_fat', '$b_protein', '$b_minerals','$b_carbohydrate','$b_calory','$l_vitamin', '$l_fat', '$l_protein', '$l_minerals','$l_carbohydrate','$l_calory','$d_vitamin', '$d_fat', '$d_protein', '$d_minerals','$d_carbohydrate','$d_calory','$pr_wrk_protein','$pr_wrk_carbohydrate','$pr_wrk_calory','$po_wrk_protein','$po_wrk_carbohydrate','$po_wrk_calory')";
$stid3 = oci_parse($conn, $sql);
$r3 = oci_execute($stid3);
$sql = "update Member set Diet_Id='$diet_id' where username='$uname'";
$stid4 = oci_parse($conn, $sql);
$r4 = oci_execute($stid4);
}
echo "<div class='alert alert-success' role='alert'>This is a success alert—check it out!</div>";
}
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Diet Chart Update</title>
<!-- Google Font: Source Sans Pro -->
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,400i,700&display=fallback">
<!-- Font Awesome Icons -->
<link rel="stylesheet" href="plugins/fontawesome-free/css/all.min.css">
<!-- overlayScrollbars -->
<link rel="stylesheet" href="plugins/overlayScrollbars/css/OverlayScrollbars.min.css">
<!-- Theme style -->
<link rel="stylesheet" href="dist/css/adminlte.min.css">
</head>
<body class="hold-transition dark-mode sidebar-mini layout-fixed layout-navbar-fixed layout-footer-fixed">
<div class="wrapper">
<!-- Preloader -->
<div class="preloader flex-column justify-content-center align-items-center">
<img class="animation__wobble" src="dist/img/AdminLTELogo.png" alt="AdminLTELogo" height="60" width="60">
</div>
<!-- Navbar -->
<nav class="main-header navbar navbar-expand navbar-dark">
<!-- Left navbar links -->
<ul class="navbar-nav">
<li class="nav-item">
<a class="nav-link" data-widget="pushmenu" href="#" role="button"><i class="fas fa-bars"></i></a>
</li>
</ul>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav ml-auto navbar-right-top">
<li class="nav-item">
<a href=" index.php" type="button" class="btn btn-secondary">Logout</a>
</li>
</ul>
</div>
<!-- Right navbar links -->
</nav>
<!-- /.navbar -->
<!-- Main Sidebar Container -->
<aside class="main-sidebar sidebar-dark-primary elevation-4">
<!-- Brand Logo -->
<a href="#" class="brand-link">
<img src="dist/img/AdminLTELogo.png" alt="AdminLTE Logo" class="brand-image img-circle elevation-3" style="opacity: .8">
<span class="brand-text font-weight-light">Fitness Mania</span>
</a>
<!-- Sidebar -->
<div class="sidebar">
<!-- Sidebar user panel (optional) -->
<div class="user-panel mt-3 pb-3 mb-3 d-flex">
<div class="image">
<img src="dist/img/user2-160x160.jpg" class="img-circle elevation-2" alt="User Image">
</div>
<div class="info">
<a href="employee_profile.php" class="d-block">
<?php echo $trainer ?>
</a>
</div>
</div>
<!-- Sidebar Menu -->
<nav class="mt-2">
<ul class="nav nav-pills nav-sidebar flex-column" data-widget="treeview" role="menu" data-accordion="false">
<!-- Add icons to the links using the .nav-icon class
with font-awesome or any other icon font library -->
<li class="nav-item menu-open">
<a href="#" class="nav-link active">
<i class="nav-icon fas fa-tachometer-alt"></i>
<p>
Dashboard
<i class="right fas fa-angle-left"></i>
</p>
</a>
<ul class="nav nav-treeview">
<li class="nav-item">
<a href="trainer_db.php" class="nav-link active">
<i class="far fa-circle nav-icon"></i>
<p>Trainer</p>
</a>
</li>
</ul>
</li>
<li class="nav-item">
<a href="#" class="nav-link">
<i class="nav-icon far fa-envelope"></i>
<p>
Mailbox
<i class="fas fa-angle-left right"></i>
</p>
</a>
<ul class="nav nav-treeview">
<li class="nav-item">
<a href="pages/mailbox/mailbox.html" class="nav-link">
<i class="far fa-circle nav-icon"></i>
<p>Inbox</p>
</a>
</li>
<li class="nav-item">
<a href="pages/mailbox/compose.html" class="nav-link">
<i class="far fa-circle nav-icon"></i>
<p>Compose</p>
</a>
</li>
</ul>
</li>
<li class="nav-item">
<a href="#" class="nav-link">
<i class="nav-icon fas fa-book"></i>
<p>
Pages
<i class="fas fa-angle-left right"></i>
</p>
</a>
<ul class="nav nav-treeview">
<li class="nav-item">
</li>
<li class="nav-item">
<a href="employee_profile.php" class="nav-link">
<i class="far fa-circle nav-icon"></i>
<p>Profile</p>
</a>
</li>
</ul>
</li>
</ul>
</li>
</ul>
</nav>
<!-- /.sidebar-menu -->
</div>
<!-- /.sidebar -->
</aside>
<!-- Content Wrapper. Contains page content -->
<div class="content-wrapper">
<!-- Content Header (Page header) -->
<div class="content-header">
<div class="container-fluid">
<div class="row mb-2">
<div class="col-sm-6">
<h1 class="m-0">Diet Chart</h1>
</div><!-- /.col -->
<div class="col-sm-6">
<h5 class="m-0 float-right">
<?php
if (!isset($mem['Diet_Id'])) {
echo "DIET ID: NULL";
} else {
echo "DIET ID: " . $mem['Diet_Id'];
}
?>
</h5>
</div><!-- /.col -->
</div><!-- /.row -->
</div><!-- /.container-fluid -->
</div>
<!-- /.content-header -->
<form action="diet.php" method="post">
<div class="container">
<table class="table">
<h3>Breakfast</h3>
<thead>
<tr>
<th>Vitamin</th>
<th>Protein</th>
<th>Carbohydrate</th>
<th>Minerals</th>
<th>Fat</th>
<th>Calory</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<input class="form-control" type="number" min="1" max="100" name="breakfast_vitamin" form="my_form">
</td>
<td>
<input class="form-control" type="number" min="1" max="100" name="breakfast_protein" form="my_form">
</td>
<td>
<input class="form-control" type="number" min="1" max="100" name="breakfast_carbohydrate" form="my_form">
</td>
<td>
<input class="form-control" type="number" min="1" max="100" name="breakfast_minerals" form="my_form">
</td>
<td>
<input class="form-control" type="number" min="1" max="100" name="breakfast_fat" form="my_form">
</td>
<td>
<input class="form-control" type="number" min="1" max="100" name="breakfast_calory" form="my_form">
</td>
</tr>
</tbody>
</table>
<table class="table">
<h3>Lunch</h3>
<thead>
<tr>
<th>Vitamin</th>
<th>Protein</th>
<th>Carbohydrate</th>
<th>Minerals</th>
<th>Fat</th>
<th>Calory</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<input class="form-control" type="number" min="1" max="100" name="lunch_vitamin" form="my_form">
</td>
<td>
<input class="form-control" type="number" min="1" max="100" name="lunch_protein" form="my_form">
</td>
<td>
<input class="form-control" type="number" min="1" max="100" name="lunch_carbohydrate" form="my_form">
</td>
<td>
<input class="form-control" type="number" min="1" max="100" name="lunch_minerals" form="my_form">
</td>
<td>
<input class="form-control" type="number" min="1" max="100" name="lunch_fat" form="my_form">
</td>
<td>
<input class="form-control" type="number" min="1" max="100" name="lunch_calory" form="my_form">
</td>
</tr>
</tbody>
</table>
<table class="table">
<h3>Dinner</h3>
<thead>
<tr>
<th>Vitamin</th>
<th>Protein</th>
<th>Carbohydrate</th>
<th>Minerals</th>
<th>Fat</th>
<th>Calory</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<input class="form-control" type="number" min="1" max="100" name="dinner_vitamin" form="my_form">
</td>
<td>
<input class="form-control" type="number" min="1" max="100" name="dinner_protein" form="my_form">
</td>
<td>
<input class="form-control" type="number" min="1" max="100" name="dinner_carbohydrate" form="my_form">
</td>
<td>
<input class="form-control" type="number" min="1" max="100" name="dinner_minerals" form="my_form">
</td>
<td>
<input class="form-control" type="number" min="1" max="100" name="dinner_fat" form="my_form">
</td>
<td>
<input class="form-control" type="number" min="1" max="100" name="dinner_calory" form="my_form">
</td>
</tr>
</tbody>
</table>
<table class="table">
<h3>Pre Workout</h3>
<thead>
<tr>
<th>Protein</th>
<th>Carbohydrate</th>
<th>Calory</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<input class="form-control" type="number" min="1" max="100" name="pre_wrk_protein" form="my_form">
</td>
<td>
<input class="form-control" type="number" min="1" max="100" name="pre_wrk_carbohydrate" form="my_form">
</td>
<td>
<input class="form-control" type="number" min="1" max="100" name="pre_wrk_calory" form="my_form">
</td>
</tr>
</tbody>
</table>
<table class="table">
<h3>Post Workout</h3>
<thead>
<tr>
<th>Protein</th>
<th>Carbohydrate</th>
<th>Calory</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<input class="form-control" type="number" min="1" max="100" name="post_wrk_protein" form="my_form">
</td>
<td>
<input class="form-control" type="number" min="1" max="100" name="post_wrk_carbohydrate" form="my_form">
</td>
<td>
<input class="form-control" type="number" min="1" max="100" name="post_wrk_calory" form="my_form">
</td>
</tr>
</tbody>
</table>
</div>
<div class="text-center">
<button type="submit" class="btn btn-primary">Submit</button>
</div>
</form>
<div style="margin-bottom:20px ;"></div>
</div>
<aside class="control-sidebar control-sidebar-dark">
</aside>
<!-- Main Footer -->
<footer class="main-footer">
<strong>Copyright © 2022 <a href="#">Gym Management System</a>.</strong>
All rights reserved.
<div class="float-right d-none d-sm-inline-block">
<b>Version</b> 3.2.0-rc
</div>
</footer>
</div>
<!-- ./wrapper -->
<!-- REQUIRED SCRIPTS -->
<!-- jQuery -->
<script src="plugins/jquery/jquery.min.js"></script>
<!-- Bootstrap -->
<script src="plugins/bootstrap/js/bootstrap.bundle.min.js"></script>
<!-- overlayScrollbars -->
<script src="plugins/overlayScrollbars/js/jquery.overlayScrollbars.min.js"></script>
<!-- AdminLTE App -->
<script src="dist/js/adminlte.js"></script>
<!-- PAGE PLUGINS -->
<!-- jQuery Mapael -->
<script src="plugins/jquery-mousewheel/jquery.mousewheel.js"></script>
<script src="plugins/raphael/raphael.min.js"></script>
<script src="plugins/jquery-mapael/jquery.mapael.min.js"></script>
<script src="plugins/jquery-mapael/maps/usa_states.min.js"></script>
<!-- ChartJS -->
<script src="plugins/chart.js/Chart.min.js"></script>
<!-- AdminLTE for demo purposes -->
<script src="dist/js/demo.js"></script>
<!-- AdminLTE dashboard demo (This is only for demo purposes) -->
<script src="dist/js/pages/dashboard2.js"></script>
</body>
</html>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
打印出更新
$ sql
:语法是错误的。但是无论如何,对于安全性和性能,您必须使用绑定变量,而不是字符串串联。请参阅 https://www.php.net/manual /en/function.oci-bind-by-name.php 。在每个OCI调用后,还要添加一些错误处理。从命令行(非Web)脚本开始,然后检查您可以插入数据。类似的内容:
然后确保您的Web应用程序数据的格式相同。
查看php OCI8手册,以及地下PHP和Oracle手册
Print out the UPDATE
$sql
: the syntax is wrong. But regardless, for security and performance you MUST use bind variables, not string concatenation. See https://www.php.net/manual/en/function.oci-bind-by-name.php. Also add some error handling after each OCI call.Start with a command-line (non web) script and check you can insert data. Something like this:
Then make sure your web app data is in the same format.
Check out the PHP OCI8 manual, and also the back half of The Underground PHP and Oracle Manual