I'm sure this has a really obvious answer; but at the moment i can't see the wood for the trees! 😕
Basically i have written a control panel for my boss to be able to dynamically change any page of his site while being online (he knows no HTML, or scripting languages).
When you select a page to edit (record in D😎 it displays the info on screen in the relevent text boxes for editing. You make your changes and click the update button. This was working fine, but for some reason refuses to work now.
I have narrowed the bug down to the record ID is not being passed over to the update script. And i can't for the life of me get it to work. I have tried using hidden fields, combing the scripts and using PHP_SELF. But whatever i do, the ID will not pass over to the update script - this is annoying because the rest of the data does!
Firstly after the record is selected it passes the ID variable to this script (that bit works).
<?
include("dbinfo.inc.php");
mysql_connect($dbhost,$un,$pw);
@mysql_select_db($db) or die( "Unable to select database");
$query="SELECT * FROM firestorm_text WHERE id='$id'";
$result=mysql_query($query);
$num=mysql_numrows($result);
$i=0;
while ($i < $num) {
$id=mysql_result($result,$i,"id");
$name=mysql_result($result,$i,"name");
$title=mysql_result($result,$i,"title");
$linktitle=mysql_result($result,$i,"linktitle");
$text=mysql_result($result,$i,"text");
$nav=mysql_result($result,$i,"nav");
mysql_close();
?>
<form action="updated.php" method="post">
ID: <input type="text" disabled="true" name="ud_id" value="<? echo "$id"; ?>">
Name: <input type="text" name="ud_name" value="<? echo "$name"?>"><br>
Title: <input type="text" name="ud_title" value="<? echo "$title"?>"><br>
Link Title: <input type="text" name="ud_linktitle" value="<? echo "$linktitle"?>"><br>
Text: <textarea rows="20" cols="100" name="ud_text"><? echo "$text"?></textarea><br>
Nav: <input type="text" name="ud_nav" value="<? echo "$nav"?>"><br>
<input name="submit_btn" type="Submit" value="Update">
</form>
<?
++$i;
}
?>
After the changes have been made, it should pass all the info into this script which should update the Database:
<?
include("dbinfo.inc.php");
mysql_connect($dbhost,$un,$pw);
mysql_select_db($db) or die( "Unable to select database");
$queryz="UPDATE firestorm_text SET name='$ud_name', title='$ud_title',
linktitle='$ud_linktitle', text='$ud_text', nav='$ud_nav' WHERE id='$ud_id'";
mysql_query($queryz);
if (!mysql_query($queryz))
{
echo "Error updating customer .$queryz";
}
echo "<center><h1>Record Updated</h1></center><br><br>";
header( 'refresh: 2; url=/ControlPanel.htm' );
echo '<center><h2>You will be re-directed in 2 seconds...</h2></center>';
echo '<center>If your browser does not support re-direction, <a href="/ControlPanel.htm"
target="_parent">Click Here</a></center>';
mysql_close();
?>
<input name="test" type="hidden" value="<?php echo $ud_id;?>">
I hope someone can help. I know this is probably really simple, but my head is going round in circles.
PS The database type is MyISAM and PHP version is 4.3.10
Thanks in advance