Jump to content

Information Not Loading to Database


usadarts

Recommended Posts

Not sure if it has something to do with the RRN that i pass through, but when I modify the information, it does not change the database.

 

index.php

<html>
<head>
<script type="text/javascript">
<!--
function articleHandler(form){
var URL = "http://www.websites.com/cpanel/updatearticles?rrn="+articles.rrn.value;
window.location.href = URL;
}
//-->
</SCRIPT>
<style type="text/css">
<!--
.style2 {color: #808080}
-->
</style>
</head>
<body>
<center>
  <table width="75%" valign="top">
    <tr>
      <td><?php
$dbh=mysql_connect ("localhost", "xxxxxxxx", "xxxxxxxx") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("xxxxxxxx"); 

$query = "SELECT * FROM `articles` ORDER BY `date` DESC";
$result = mysql_query($query,$dbh) or die(mysql_error());

if (result){
		 echo "<center><form name=\"articles\">";
	     echo "<select name=\"rrn\" size=1 onChange=\"javascript:articleHandler()\">";
   			 echo "<option value=''>Select Article To Update</option>";		

while($row = mysql_fetch_array($result))
		  	{
   			 echo "<option value='{$row['rrn']}'>{$row['date']} - {$row['title']}</option>";		
			} 
	     echo '</select></form></center>';
		}
?>
        <?php
$dbh=mysql_connect ("localhost", "xxxxxxxxx", "xxxxxxxx") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("xxxxxxxx"); 
$rrn = $_GET['rrn']; 

$queryr = "SELECT * FROM `articles` WHERE `rrn` = '$rrn'";
$resultr = mysql_query($queryr,$dbh) or die(mysql_error());

while($row = mysql_fetch_array($resultr))
	  {
	    echo "<center><font size=+2>Add News Articles</font>";
		echo "<form action=\"post.php?$rrn\" method=\"post\">";

		echo "<textarea name=\"title\" cols=\"50\" rows=\"1\">";
		echo $row['title'];
		echo "</textarea><br>";

		echo "<textarea name=\"author\" cols=\"50\" rows=\"1\">";
		echo $row['author'];
		echo "</textarea><br>";

		echo "<textarea name=\"date\" cols=\"20\" rows=\"1\">";
		echo $row['date'];
		echo "</textarea><br>";

		echo "<textarea name=\"newcomments\" cols=\"100\" rows=\"50\">";
		echo $row['info'];
		echo "</textarea><br>";

		echo "<input type=\"submit\">";
		echo "</form></center>";
	  } 

?>
      </td>
    </tr>
  </table>
</center>
</body>
</html>

 

 

post.php code

<?php 
$title = $_POST['title'];
$author = $_POST['author'];
$date = $_POST['date'];
$info = $_POST['info'];
$str     = $info;
$order   = array("\r\n", "\n", "\r");
$replace = '<br />';
$newstr = str_replace($order, $replace, $str);
$rrn = $_GET['rrn']; 

str_replace("/r/n","<br><br>",'$info');

$dbh=mysql_connect ("localhost", "xxxxxxxxxxx", "xxxxxxxx") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("xxxxxxxxx"); 

$insert =  "UPDATE article SET title='$title', author='$author', date='$date',  info='$newstr' WHERE rrn=$rrn";

$results = mysql_query($insert);

echo "<center>Article Modified - <a href=\"../index.php\"><font size=\"4\">BACK TO CONTROL PANEL</font></A></center>";
echo "";
?>

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.