duanche4578 2015-10-06 09:33
浏览 73

从另一个脚本中获取变量

Using a drop down list I am selecting a data from a list :

<option value="R.K.Hospital">R.K.Hospital </option>
<option value="Sevabhai Hospital">Sevabhai Hospital</option>

Now Using this part of the code I am checking whether the seat is available or not :

$queryreg = mysql_query("SELECT available FROM hospital WHERE h_name='$hospital' ");
        $queryreg = mysql_fetch_assoc($queryreg);
        $a=    $queryreg;  

        echo '<span style="color:ff0000;text-align:center;">Available seats are , '.$a['available'].'  </span>';

        if($a['available']>0)
        {

            echo (" <form action='book_bed.php' method='post'><input name='submit' type='submit' value='Book Now' /> </form>"); 
        }

Now I want to book the seat if the seats are available...

<?php


include_once('connection.php');

include_once('available.php');


$hospital=$_POST['hospital'];
$username=$_SESSION['username'];

$date=date("Y-m-d");


if(@$_POST['submit'])
{
    $queryreg = mysql_query("INSERT INTO `bed_book` VALUES ('$username','$hospital','')",$connect);
    echo'<span style="color:#AFA;text-align:center;">Order Has Been Booked !!</span>';  
}

?>

Everything is getting inserted in the database except the $hospital variable... I guess there is some implementation problem...The connection and the database is working quite finely so there is not an issue. If anybody can help I'll be thankful...

  • 写回答

1条回答 默认 最新

  • dongliyi967823 2015-10-06 09:45
    关注

    In your form there is no any input for hospital

    echo (" <form action='book_bed.php' method='post'>
    <input name='hospital' type='hidden' value='".$hospital."' />
    <input name='submit' type='submit' value='Book Now' /> 
    </form>"); 
    

    and on submit of it you will get value of it

    $queryreg = mysql_query("INSERT INTO `bed_book` VALUES ('$username','".$hospital."','')",$connect);
    
    评论

报告相同问题?

悬赏问题

  • ¥15 全部备份安卓app数据包括密码,可以复制到另一手机上运行
  • ¥15 Python3.5 相关代码写作
  • ¥20 测距传感器数据手册i2c
  • ¥15 RPA正常跑,cmd输入cookies跑不出来
  • ¥15 求帮我调试一下freefem代码
  • ¥15 matlab代码解决,怎么运行
  • ¥15 R语言Rstudio突然无法启动
  • ¥15 关于#matlab#的问题:提取2个图像的变量作为另外一个图像像元的移动量,计算新的位置创建新的图像并提取第二个图像的变量到新的图像
  • ¥15 改算法,照着压缩包里边,参考其他代码封装的格式 写到main函数里
  • ¥15 用windows做服务的同志有吗