Jump to content

[SOLVED] Update Record


emediastudios

Recommended Posts

Quite an easy one for you PHPFREAKS, but not so for me.

I'm teaching myself with the help of these forums.

 

Im trying to echo the content in the field 'news' in a text field, and allow the ability to update the record.

I have altered a file i had on another site and have got this fay.

When i view the page i get "" only in the text box.

 

<?php
include_once('includes/include.php');
$password = "s*********";

if($_POST[password] == "" && $_SESSION[passed] != "y"){
  $content .= "<form method='post' action='admin.php'><input type='password' name='password' value='password'><input type=submit></form>";
}
else if($_POST[password] != ""){
  if($password == $_POST[password]){
   $_SESSION[passed] = "y";
  }
  else{
    echo "<script>window.location = 'admin.php';</script>";
  }
}
if($_SESSION[passed] == "y"){

$content .= '<form id="form1" name="form1" method="post" action="">
  <table width="500" border="0" align="center">
    <tr>
      <td colspan="2"><label>
        </label>
      <div align="center">Edit News</div></td>
    </tr>
    
    <tr>
      <td> </td>
      <td><div align="center">
        <textarea name="ttnews" id="ttnews" cols="55" rows="10">"'.$ttnews[news].'"</textarea>
      </div></td>
    </tr>
    <tr>
      <td> </td>
      <td><label>
        <div align="center">
          <input type="submit" name="update" id="update" value="update" />
          </div>
      </label></td>
    </tr>
    <tr>
      <td> </td>
      <td> </td>
    </tr>
  </table>
</form>';

$query = "SELECT * FROM ttnews ORDER BY id ASC";
$result = mysql_query($query) or die(mysql_error());
$ttnews=mysql_fetch_array($result);


echo $content;
}
  else{ 
  echo "You Must Be Logged In To Do That";
  }

?>

Link to comment
https://forums.phpfreaks.com/topic/110289-solved-update-record/
Share on other sites

Im hoppless  :P

 

I know someone here could do this in a second.

This is my code, full of errors i know.

 

<?php
include_once('includes/include.php');
$ttnews=$_POST['news'];
$query = "UPDATE ttnews ,$ttnews";
$result = mysql_query($query) or die(mysql_error());

header("Location: updated.php"); 

?>

 

I have 2 fileds in my ttnews table.

1d and news.

 

Link to comment
https://forums.phpfreaks.com/topic/110289-solved-update-record/#findComment-565897
Share on other sites

I changed the code to this

but it inserts nothing and erases the text that is in that field.

 

<?php
include_once('includes/include.php');
$AA=$_POST['news'];
$query = "UPDATE ttnews SET news='$AA' WHERE id=1";
$result = mysql_query($query) or die(mysql_error());

header("Location: updated.php"); 

?>

Link to comment
https://forums.phpfreaks.com/topic/110289-solved-update-record/#findComment-565899
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.