Variable not passing through

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
oche
Forum Newbie
Posts: 1
Joined: Sun Aug 19, 2007 8:18 pm

Variable not passing through

Post by oche »

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.php

Code: 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>";
		  } 

?>
posthp.php

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]
RhapX
Forum Commoner
Posts: 30
Joined: Mon Dec 05, 2005 5:24 pm
Location: Seattle, Washington

Post by RhapX »

In your form put:

Code: Select all

<form action="" method="post">
Post Reply