这是我的PHP代码页
<?php
session_start();
//include database connection
include_once("dbconn.php");
//afetr click the submit button the below code will be impelemnted
if(isset($_POST['id'])){
$id=$_POST['id'];
$Type=$_POST['Type'];
$Avalibility=$_POST['Avalibility'];
# insert data into MySQL database
$sql1 =" update $Type set Reserve=1 where APP_ID=$id ";
$sql2="INSERT INTO appointment_summary
SELECT Fname,Dep_Name,".$_SESSION['login_user'] .",D_ID,Hospital_Name,Hospital_Type,'".$_SESSION['Reason']."',APP_ID,Avalibility
FROM $Type
where APP_ID=$id";
$sql3="select * from appointment_summary where P_ID=".$_SESSION['login_user'] ." and Availability ='$Avalibility' ";
$result=$conn->query($sql3);
if ($result->num_rows != 1) {
$conn->query($sql2);
$conn->query($sql1);
echo "<script>
alert('Your appointment has been succssfuly add');
window.location.href='CheckAppoinmnets.php';
</script>";
} else {
$Invalid="<p style=\"color:red;\"> You alrredy have an appointment in this time</p>";
$_SESSION['Invalid']=$Invalid;
}
}
//enter code here
$conn->close();
我在 HTML 页面中使用的这段代码
<?php
if(isset($_POST['id'])){
echo $_SESSION['Invalid'];
}
?>
最佳答案
试试下面的代码
<?php
session_start();
if(isset($_REQUEST['id'])){
echo isset($_SESSION['Invalid'])?$_SESSION['Invalid']:'';
}
?>
如果你在 ID 和 SESSION 中都有值,它应该打印
关于php - 我正在尝试使用 post 方法将变量从 PHP 传递到 HTML,但它对我不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35668811/