Variable not passing through
Posted: Sun Aug 19, 2007 8:24 pm
feyd | Please use
posthp.php
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Have a form that loads database information which could then be modified to update the database with the new information. The date changes fine, but the newcomments is not being past to the posthp.php.
ModifyHP.phpCode: Select all
<?php
$dbh=mysql_connect ("xxxxxxxx", "xxxxxxxx_xxxxxxxx", "xxxxxxxx") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("xxxxxxxx_xxxxxxxx");
$query = "SELECT * FROM `homepage`";
$result = mysql_query($query,$dbh) or die(mysql_error());
while($row = mysql_fetch_array($result))
{
echo "<font size=+2>Modify Home Page</font>";
echo "<form action=\"posthp.php\">";
echo "<textarea name=\"newcomments\" cols=\"100\" rows=\"40\">";
echo $row['comments'];
echo "</textarea>";
echo "<br>";
echo "<input type=\"submit\">";
echo "</form>";
}
?>Code: Select all
<?php
$newcomments = $_POST['newcomments'];
$date = date('ymd');
$dbh=mysql_connect ("xxxxxxxx", "xxxxxxxx_xxxxxxxx", "xxxxxxxx") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("xxxxxxxx_xxxxxxxx");
$sql = "UPDATE homepage SET date='$date', comments='$newcomments' WHERE rrn='1'";
$result = mysql_query($sql) or die('I cannot update database: "' . mysql_error());
echo "<center>Home Page Updated - <a href=\"index.php\"><font size=\"4\">BACK TO CONTROL PANEL</font></A></center>";
echo "";
?>feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]