在我的代碼中,我試圖從一個php獲取變量的值。在這個PHP文件中,我通過url從其他一些PHP文件中獲取值。如果語句使用GET,PHP沒有獲取值
我得到了其他部分裏面所有的值,但內部沒有如果,變量MEETING_ID和pemail不存儲任何東西在數據庫中的所有其他領域的完美存儲的值。我錯在哪裏?
<?php
if (isset($_POST['send'])) {
$pemail = $_POST['e'];
$meeting_id = $_POST['mid'];
$date = $_POST["dat"];
if ($date=="val1") {
$d1 = 'Yes';
}
else {
$d1='No';
}
if ($date=="val2") {
$d2 = 'Yes';
}
else {
$d2='No';
}
$location = $_POST["location"];
if ($location=="val1") {
$l1 = 'Yes';
}
else {
$l1='No';
}
if ($location=="val2") {
$l2 = 'Yes';
}
else {
$l2='No';
}
$check_list1 = $_POST['check_list1'];
if ($check_list1 != 'yes') {
$check_list1 = 'No';
}
$check_list2 = $_POST['check_list2'];
if ($check_list2 != 'yes') {
$check_list2 = 'No';
}
$host='mysql5.000webhost.com';
$uname='admin';
$pwd='*****';
$db="meeting";
$con = mysql_connect($host,$uname,$pwd) or die("connection failed");
mysql_select_db($db,$con) or die("db selection failed");
$flag['code']=0;
if($r=mysql_query("insert into meeting.response (meeting_id, Email,
DAT1, DAT2, Location1, Location2, Travel, Hotel)
values('$meeting_id','$pemail','$d1','$d2','$l1','$l2','$check_list1',
'$check_list2') ",$con))
{
$flag['code']=1;
echo"hi";
}
print(json_encode($flag));
mysql_close($con);
?>
Your response was sent
<?php
} else {
$top=$_GET['t'];
$dat1=$_GET['d1'];
$tim1=$_GET['t1'];
$dat2=$_GET['d2'];
$tim2=$_GET['t2'];
$loc1=$_GET['l1'];
$loc2=$_GET['l2'];
$mid=$_GET['id'];
$e=$_GET['pemail'];
?>
<h1><center>Meeting Invitation</center></h1>
<form action="my.php" method="post">
You are invited for the meeting on <?php echo $top; ?>
proposed dates are :<br><br>
Date
Time<br>
<?php echo $dat1; ?> <?php echo $tim1; ?><input
type = "radio" name = "dat" <?php if (isset($dat) && $dat=="val1") echo
"checked";?> value = "val1" checked="true" ><br>
<?php echo $dat2; ?> <?php echo $tim2; ?><input
type = "radio" name = "dat" <?php if (isset($dat) && $dat=="val2") echo
"checked";?> value = "val2" ><br><br>
Proposed locations are :<br>
Location 1 : <?php echo $loc1; ?> <input type =
"radio" name = "location" <?php if (isset($location) &&
$location=="val1") echo
"checked";?> value = "val1" checked="true" ><br>
Location 2 : <?php echo $loc2; ?> <input type =
"radio" name = "location" <?php if (isset($location) && $location=="val2")
echo
"checked";?> value = "val2" ><br><br>
Do you want travel facility ?
<input type="checkbox" name="check_list1" value="yes"> <br><br>
Do you want hotel facility ?
<input type="checkbox" name="check_list2" value="yes"> <br><br><br>
<input type="submit" name="send" value="Send Response">
<input type="reset" >
</form>
<?php
};
?>
當你使用'GET',該參數是'$ _GET',但你使用'$ _POST ['mid']'。 – Barmar 2015-02-05 17:44:04
如果您希望能夠通過GET或POST獲取參數,您可以使用'$ _REQUEST' - 它將它們結合起來。 – Barmar 2015-02-05 17:44:52
我沒有看到你添加的輸入E,中期,到窗體... – satchcoder 2015-02-05 17:47:50