[英]Form won't post
我正在尝试使用PHP / POST / etc来帮助我作为Webdev的日常工作。 从教程等中,我在网上看到过,这应该可行。 但是,当我单击提交时,页面将重定向到bagelBack.php
,但是有一个空白页面,并且该鸣叫未提交。 我使用XAMPP Apache在自己的计算机上。 (如果有帮助,HTML页面上有jQuery)
编辑:它在php的第40行上失败了( $connection->request
等)。 var_dump
工作,但是echo
不能。 我是这一切的新手。 为什么这不会引发错误?
HTML:
<form id="bagelForm" action="bagelBack.php" method="POST">
<label for="twitterName">Twitter Name: </label><input type="text" id="twitterName" name="twitterName"/><br />
<label for="bagelType">Bagel Type: </label><input type="text" id="bagelType" name="bagelType"/><br />
<input type="submit" />
</form>
PHP(大部分来自此处 ):
<?php
/**
* bagelBack.php
* Example of posting a tweet with OAuth
* Latest copy of this code:
* http://140dev.com/twitter-api-programming-tutorials/hello-twitter-oauth-php/
* @author Adam Green <140dev@gmail.com>
* @license GNU Public License
*/
$name = "@".$_POST['twitterName'];
$type = $_POST['bagelType'];
$tweet_text = $name.", your ".$type." bagel has finished toasting!";
$result = post_tweet($tweet_text);
echo "Response code: " . $result . "\n";
function post_tweet($tweet_text) {
// Use Matt Harris' OAuth library to make the connection
// This lives at: https://github.com/themattharris/tmhOAuth
require_once('tmhOAuth.php');
// Set the authorization values
// In keeping with the OAuth tradition of maximum confusion,
// the names of some of these values are different from the Twitter Dev interface
// user_token is called Access Token on the Dev site
// user_secret is called Access Token Secret on the Dev site
// The values here have asterisks to hide the true contents
// You need to use the actual values from Twitter
$connection = new tmhOAuth(array(
'consumer_key' => '[redacted]',
'consumer_secret' => '[redacted]',
'user_token' => '[redacted]',
'user_secret' => '[redacted]'
));
// Make the API call
$connection->request('POST',
$connection->url('1/statuses/update'),
array('status' => $tweet_text));
return $connection->response['code'];
}
?>
我在遇到相同问题时写了这篇文章:
http://www.highonphp.com/php-fastcgi-post-requests-failing
它与已安装Web主机的fcgi vs cgi SAPI有关。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.