dongyu1918 2011-04-15 12:29
浏览 44

First form的所有数据都不存储在Backend(ReserveRoomsBackend.php)文件中

Problem Statement:All the data of First form are not getting into the backend file(ReserveRoomsBackend.php) which include start_date, end_date,sr_citizen_choice which may be loosing at between of program so on submitting it is not passed to another page so what should be the solution for this .

IN Reserve.html file i have used two files

1.findReserveRoomsBackend.php is the file in which it will find out the free rooms and return a single room and the respective building

I think that when the findReserveRoomsBackend.php return the room number then dates are lost

2.ReserveRoomsBackend.php file for mysql connectivity and insert the data of form into the MYSQL database.

The following is the Reserve.html file

<html>
<script type="text/javascript" src="../jQuery.js"></script>
<script type="text/javascript">

  $(document).ready(function(){
    document.getElementById("form_reserve").style.display = "none";
    document.getElementById("label").style.display = "none";
   });

   function doAjaxPost(){

        var from_date = document.getElementById("from_date").value;
        var end_date = document.getElementById("end_date").value;
        var no_of_males= document.getElementById("id_males").value;
        var no_of_females=document.getElementById("id_females").value;
        var no_of_childrens=document.getElementById("id_childrens").value;
            var sr_citizen ;
        for (var i=0; i < document.reserve_rooms.sr_citizen_choice.length; i++) 
                        {
                  if (document.reserve_rooms.sr_citizen_choice[i].checked) 
                                 {
                var sr_citizen =                                 document.reserve_rooms.sr_citizen_choice[i].value;
                     }
               }

        //.getJSON -- get building id, building name, room number 
        // if building id > 0 show the reservation details form
        // else show the messgae

//findReserveRoomsBackend.php is the file in which it will find out the free rooms and //return a single room and the respective building
//I think that when the findReserveRoomsBackend.php return the room number then dates are //lost

//findReserveRoomsBackend.php file for mysql connectivity and insert the date of form into the  MYSQL database

var link = 'http://localhost/findReserveRoomsBackend.php?start_date='+from_date+' & end_date='+end_date+' & sr_citizen_choice='+sr_citizen+' & no_of_males='+no_of_males+'& no_of_females='+no_of_females+' & no_of_childrens='+no_of_childrens;

        $.getJSON(link,function(json)
       {
            if( json.length> 0)
       {

document.form_reserve.action ="http://localhost/ReserveRoomsBackend.php?        bldg_number="+json[0].bldg_number +" & room_number="+json[0].room_number;
        document.getElementById("form_reserve").style.display = "block";
    }
             else
       {
           document.getElementById("label").style.display = "block";
       }

alert("inside json finction " + json.length+"  "+json[0].room_number+"   "+json[0].bldg_number);
        }); //.getJSON

    }//doAjaxPost

</script>

<div style="width: 950px; height: 500px; background-color: #FAE89E; border-width: 3px; border-style: inset; color: #FF0000; font-size: 13px; font-family: Arial; overflow: auto;">

   <script type="text/javascript" src="../jQuery.js"></script>
   <script type="text/javascript" src="../jquery.ui.datepicker.js"></script>
   <script language="javascript" type="text/javascript" src="datetimepicker.js"> </script>
<body>

------This is the First form---------------------------------------------------------------

<form id='target'  METHOD="POST" name='reserve_rooms'>

    <p> From Date:<input name="from"   type="text" id ="from_date"/>
        End Date:<input name="to" type="text"   id="end_date" />

   Senior Citizen*:<input type  = "radio" name  = "sr_citizen_choice" value = "Y" />Yes  
                   <input type  = "radio" name  = "sr_citizen_choice" value = "N"  checked  />No

<input  id="find_availability" type="button" value="Find Availability" onClick="doAjaxPost()"  />
        </p>

    </form> 


    <div id='label' name ='label'>
           No Rooms are available for the given period 
    </div>

--This is the second form-----------------------------------

<form id='form_reserve' name='form_reserve' " METHOD="POST">

<fieldset>

    <legend>Personal Details :</legend>

        <b>Name*:</b> <input type="text" name="fname"  /> 
                Address*:<input type="text" size=50 width=30 name="faddress"/>
                City*:<input type="text" name="fcity" />
        State*:</b> <input type="text" name="fstate" />
        Country*:<select name="gourl" size="1">
          <option>India</option>
</select>
</fieldset>
<input type="submit" value="Reserve Room"/>
</form> 
</body>
</html>
  • 写回答

1条回答 默认 最新

  • doushang4274 2011-04-15 13:48
    关注

    This is all the same HTML file I assume?

    If so, you have two opening tags and only one closing tag. The first (above your date fields) has an invalid method attribute ('button'). The second one will actually create a proper form which is presumably what is being submitted.

    So get rid of your first tag and move the second one above your date fields.

    Secondly, the field names that are submitted come from the 'name' attribute not the 'id', so your date fields need to have name="start_date" and name="end_date"

    Finally, it is a POST form so you will find your posted variables in PHP in $_POST not $_GET. You can also find them in $_REQUEST, although personally I think it's more secure if you specify in your code where you expect user-supplied variables to come from, so use $_POST.

    Hope this answers it!

    评论

报告相同问题?

悬赏问题

  • ¥15 为什么apriori的运行时间会比fp growth的运行时间短呢
  • ¥15 帮我解决一下膳食平衡的线性规划模型的数据实例
  • ¥40 万年历缺少农历,需要和阳历同时显示
  • ¥250 雷电模拟器内存穿透、寻基址和特征码的教学
  • ¥200 比特币ord程序wallet_constructor.rs文件支持一次性铸造1000个代币,并将它们分配到40个UTXO上(每个UTXO上分配25个代币),并设置找零地址
  • ¥15 关于Java的学习问题
  • ¥15 如何使用chatgpt完成文本分类任务?
  • ¥15 已知速度v关于位置s的等式,怎么转化为已知位置求速度v的等式
  • ¥15 我有个餐饮系统,用wampserver把环境配置好了,但是后端的网页却进去,是为什么,能不能帮远程一下?
  • ¥15 R运行没有名称为"species"的插槽对于此对象类"SDMmodelCV"