mags93:4
08-28-2015, 04:09 PM
I have two php files one for editing the second for updating, i am not sure what is missing with them as they display nothing when i click to edit a entry from the database.
This is the edit php file:
<?php
include("../dbconfig.php");
include("../../inc/menucode.php");
$result = mysql_query("SELECT * FROM Words WHERE ID = '$ID'");
$row = mysql_fetch_array($result);
?>
<script language="javaScript" src="http://www.elijahlist.com/inc/subscribevalidate.js" type="text/javascript"></script>
<script src="../../inc/AC_RunActiveContent.js" type="text/javascript"></script>
<SCRIPT TYPE="text/javascript" LANGUAGE="JavaScript">
<!--
function GetForm(myForm) {
if (myForm.category.options[myForm.category.selectedIndex].value == "") {
alert("Please choose a Category from the list!");
myForm.category.focus();
return false;
}
return true;
} // function GetForm
// -->
</SCRIPT>
</head>
<body>
<?php
include("../../inc/tooltipcode.inc");
include("../../inc/googleanalyticscode.php");
?>
<div id="container">
<table width="1000" border="0" cellspacing="0" cellpadding="0">
<tr>
<td id="top">
<?php
include ("../../inc/subscribeboxes.inc");
include ("../../inc/navbar_menu.inc");
?>
</td>
</tr>
<tr>
<td>
<table width="980" border="0" cellspacing="0" cellpadding="0">
<tr>
<td id="main">
<h1></h1>
<form method="post" action="words_update.php?ID=<?php echo $ID?>" onSubmit="return GetForm(this)">
<fieldset>
<legend>Edit A Article</legend>
<ol>
<li><label>Title:</label>
<input type="text" name="Title" size="50" value="<?php echo htmlspecialchars($row['Title']) ?>" /></li>
<li><label>Author:</label>
<input type="text" name="Author" size="50" value="<?php echo htmlspecialchars($row['Author']) ?>" /></li>
<li><label>Email Address:</label>
<input type="text" name="Email" size="50" value="<?php echo htmlspecialchars($row['Email']) ?>" /></li>
<li><label>"From" Name</label>
<input type="text" name="From" size="50" value="<?php echo htmlspecialchars($row['Source']) ?>" /></li>
<li><label>"From" URL</label>
<input type="text" name="URL" size="50" value="<?php echo htmlspecialchars($row['URL']) ?>" /></li>
<li><label>FB Image URL:</label>
<input type="text" name="image" size="50" value="<?php echo htmlspecialchars($row['image']) ?>" /> <a target="_blank" href="<?php echo htmlspecialchars($row['image']) ?>">Open Photo URL</a></li>
<li><label>Category</label>
<select name="category">
<option value="<?php echo htmlspecialchars($row[category]) ?>"><?php echo htmlspecialchars($row[category]) ?></option>
<option value="word">Word</option>
<option value="conference">Conference</option>
<option value="advertizing">Advertizing</option>
<option value="gmw">God's Mysterious Ways</option>
</select>
</li>
<li><label>Display Date</label>
<input type="text" name="Display_Date" value="<?php echo htmlspecialchars($row['Display_Date']) ?>" /></li>
<li><label>Listing Date</label>
<input type="text" name="Date_Created" value="<?php echo htmlspecialchars($row['Date_Created']) ?>" /></li>
<li><label>Active?</label>
<input type="checkbox" value="on" name="active" <?php if($row['active']) {echo "checked";} ?> /></li>
<li><label>Word</label>
<textarea name="Word" rows="15" cols="55"><?php echo $row['Word']?></textarea></li>
</ol>
</fieldset>
<fieldset class="submit">
<input type="submit" value="Submit" />
<input type="submit" name="cancel" value="Cancel" />
<input type="submit" value="Delete" name="delete" />
</fieldset>
</form>
<div style="padding-left:42px;" align="center"><a target="_blank" href="http://www.site.com/words/display_word.php?ID=<?php echo htmlspecialchars($row[ID]) ?>">Open This Word in a New Tab</a></div>
</td>
</tr>
</table>
</td>
</tr>
</table>
</div>
</body>
</html>
This is the code for update php file:
<?php
if(isset($_REQUEST["cancel"])) {
header("Location:index.html");
exit;
}
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title></title>
<?php
include("../dbconfig.php");
include("../../inc/menucode.php");
// $result = mysql_query("SELECT * FROM Words WHERE ID = '$ID'");
// $row = mysql_fetch_array($result);
?>
<script language="javaScript" src="http://www.site.com/inc/subscribevalidate.js" type="text/javascript"></script>
<script src="../../inc/AC_RunActiveContent.js" type="text/javascript"></script>
<link href="/styles/layoutstyles.css" rel="stylesheet" type="text/css" />
<link href="/styles/styles.css" rel="stylesheet" type="text/css" />
<link href="../adminstyles.css" rel="stylesheet" type="text/css" />
</head>
<body>
<?php
include("../../inc/googleanalyticscode.php");
?>
<div id="container">
<table width="1000" border="0" cellspacing="0" cellpadding="0">
<tr>
<td id="top">
<?php
include ("../../inc/subscribeboxes.inc");
include ("../../inc/navbar_menu.inc");
?>
</td>
</tr>
<tr>
<td>
<table width="1000" border="0" cellspacing="0" cellpadding="0">
<tr>
<td id="main">
<div align="center" style="font-family: verdana; margin: 20px;">
<?php
$Title = $_POST['Title'];
$Author = $_POST['Author'];
$Email = $_POST['Email'];
$Source = $_POST['From'];
$URL = $_POST['URL'];
$category = $_POST['category'];
$Display_Date = $_POST['Display_Date'];
$Date_Created = $_POST['Date_Created'];
$Active = $_POST['Active'];
$Word = $_POST['Word'];
if(isset($_REQUEST["delete"])) {
mysql_query("DELETE FROM Words WHERE ID=" . $_REQUEST["ID"]);
echo 'The Word has been successfully removed from the database.<br><br>';
echo '<a href=index.html>Return to the Words Page</a><P>';
echo '<a href=words_list.html>Return to the Words List</a>';
exit;
}
if($_REQUEST["Title"] == "")
{
$EString = 'You must include a Title.';
}
if($_REQUEST["Author"] == "")
{
$EString .= '<br>You must include an Author.';
}
if($_REQUEST["Word"] == "")
{
$EString .= '<Br>You must include a Word';
}
if(isset($EString))
{
echo $EString;
echo '<br><br>Please use your browsers back button to correct the above errors.';
exit;
}
$result = mysql_query("SELECT * FROM Words where ID = '$ID'");
$row = mysql_fetch_array($result);
$qry_string = "UPDATE Words SET";
if($row[Title] != $Title)
{
$end_string .= " Title = '$Title'";
}
if($row[Author] != $Author)
{
if(isset($end_string))
{
$end_string .= ", Author = '$Author'";
}
else
{
$end_string = " Author = '$Author'";
}
}
if($row[Display_Date] != $Display_Date)
{
if(isset($end_string))
{
$end_string .= ", Display_date = '$Display_Date'";
}
else
{
$end_string = " Display_date = '$Display_Date'";
}
}
if($row[Word] != $Word)
{
echo 'Alter Word<br>';
if(isset($end_string))
{
$end_string .= ", Word = '$Word'";
}
else
{
$end_string = " Word = '$Word'";
}
}
if($row[Date_Created] != $Date_Created)
{
if(isset($end_string))
{
$end_string .= ", Date_Created = '$Date_Created'";
}
else
{
$end_string = " Date_Created = '$Date_Created'";
}
}
if($row[Email] != $Email)
{
if(isset($end_string))
{
$end_string .= ", Email = '$Email'";
}
else
{
$end_string = " Email = '$Email'";
}
}
if($row[Source] != $From)
{
if(isset($end_string))
{
$end_string .= ", Source = '$From'";
}
else
{
$end_string = " Source = '$From'";
}
}
if($row[URL] != $URL)
{
if(isset($end_string))
{
$end_string .= ", URL = '$URL'";
}
else
{
$end_string = " URL = '$URL'";
}
}
if($row[image] != $image)
{
if(isset($end_string))
{
$end_string .= ", image = '$image'";
}
else
{
$end_string = " image = '$image'";
}
}
if($row[category] != $category)
{
if(isset($end_string))
{
$end_string .= ", category = '$category'";
}
else
{
$end_string = " category = '$category'";
}
}
$_REQUEST["active"] == "on"?$active=1:$active=0;
if($row["active"] != $active)
{
if(isset($end_string)) $end_string .= ", ";
$end_string .= "active = " . $active;
}
if(!isset($end_string))
{
echo 'There was no information to be updated.<br><br>';
echo '<a href=index.html>Return to Words Page';
exit;
}
$qry_string = $qry_string.$end_string." WHERE ID = '$ID'";
if(mysql_query($qry_string) == FALSE)
{
echo 'There was an error attempting to update the database.<br>';
echo 'Please contact the system administrator with the following information:';
echo "<br><br>Query String -> $qry_string";
echo "<br/><br/>mysql_error();";
exit;
}
echo 'The database has been updated<br><br>';
echo '<a href=index.html>Return to the Words Page</a><P>';
echo '<a href=words_list.html>Return to the Words List</a>';
?>
</div>
</td>
</table>
</div>
</body>
</html>
The trigger that loads the edit page is is hyperlink:"<td><a href=words_edit.php?ID=$row[ID]>Edit</a></td></tr>";
I am not sure of the problem here, i am thinking it may have to do with how the edit page is initially loaded. There are no errors that i am receiving it is just not displaying the data that is coming from the database. Thanks
This is the edit php file:
<?php
include("../dbconfig.php");
include("../../inc/menucode.php");
$result = mysql_query("SELECT * FROM Words WHERE ID = '$ID'");
$row = mysql_fetch_array($result);
?>
<script language="javaScript" src="http://www.elijahlist.com/inc/subscribevalidate.js" type="text/javascript"></script>
<script src="../../inc/AC_RunActiveContent.js" type="text/javascript"></script>
<SCRIPT TYPE="text/javascript" LANGUAGE="JavaScript">
<!--
function GetForm(myForm) {
if (myForm.category.options[myForm.category.selectedIndex].value == "") {
alert("Please choose a Category from the list!");
myForm.category.focus();
return false;
}
return true;
} // function GetForm
// -->
</SCRIPT>
</head>
<body>
<?php
include("../../inc/tooltipcode.inc");
include("../../inc/googleanalyticscode.php");
?>
<div id="container">
<table width="1000" border="0" cellspacing="0" cellpadding="0">
<tr>
<td id="top">
<?php
include ("../../inc/subscribeboxes.inc");
include ("../../inc/navbar_menu.inc");
?>
</td>
</tr>
<tr>
<td>
<table width="980" border="0" cellspacing="0" cellpadding="0">
<tr>
<td id="main">
<h1></h1>
<form method="post" action="words_update.php?ID=<?php echo $ID?>" onSubmit="return GetForm(this)">
<fieldset>
<legend>Edit A Article</legend>
<ol>
<li><label>Title:</label>
<input type="text" name="Title" size="50" value="<?php echo htmlspecialchars($row['Title']) ?>" /></li>
<li><label>Author:</label>
<input type="text" name="Author" size="50" value="<?php echo htmlspecialchars($row['Author']) ?>" /></li>
<li><label>Email Address:</label>
<input type="text" name="Email" size="50" value="<?php echo htmlspecialchars($row['Email']) ?>" /></li>
<li><label>"From" Name</label>
<input type="text" name="From" size="50" value="<?php echo htmlspecialchars($row['Source']) ?>" /></li>
<li><label>"From" URL</label>
<input type="text" name="URL" size="50" value="<?php echo htmlspecialchars($row['URL']) ?>" /></li>
<li><label>FB Image URL:</label>
<input type="text" name="image" size="50" value="<?php echo htmlspecialchars($row['image']) ?>" /> <a target="_blank" href="<?php echo htmlspecialchars($row['image']) ?>">Open Photo URL</a></li>
<li><label>Category</label>
<select name="category">
<option value="<?php echo htmlspecialchars($row[category]) ?>"><?php echo htmlspecialchars($row[category]) ?></option>
<option value="word">Word</option>
<option value="conference">Conference</option>
<option value="advertizing">Advertizing</option>
<option value="gmw">God's Mysterious Ways</option>
</select>
</li>
<li><label>Display Date</label>
<input type="text" name="Display_Date" value="<?php echo htmlspecialchars($row['Display_Date']) ?>" /></li>
<li><label>Listing Date</label>
<input type="text" name="Date_Created" value="<?php echo htmlspecialchars($row['Date_Created']) ?>" /></li>
<li><label>Active?</label>
<input type="checkbox" value="on" name="active" <?php if($row['active']) {echo "checked";} ?> /></li>
<li><label>Word</label>
<textarea name="Word" rows="15" cols="55"><?php echo $row['Word']?></textarea></li>
</ol>
</fieldset>
<fieldset class="submit">
<input type="submit" value="Submit" />
<input type="submit" name="cancel" value="Cancel" />
<input type="submit" value="Delete" name="delete" />
</fieldset>
</form>
<div style="padding-left:42px;" align="center"><a target="_blank" href="http://www.site.com/words/display_word.php?ID=<?php echo htmlspecialchars($row[ID]) ?>">Open This Word in a New Tab</a></div>
</td>
</tr>
</table>
</td>
</tr>
</table>
</div>
</body>
</html>
This is the code for update php file:
<?php
if(isset($_REQUEST["cancel"])) {
header("Location:index.html");
exit;
}
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title></title>
<?php
include("../dbconfig.php");
include("../../inc/menucode.php");
// $result = mysql_query("SELECT * FROM Words WHERE ID = '$ID'");
// $row = mysql_fetch_array($result);
?>
<script language="javaScript" src="http://www.site.com/inc/subscribevalidate.js" type="text/javascript"></script>
<script src="../../inc/AC_RunActiveContent.js" type="text/javascript"></script>
<link href="/styles/layoutstyles.css" rel="stylesheet" type="text/css" />
<link href="/styles/styles.css" rel="stylesheet" type="text/css" />
<link href="../adminstyles.css" rel="stylesheet" type="text/css" />
</head>
<body>
<?php
include("../../inc/googleanalyticscode.php");
?>
<div id="container">
<table width="1000" border="0" cellspacing="0" cellpadding="0">
<tr>
<td id="top">
<?php
include ("../../inc/subscribeboxes.inc");
include ("../../inc/navbar_menu.inc");
?>
</td>
</tr>
<tr>
<td>
<table width="1000" border="0" cellspacing="0" cellpadding="0">
<tr>
<td id="main">
<div align="center" style="font-family: verdana; margin: 20px;">
<?php
$Title = $_POST['Title'];
$Author = $_POST['Author'];
$Email = $_POST['Email'];
$Source = $_POST['From'];
$URL = $_POST['URL'];
$category = $_POST['category'];
$Display_Date = $_POST['Display_Date'];
$Date_Created = $_POST['Date_Created'];
$Active = $_POST['Active'];
$Word = $_POST['Word'];
if(isset($_REQUEST["delete"])) {
mysql_query("DELETE FROM Words WHERE ID=" . $_REQUEST["ID"]);
echo 'The Word has been successfully removed from the database.<br><br>';
echo '<a href=index.html>Return to the Words Page</a><P>';
echo '<a href=words_list.html>Return to the Words List</a>';
exit;
}
if($_REQUEST["Title"] == "")
{
$EString = 'You must include a Title.';
}
if($_REQUEST["Author"] == "")
{
$EString .= '<br>You must include an Author.';
}
if($_REQUEST["Word"] == "")
{
$EString .= '<Br>You must include a Word';
}
if(isset($EString))
{
echo $EString;
echo '<br><br>Please use your browsers back button to correct the above errors.';
exit;
}
$result = mysql_query("SELECT * FROM Words where ID = '$ID'");
$row = mysql_fetch_array($result);
$qry_string = "UPDATE Words SET";
if($row[Title] != $Title)
{
$end_string .= " Title = '$Title'";
}
if($row[Author] != $Author)
{
if(isset($end_string))
{
$end_string .= ", Author = '$Author'";
}
else
{
$end_string = " Author = '$Author'";
}
}
if($row[Display_Date] != $Display_Date)
{
if(isset($end_string))
{
$end_string .= ", Display_date = '$Display_Date'";
}
else
{
$end_string = " Display_date = '$Display_Date'";
}
}
if($row[Word] != $Word)
{
echo 'Alter Word<br>';
if(isset($end_string))
{
$end_string .= ", Word = '$Word'";
}
else
{
$end_string = " Word = '$Word'";
}
}
if($row[Date_Created] != $Date_Created)
{
if(isset($end_string))
{
$end_string .= ", Date_Created = '$Date_Created'";
}
else
{
$end_string = " Date_Created = '$Date_Created'";
}
}
if($row[Email] != $Email)
{
if(isset($end_string))
{
$end_string .= ", Email = '$Email'";
}
else
{
$end_string = " Email = '$Email'";
}
}
if($row[Source] != $From)
{
if(isset($end_string))
{
$end_string .= ", Source = '$From'";
}
else
{
$end_string = " Source = '$From'";
}
}
if($row[URL] != $URL)
{
if(isset($end_string))
{
$end_string .= ", URL = '$URL'";
}
else
{
$end_string = " URL = '$URL'";
}
}
if($row[image] != $image)
{
if(isset($end_string))
{
$end_string .= ", image = '$image'";
}
else
{
$end_string = " image = '$image'";
}
}
if($row[category] != $category)
{
if(isset($end_string))
{
$end_string .= ", category = '$category'";
}
else
{
$end_string = " category = '$category'";
}
}
$_REQUEST["active"] == "on"?$active=1:$active=0;
if($row["active"] != $active)
{
if(isset($end_string)) $end_string .= ", ";
$end_string .= "active = " . $active;
}
if(!isset($end_string))
{
echo 'There was no information to be updated.<br><br>';
echo '<a href=index.html>Return to Words Page';
exit;
}
$qry_string = $qry_string.$end_string." WHERE ID = '$ID'";
if(mysql_query($qry_string) == FALSE)
{
echo 'There was an error attempting to update the database.<br>';
echo 'Please contact the system administrator with the following information:';
echo "<br><br>Query String -> $qry_string";
echo "<br/><br/>mysql_error();";
exit;
}
echo 'The database has been updated<br><br>';
echo '<a href=index.html>Return to the Words Page</a><P>';
echo '<a href=words_list.html>Return to the Words List</a>';
?>
</div>
</td>
</table>
</div>
</body>
</html>
The trigger that loads the edit page is is hyperlink:"<td><a href=words_edit.php?ID=$row[ID]>Edit</a></td></tr>";
I am not sure of the problem here, i am thinking it may have to do with how the edit page is initially loaded. There are no errors that i am receiving it is just not displaying the data that is coming from the database. Thanks