我遇到一个问题,用户可以将事件提交给日历,但我无法将它们重定向回原始页面.我尝试过使用:
header("Location: http://localhost/Project/View/Home.php");
exit;
但我收到一条消息此网页有一个重定向循环
HTML – Home.php
Content:
style="border: 0" width="1000" height="600" frameborder="0" scrolling="no">
PHP – Cal.php
$path = '/opt/lampp/htdocs/Project/ZendGdata-1.12.0/library';
$oldPath = set_include_path(get_include_path() . PATH_SEPARATOR . $path);
require_once 'Zend/Loader.php';
Zend_Loader::loadClass('Zend_Gdata');
Zend_Loader::loadClass('Zend_Gdata_ClientLogin');
Zend_Loader::loadClass('Zend_Gdata_Calendar');
// User whose calendars you want to access
$user = 'email@gmail.com';
$pass = 'password';
$serviceName = Zend_Gdata_Calendar::AUTH_SERVICE_NAME; // predefined service name for calendar
$client = Zend_Gdata_ClientLogin::getHttpClient($user, $pass, $serviceName);
$service = new Zend_Gdata_Calendar($client);
// Create a new event object using calendar service's factory method.
// We will then set different attributes of event in this object.
$event= $service->newEventEntry();
// Create a new title instance and set it in the event
$event->title = $service->newTitle("Service");
$event->content = $service->newContent(isset($_POST["Content"]));
// Create an object of When and set start and end datetime for the event
$when = $service->newWhen();
// Set start and end times in RFC3339 (http://www.ietf.org/rfc/rfc3339.txt)
$when->startTime = "2012-10-20T16:30:00.000+05:30"; // 8th July 2010, 4:30 pm (+5:30 GMT)
$when->endTime = "2012-10-20T17:30:00.000+05:30"; // 8th July 2010, 5:30 pm (+5:30 GMT)
// Set the when attribute for the event
$event->when = array($when);
// Create the event on google server
$newEvent = $service->insertEvent($event);
// URI of the new event which can be saved locally for later use
$eventUri = $newEvent->id->text;
header("Location: http://localhost/Project/View/Home.php");
exit;
?>
解决方法:
看起来原因是
在你的home.php
您需要在标题重定向周围添加条件.
您可以使用:
if(isset($_POST['Content']))
header("Location: http://localhost/Project/View/Home.php");
标签:html,php,redirect,header
来源: https://codeday.me/bug/20190901/1785102.html