由于某些原因我无法从表单到下一页获取变量send.php我试图回应它们但我看不到输出。使用进入日期时段t1是较低时段而t2是较高时段。然后在文本框中输入消息。在提交时,将日期时间段插入到db select语句中以选择联系人。然后将它们与消息一起传递给sendbulk函数。我无法得到这些变量。有人发现了什么?
<FORM ACTION="send.php" METHOD="POST">
<input type="text" name="t1" id="t1" placeholder="start">
<img src='calendar.jpg' onClick="start_cal('t1','calendar1');";>
<div id="calendar1" style=""></div>
<input type="text" id="t2" name="t2" placeholder="stop">
<img src='calendar.jpg' onClick="start_cal('t2','calendar2');";>
<div id="calendar2" style=""></div><br>
Your Message:<BR>
<TEXTAREA NAME="message" COLS=50 ROWS=6></TEXTAREA> <P>
<INPUT TYPE="SUBMIT" VALUE="Send Message">
</FORM>
//send.php has the following code
$message_sent = $_POST['message'];
$t1 = $_POST['t1'];
$t2 = $_POST['t2'];
//create database connection
$sql = "SELECT DISTINCT msisdn FROM customer WHERE time_paid BETWEEN '$t1' AND '$t2'";
$result = mysqli_query($conn, $sql);
$resultarr = mysqli_fetch_assoc($result); // fetch data
$mobilenumber = $resultarr['msisdn'];
echo "$mobilenumber"; echo "<br>";
sendbulk();
function sendbulk() {
global $message_sent;
global $mobilenumber;
echo "$message_sent";
echo "$mobilenumber";
$serviceArguments = array(
"mobilenumber" => $mobilenumber,
"message" => $message_sent
);
$client = new SoapClient("http://.......");
$result = $client->process($serviceArguments);
$conn->close();
return $result;
}
答案 0 :(得分:0)
检查以下示例;
<?php
//send.php has the following code
$message_sent = isset($_POST['message']) ? $_POST['message'] : 'There is no message';
$t1 = isset($_POST['t1']) ? $_POST['t1'] : 'default something';
$t2 = isset($_POST['t2']) ? $_POST['t2'] : 'default something';
//create database connection
$sql = "SELECT DISTINCT msisdn FROM customer WHERE time_paid BETWEEN '$t1' AND '$t2'";
$result = mysqli_query($conn, $sql);
$rowcount = mysqli_num_rows($result);
if($rowcount > 0){
$resultarr = mysqli_fetch_assoc($result); // fetch data
$mobilenumber = $resultarr['msisdn'];
// parameters goes in function...
sendbulk($mobilenumber, $message_sent);
}else{
echo 'Opppss!!! There is no result.';
}
function sendbulk($mobilenumber, $message_sent) {
global $conn;
echo "$message_sent";
echo '<br />';
echo "$mobilenumber";
$serviceArguments = array(
"mobilenumber" => $mobilenumber,
"message" => $message_sent
);
$client = new SoapClient("http://.......");
$result = $client->process($serviceArguments);
$conn->close();
return $result;
}
答案 1 :(得分:0)
让我们采取基本的例子我不知道为什么会这样,但程序是
<form enctype="multipart/form-data" action="send.php" method="post">
<input type="text" name="t1" id="t1" placeholder="start">
<input type="submit" name="submit" id="submit">
</form>
此处 enctype =“multipart / form-data”如果您想发送图片,可以使用 在send.php上你通过 print_r($ _ POST)检查 $ _ POST 它会打印你发送和接收的所有内容,发送时间,php页面
$t1 = isset($_POST['t1']) ? $_POST['t1'] : 'There is no t1';
或者只是喜欢这个
$t1 = $_POST['ti'] //then next procedures