对数据库中的信息进行更改的按钮 [英] Button that makes changes to information within database

查看:184
本文介绍了对数据库中的信息进行更改的按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为网页编写PHP代码,显示某人的姓名和为他们提交的祷告请求。页面的想法是,管理员可以进来和编辑祈祷请求,以纠正拼写错误,拼写错误的单词等。我得到数据库填充字段没有问题。我遇到的问题是,当我点击批准祷告请求按钮,我收到页面未找到错误,我编辑的信息不会在数据库内更新。任何建议将是非常有帮助。感谢。

I am writing PHP code for a web page that displays the first and last name of someone and the prayer request that was submitted for them. The idea of the page is that an admin can come in and edit the prayer request to correct typos, misspelled words, etc. I am getting the database to populate the fields no problem. The problem I am having is that when I click the "Approve Prayer Request" button I receive a "page not found" error and the info that I edited does not update within the database. Any suggestions would be extremely helpful. Thanks.

此文件名为ApproveDenyPrayerRequest。

This file is named ApproveDenyPrayerRequest.

<?php

$username="XXXXX";
$password="XXXXX";
$database="XXXXX";

$link = mysqli_connect('XXXXXXX', $username, $password, $database);

if (!$link) {
die('Connect Error (' . mysqli_connect_errno() . ') '. mysqli_connect_error());
}

echo 'Success... ' . mysqli_get_host_info($link) . "\n";

$query = "SELECT * FROM Request";
$result = mysqli_query($link,$query); //<----- Added link
$row = mysqli_fetch_array($result);

?>

<form method="post" action="ApproveDenyPrayerRequest.php" />

<table>

<tr>
    <td>First Name:</td>
    <td><input type="text" name="first" value="<? echo "$row[Reg_F_Name]" ?>"></td>
</tr>

<tr>
    <td>Last Name:</td>
    <td><input type="text" name="last" value="<? echo "$row[Reg_L_Name]" ?>"></td>
</tr>

<tr>
    <td>Prayer Request</td>
    <td><input type="text" name="phone" value="<? echo "$row[Reg_Request]" ?>"></td>
</tr>

</table>
<input name="add" type="submit" id="add" value="Approve Prayer Request">

</form>

这是第二个CGI文件,包含实际的mySQLi调用。此文件名为PrayerRequest

Here's the second CGI file which contains the actual mySQLi calls. This file is named PrayerRequest

<?php

$username="XXXX";
$password="XXXXXXX";
$database="prayer";

mysqli_connect('hostname',$username,$password,$database);
@mysqli_select_db($database) or die( "Unable to select database");
$query = "SELECT * FROM Request";
$query2="UPDATE Request (Reg_F_Name,Reg_L_Name,Reg_Request)";
VALUES ("$row[Reg_F_Name]","$row[Reg_L_Name]","$row[Reg_Request]")
$result = mysqli_query($query);
$row = mysqli_fetch_array($result);
?>

<form method="post" action="ApproveDenyPrayerRequest.php" />

<table>

<tr>
<td>First Name:</td>
<td><input type="text" name="first" value="<? echo "$row[Reg_F_Name]" ?>"></td>
</tr>

<tr>
<td>Last Name:</td>
<td><input type="text" name="last" value="<? echo "$row[Reg_L_Name]" ?>"></td>
</tr>

<tr>
<td>Prayer Request</td>
<td><input type="text" name="phone" value="<? echo "$row[Reg_Request]" ?>"></td>
</tr>

</table>

</form>


推荐答案

我们需要知道目录结构。为了使这个脚本工作,你需要创建一个名为cgi-bin的文件夹与此脚本文件同级,然后你需要在该文件夹中放置ApproveDenyPrayerRequest.php。

We need to know to directory structure. For this script to be working you need to create a folder called "cgi-bin" at the same level as this script file and then you need to place "ApproveDenyPrayerRequest.php" in that folder.

如果cgi-bin已经存在,你需要提供正确的路径,如果它是一个lvl尝试:../cgi-bin/ApproveDenyPrayerRequest.php或者只使用绝对URL

if cgi-bin is already exist you need to supply the correct path i.e. if it is one lvl up try: "../cgi-bin/ApproveDenyPrayerRequest.php" or just use the absolute URL

这篇关于对数据库中的信息进行更改的按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆