gpt4 book ai didi

PHP 使用 Google OpenID 编辑帖子

转载 作者:行者123 更新时间:2023-11-30 00:11:18 25 4
gpt4 key购买 nike

我正在尝试为我的网站编写一个编辑帖子页面,该页面使用 google openid 登录向自身发布帖子,但是我只是得到一个空白页面,而不是编辑表单。这是我正在使用的代码:

<html>
<head>
<title>BQuotes</title>
<!-- <meta name="viewport" content="width=device-width, initial-scale=1"> -->
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<link href="votingfiles/voting.css" rel="stylesheet" type="text/css" />
<script src="votingfiles/voting.js" type="text/javascript"></script>
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.4.2/jquery.mobile-1.4.2.min.css" />
<link rel="stylesheet" type="text/css" href="http://bquotes.me/mystyle-a.css">
<script src="http://code.jquery.com/jquery-1.10.0.min.js"></script>
<script src="http://code.jquery.com/mobile/1.4.2/jquery.mobile-1.4.2.min.js"></script>
<style>
.head_text {
color: #ffffff;
}
a {
text-decoration: none;
}
</style>

<script type="text/javascript">
$('#g-login').bind('click', function (event) {
// event.preventDefault();
// $('#form-id').attr('action', 'google-login.php').trigger('submit');
alert("Clicked");
});
</script>
</head>
<body style="color:#d4ffaa">


<!-- BQ Edit Post Start -->
<div data-role="page" id="editPost">
<div data-role="header" style="background-color:#5FBF00">
<h1 class="head_text">BQuotes: Edit Statuses</h1>
</div>
<div data-role="main" class="ui-content">

<?php





?>


</div>



<?php
define ('HOSTNAME', 'host');
define ('USERNAME', 'user');
define ('PASSWORD', 'pass');
define ('DATABASE_NAME', 'db');

$db = mysql_connect(HOSTNAME, USERNAME, PASSWORD) or die ('I cannot connect to MySQL.');

mysql_select_db(DATABASE_NAME);

$tbl='table';
$id=$_POST['pid'];

$query="SELECT * from $tbl WHERE $id=id";
$result = mysql_query($query);

while($row = mysql_fetch_array($result)) {
$id=$row['id'];
$username=$row['username'];
$message=$row['message'];
$tag=$row['tag'];



session_start();
if($_SESSION['myusername'] != null && isset($_SESSION['myusername'])){
echo "<form action='logout.php' method='post' id ='form-logout' data-ajax='false'>
<br/><input type='submit' value='Logout'/>";
echo "</form>";
echo "<div style='margin-left:20px;'>Logged In As: ".$_SESSION['myusername']."</div>";

echo "<form name='post-edit' action='' method='post'>";
echo "<input type='hidden' name='id' value=".$row['id'].">";
echo "<input type='hidden' name='username' value=".$row['username'].">";
echo "<textarea name='message' value=".$row['message'].">";
echo "<input type='text' name='tag' value=".$row['tag'].">";
echo "<input type='submit' name='submit' value='Edit!'>";
echo "</form>";

}
else if($_SESSION['myusername'] == null){
echo "<form action='google-login.php?login=true' method='post' id ='form-id' data-ajax='false'>";
echo "<span class='loginreq'>Login to Edit</span>";
echo "<br/><input type='submit' value='Login with Google'/>";
echo "</form>";
}
}



if (isset($_POST['submit'])) {

$query = "UPDATE mybq_post_txt_main SET message=$message, tag=$tag WHERE id=$id ";

$result = mysql_query($query);

while ($row = mysql_fetch_array($result)) {

echo "Your post has been edited to:";<br>
echo $row['message'];
echo $row['tag'];
}

mysql_free_result($result);
mysql_close();

}

?>



<a href='mybq-index.php'>Home</a>


</div>


</body>
</html>

任何帮助将不胜感激。 (别介意 PHP SQL 语句,稍后我会将它们转换为 PDO)。

最佳答案

$query="SELECT * from $tbl WHERE $id=id";

应该是

$query="SELECT * from $tbl WHERE id=$id";

(即翻转“id”,将 SQL 列放在第一位,然后将 PHP 变量放在第二位)

不确定这是否能解决所有问题,但这是我首先想到的事情。

关于PHP 使用 Google OpenID 编辑帖子,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24027918/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com