为什么我的PHP代码没有被执行?

时间:2013-10-15 19:44:34

标签: wordpress curl

我正在使用WordPress。我创建了i.php文件(短信API):

<?php
if (isset($_POST['submit'])) {
//Variables to POST
$user = "xxxxxx";
$password = "xxxxxxx";
$mobiles = $_POST['phone'];
$message = $_POST['msg'];
$sender = $_POST['sender'];

//Initialize CURL data to send via POST to the API
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://182.18.172.239/sendhttp.php");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,
          array('user' => $user,
                'password' => $password,
                'mobiles' => $mobiles,
                'message' => $message,
                'sender' => $sender)
          );

//Execute CURL command and return into variable $result
$result = curl_exec($ch);

//Do stuff
echo "MESSAGE SENT TO $mobiles FROM $sender. SMS delivery make take upto 10 minutes. If still not getting delivered please send it again. DND or NDNC subscribers will not receive the SMS. To deactivate DND, send STOP DND to 1909";
}
?>
<br><br><br>
<form name='sms' action='' method='post'>
Phone number<br/><input type='text' name='phone' value='' maxlength=12/>
<br/>
Sender ID (from) <br/><input type='text' name='sender' value='' maxlength=15/>
<br/>
Message : <br/><textarea rows=5 cols=30 name='msg'></textarea>
<br/>
<input type='submit' name='submit' value='Send'>
</form> 

我已将此文件(i.php)包含在我的WP主题的sidebar.php中,方法是在sidebar.php中添加此行

//Including i.php
include_once('i.php');

然后我访问了我的网站,看到只有HTML被执行,而不是PHP,请在http://androsocial.com/note3上查看

我的服务器启用了cURL。

请帮忙。谢谢!

1 个答案:

答案 0 :(得分:0)

在文件i.php

的开头添加
require('../../../wp-load.php');