- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试创建一些东西,但它不起作用。
我有一个包含类次的数据库
(Shift, Location, Start Time, End Time,...).
我创建了一个页面来搜索这些类次并显示它们。
这会提供一个表格,其中包含类次和 3 个用于编辑、删除或预订类次的链接
。
预订应将其添加到“我的 Google 日历”中。 Book 链接将 ID 发送到 Add_Event.php Google 总是尝试让我一次又一次地登录而不发送任何内容。我很绝望。昨天有效。现在它停止工作了。
search.php
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Zoeken</title>
</head>
<body>
<form action="" method="post">
<div>
<strong>Dienst: </strong> <input type="text" name="Dienst" value="<?php echo $Dienst; ?>" /><br/>
<input type="submit" name="zoeken" value="Zoeken">
</div>
</form>
<?php
if (isset($_POST['zoeken']))
{
include('connect-db.php');
$id = $_POST['id'];
$Locatie = $_POST['Locatie'];
$Periode = $_POST['Periode'];
$Dag = $_POST['Dag'];
$Dienst = $_POST['Dienst'];
// get results from database
$result = mysql_query("SELECT * FROM WMC_DeLijn WHERE Dienst='$Dienst' ")
or die(mysql_error());
// display data in table
echo "<p><b>Alles</b> | <a href='search_paginated.php?page=1'>Pagina</a></p>";
echo "<h2>Resultaten:</h2><p>";
echo "<table border='1' cellpadding='10'>";
echo "<table><tr><th>ID</th><th>Locatie</th><th>Periode</th><th>Dag</th> <th>Dienst</th><th>Delen</th><th>Geleed</th><th>Start 1</th><th>Eind 1</th> <th>Start 2</th><th>Eind 2</th><th>Lijnen</th></tr>";
// loop through results of database query, displaying them in the table
while($row = mysql_fetch_array( $result )) {
// echo out the contents of each row into a table
echo "<tr>";
echo '<td align="center">' . $row['id'] . '</td>';
echo '<td align="center">' . $row['Locatie'] . '</td>';
echo '<td align="center">' . $row['Periode'] . '</td>';
echo '<td align="center">' . $row['Dag'] . '</td>';
echo '<td align="center">' . $row['Dienst'] . '</td>';
echo '<td align="center">' . $row['Delen'] . '</td>';
echo '<td align="center">' . $row['Geleed'] . '</td>';
echo '<td align="center">' . $row['Start1'] . '</td>';
echo '<td align="center">' . $row['Eind1'] . '</td>';
echo '<td align="center">' . $row['Start2'] . '</td>';
echo '<td align="center">' . $row['Eind2'] . '</td>';
echo '<td align="center">' . $row['Lijnen'] . '</td>';
echo '<td align="center"><a href="edit.php?id=' . $row['id'] . '">Bewerken</a></td>';
echo '<td align="center"><a href="delete.php?id=' . $row['id'] . '">Verwijderen</a></td>';
echo '<td align="center"><a href="Add_Event.php?id=' . $row['id'] . '">Afspraak maken</a></td>';
echo "</tr>";
} }
// close table>
echo "</table>";
?>
<p><a href="new.php">Toevoegen</a> | <a href="search.php">Zoeken</a> | <a href="search_lijnen.php">Zoeken op lijnnummer</a></p>
Add_Event.php
<?php
error_reporting(E_ALL);
// connect to the database
include('connect-db.php');
// get the 'id' value from the URL (if it exists), making sure that it is valid (checing that it is numeric/larger than 0)
if (isset($_GET['id']) && is_numeric($_GET['id']) && $_GET['id'] > 0)
{
// query db
$id = $_GET['id'];
$result = mysql_query("SELECT * FROM WMC_DeLijn WHERE id=$id")
or die(mysql_error());
$row = mysql_fetch_array($result);
// check that the 'id' matches up with a row in the databse
if($row)
{
// get data from db
$Locatie = $row['Locatie'];
$Periode = $row['Periode'];
$Dag = $row['Dag'];
$Dienst = $row['Dienst'];
$Delen = $row['Delen'];
$Geleed = $row['Geleed'];
$Start1 = $row['Start1'];
$Eind1 = $row['Eind1'];
$Start2 = $row['Start2'];
$Eind2 = $row['Eind2'];
$Lijnen = $row['Lijnen'];
}
else
// if no match, display result
{
echo "No results!";
}
}
else
// if the 'id' in the URL isn't valid, or if there is no 'id' value, display an error
{
echo 'Error!';
}
require_once '/customers/0/c/6/wmc-corner.be/httpd.www/DeLijn/google-api-php-client/src/Google_Client.php';
require_once '/customers/0/c/6/wmc-corner.be/httpd.www/DeLijn/google-api-php-client/src/contrib/Google_CalendarService.php';
session_start();
$client = new Google_Client();
$client->setApplicationName("Diensten Boeken");
$client->setClientId('xxx.apps.googleusercontent.com');
$client->setClientSecret('xxxx');
$client->setRedirectUri('http://www.xxx.be/xxx/search.php');
$client->setDeveloperKey('AIzaSyCyEC7cIu7yJS6ao73yaFMszKwvsWGkvFc');
$cal = new Google_CalendarService($client);
if (isset($_GET['logout']))
{
unset($_SESSION['token']);
}
if (isset($_GET['code']))
{
$client->authenticate($_GET['code']);
$_SESSION['token'] = $client->getAccessToken();
header('Location: http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']);
}
if (isset($_SESSION['token']))
{
$client->setAccessToken($_SESSION['token']);
}
if ($client->getAccessToken())
{
$calList = $cal->calendarList->listCalendarList();
// print_r(get_declared_classes()); //This will dump the data of all declared classes so you can see what you have to work with
//print "<br/><br/>";
if(isset($_POST['action']))
{
$action = $_POST['action'];
if($action == "addCalEvent")
{
//Text Variables
$tBus="Bus: ";
$tLijnen="Lijnen: ";
$tDienst="Dienst ";
$tDienst1="/1";
$tDienst2="/2";
$plus="T";
$title1 = $tDienst.$fDienst.$tDienst1;
$title2 = $tDienst.$fDienst.$tDienst2;
$timezone= ".000+02:00";
//Post Variables
$title =$_POST["title"] ;
$desc = $_POST["desc"];
$calID = $_POST["calID"];
$locat = $_POST["locat"];
$ffrom = $_POST["from"];
$funtil = $_POST["until"];
$fPeriode = $_POST["Periode"];
$fDelen = $_POST["Delen"];
$fDienst = $_POST["Dienst"];
$fGeleed = $_POST["Geleed"];
$fStart1 = $_POST["Start1"];
$fEind1 = $_POST["Eind1"];
$fStart2 = $_POST["Start2"];
$fEind2 = $_POST["Eind2"];
$fDag = $_POST["Dag"];
$fLijnen = $_POST["Lijnen"];
//Time Variables
$from= $ffrom.$plus.$fStart1.$timezone;
$until= $funtil.$plus.$fEind1.$timezone;
$from1= $ffrom.$plus.$fStart2.$timezone;
$until1= $funtil.$plus.$fEind2.$timezone;
if($fDelen ='1')
{
//Set the Event data
$event = new Google_Event(); //note in the API examples it calls Event(). Apparently, they changed it and didn't update examples.
$event->setSummary($title);
$event->setDescription($desc);
$event->setLocation($locat);
$start = new Google_EventDateTime();
$start->setDateTime($from);
$event->setStart($start);
$end = new Google_EventDateTime();
$end->setDateTime($until);
$event->setEnd($end);
$attendee1 = new Google_EventAttendee();
$attendee1->setEmail('addenteeEmail');
// ...
//$attendees = array(dewit.lesley@gmail.com);
//$event->attendees = $attendees;
$createdEvent = $cal->events->insert('u4slarv7t1qn1fsblvfkdoct4c@group.calendar.google.com', $event);
// echo $createdEvent->getId();
}
else
{
$event = new Google_Event(); //note in the API examples it calls Event(). Apparently, they changed it and didn't update examples.
$event->setSummary($title1);
$event->setDescription($desc);
$event->setLocation($locat);
$start = new Google_EventDateTime();
$start->setDateTime($from);
$event->setStart($start);
$end = new Google_EventDateTime();
$end->setDateTime($until);
$event->setEnd($end);
$attendee1 = new Google_EventAttendee();
$attendee1->setEmail('addenteeEmail');
$event1 = new Google_Event(); //note in the API examples it calls Event(). Apparently, they changed it and didn't update examples.
$event1->setSummary($title2);
$event1->setDescription($desc);
$event1->setLocation($locat);
$start = new Google_EventDateTime();
$start->setDateTime($from1);
$event1->setStart($start);
$end = new Google_EventDateTime();
$end->setDateTime($until1);
$event->setEnd($end);
$attendee1 = new Google_EventAttendee();
$attendee1->setEmail('addenteeEmail');
$createdEvent = $cal->events->insert('xxx@group.calendar.google.com', $event);
// echo $createdEvent->getId();
}
}
}
// This is the form
print "<div style='width:100%;height:100%;'><div style='width:550px;height:550px;text-align:center;margin:200px auto;background-color:#f0ffff;border:1px solid black;'><div style='padding:50px;'><table>";
print "<form action='Add_Event.php' method='POST'>";
print "<tr><td>Title: </td><td><input type='text' name='title'value=' Dienst: $Dienst' id='title'></td></tr>";
print "<tr><td>Omschrijving: </td><td><input type='text' name='desc'value=' Geleed: $Geleed Lijnen: $Lijnen' id='title'></td></tr>";
print "<tr><td>Dag: </td><td><input type='text' name='locat'value='Stelplaats : $Locatie' id='desc'></td></tr>";
print "<tr><td>Periode: </td><td><input type='text' name='Periode' value='$Periode' id='locat'></td></tr>";
print "<tr><td>Dag: </td><td><input type='text' name='Dag'value='$Dag' id='desc'></td></tr>";
print "<tr><td>Dienst: </td><td><input type='text' name='Dienst' value='$Dienst' id='locat'></td></tr>";
print "<tr><td>Delen: </td><td><input type='text' name='Delen' value='$Delen' id='locat'></td></tr>";
print "<tr><td>Start1: </td><td><input type='text' name='Start1' value='$Start1' id='Start1'></td></tr>";
print "<tr><td>Eind1: </td><td><input type='text' name='Eind1' value='$Eind1' id='Eind1'></td></tr>";
print "<tr><td>Start2: </td><td><input type='text' name='Start2' value='$Start2' id='Eind1'></td></tr>";
print "<tr><td>Eind2: </td><td><input type='text' name='Eind2' value='$Eind2' id='Eind1'></td></tr>";
print "<tr><td>Geleed: </td><td><input type='text' name='Geleed'value='$Geleed' id='desc'></td></tr>";
print "<tr><td>Lijnen: </td><td><input type='text' name='Lijnen'value='$Lijnen' id='desc'></td></tr>";
print "<tr><td colspan='2'>Datum Formaat: JJJJ-MM-DDTHH</td></tr>";
print "<tr><td>From: </td><td><input type='text' name='from' id='from'></td></tr>";
print "<tr><td>To: </td><td><input type='text' name='until' id='until'></td></tr>";
print "<input type='hidden' name='action' value='addCalEvent'>";
print "<tr><td colspan='2'><div style='text-align:right;'><input type='submit' value='Submit'></div></td></tr>";
print "</form>";
print "</table></div></div></div>";
//Dumps Calendar Data so you can see what you're working with
//print "<h1>Calendar List</h1><pre>" . print_r($calList, true) . "</pre>";
$_SESSION['token'] = $client->getAccessToken();
}
else
{
$authUrl = $client->createAuthUrl();
print "<a class='login' href='$authUrl'>Verbind met Google!</a>";
}
?>
最佳答案
我能够做我需要做的事情。我重写了代码,并且使用了我的 Google 服务帐户。这暂时解决了我的问题。
关于php - 在 Google 日历中插入事件 PHP 和 SQL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31265763/
我在 JavaScript 文件中运行 PHP,例如...... var = '';). 我需要使用 JavaScript 来扫描字符串中的 PHP 定界符(打开和关闭 PHP 的 )。 我已经知道使
我希望能够做这样的事情: php --determine-oldest-supported-php-version test.php 并得到这个输出: 7.2 也就是说,php 二进制检查 test.
我正在开发一个目前不使用任何框架的大型 php 站点。我的大问题是,随着时间的推移慢慢尝试将框架融入应用程序是否可取,例如在创建的新部件和更新的旧部件中? 比如所有的页面都是直接通过url服务的,有几
下面是我的源代码,我想在同一页面顶部的另一个 php 脚本中使用位于底部 php 脚本的变量 $r1。我需要一个简单的解决方案来解决这个问题。我想在代码中存在的更新查询中使用该变量。 $name)
我正在制作一个网站,根据不同的情况进行大量 PHP 重定向。就像这样...... header("Location: somesite.com/redirectedpage.php"); 为了安全起见
我有一个旧网站,我的 php 标签从 因为短标签已经显示出安全问题,并且在未来的版本中将不被支持。 关于php - 如何避免在 php 文件中写入
我有一个用 PHP 编写的配置文件,如下所示, 所以我想用PHP开发一个接口(interface),它可以编辑文件值,如$WEBPATH , $ACCOUNTPATH和 const值(value)观
我试图制作一个登录页面来学习基本的PHP,首先我希望我的独立PHP文件存储HTML文件的输入(带有表单),但是当我按下按钮时(触发POST到PHP脚本) )我一直收到令人不愉快的错误。 我已经搜索了S
我正在寻找一种让 PHP 以一种形式打印任意数组的方法,我可以将该数组作为赋值包含在我的(测试)代码中。 print_r 产生例如: Array ( [0] => qsr-part:1285 [1]
这个问题已经有答案了: 已关闭11 年前。 Possible Duplicate: What is the max key size for an array in PHP? 正如标题所说,我想知道
我正在寻找一种让 PHP 以一种形式打印任意数组的方法,我可以将该数组作为赋值包含在我的(测试)代码中。 print_r 产生例如: Array ( [0] => qsr-part:1285 [1]
关闭。这个问题需要多问focused 。目前不接受答案。 想要改进此问题吗?更新问题,使其仅关注一个问题 editing this post . 已关闭 9 年前。 Improve this ques
我在 MySQL 数据库中有一个表,其中存储餐厅在每个工作日和时段提供的菜单。 表结构如下: i_type i_name i_cost i_day i_start i_
我有两页。 test1.php 和 test2.php。 我想做的就是在 test1.php 上点击提交,并将 test2.php 显示在 div 中。这实际上工作正常,但我需要向 test2.php
我得到了这个代码。我想通过textarea更新mysql。我在textarea中回显我的MySQL,但我不知道如何更新它,我应该把所有东西都放进去吗,因为_GET模式没有给我任何东西,我也尝试_GET
首先,我是 php 的新手,所以我仍在努力学习。我在 Wordpress 上创建了一个表单,我想将值插入一个表(data_test 表,我已经管理了),然后从 data_test 表中获取所有列(id
我有以下函数可以清理用户或网址的输入: function SanitizeString($var) { $var=stripslashes($var); $va
我有一个 html 页面,它使用 php 文件查询数据库,然后让用户登录,否则拒绝访问。我遇到的问题是它只是重定向到 php 文件的 url,并且从不对发生的事情提供反馈。这是我第一次使用 html、
我有一个页面充满了指向 pdf 的链接,我想跟踪哪些链接被单击。我以为我可以做如下的事情,但遇到了问题: query($sql); if($result){
我正在使用 从外部文本文件加载 HTML/PHP 代码 $f = fopen($filename, "r"); while ($line = fgets($f, 4096)) { print $l
我是一名优秀的程序员,十分优秀!