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