usadarts Posted August 20, 2007 Share Posted August 20, 2007 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 ""; ?> Quote Link to comment https://forums.phpfreaks.com/topic/65752-solved-variable-not-passing-through/ Share on other sites More sharing options...
chocopi Posted August 20, 2007 Share Posted August 20, 2007 try adding method="post" into your form tag Quote Link to comment https://forums.phpfreaks.com/topic/65752-solved-variable-not-passing-through/#findComment-328464 Share on other sites More sharing options...
usadarts Posted August 20, 2007 Author Share Posted August 20, 2007 Duh.....thanks chocopi for the help. I guess this teaches me to look over code more carefully before bothering you guys. Quote Link to comment https://forums.phpfreaks.com/topic/65752-solved-variable-not-passing-through/#findComment-328470 Share on other sites More sharing options...
chocopi Posted August 20, 2007 Share Posted August 20, 2007 lol i only knew this as i remember someone saying the default is 'get' im glad it worked Quote Link to comment https://forums.phpfreaks.com/topic/65752-solved-variable-not-passing-through/#findComment-328474 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.