Button that makes changes to information within database

喜你入骨 提交于 2019-12-25 02:22:32

问题


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.

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>

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>

回答1:


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.

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



来源:https://stackoverflow.com/questions/23036868/button-that-makes-changes-to-information-within-database

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!