[英]Im trying to pass a variable from PHP to HTML using post method but it doesn't work with me
这是我的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中均具有值,则应打印
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.