Jump to content

[SOLVED] Variable not passing through


usadarts

Recommended Posts

Not quit there yet.  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

<?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

<?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 "";
?>

Link to comment
https://forums.phpfreaks.com/topic/65752-solved-variable-not-passing-through/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.