Jump to content

[SOLVED] php edit is editing everything!


runnerjp

Recommended Posts

ok i have my forumedit.php

 

<?php
$forumlock=0;// default value if it's not set
if (isset($_POST['edit'])) {
if(isset($_POST['forumlock'])){
	$forumlock=1;
}else{
	$forumlock=0;
}
$title = $_POST['title'];
$query = "UPDATE forumtutorial_posts SET forumlock = '$forumlock', title = '$title' WHERE postid='$getthreads3[postid]' ";
mysql_query($query) or die('Error, query failed');
echo "Your title is ". $title . "<br />";
}else{
$check = '';
if($forumlock==1) {
	$check = "CHECKED";
}

?>

<h4> </h4>
<form name='input' action='index.php?page=forum&forum=<? echo $forum ?>' method='post'>

Title:
  <input class='input' name='title' type='text' value='<? echo $getthreads3[title];?>' />
  <br/>
  <input type='checkbox' name='forumlock' $check> Lock a Room<br/>
<input type='submit' name='edit' value='edit'/>
</form>
    
  <?
}
?>

 

i have included it here

 

<table class='maintable'>

<tr class='headline'><td colspan="3">Topic</td><td width=20%>Topic Starter</td><td width="5%">Replies</td><td width="25%">Last replied time</td></tr>
<?php

$getthreads="Select * from forumtutorial_posts where parentid='0' and forum = '$forum' ORDER BY lastrepliedto DESC $max";


$getthreads2=mysql_query($getthreads) or die("Could not get threads");

while($getthreads3=mysql_fetch_array($getthreads2))

{

  $getthreads3[title]=strip_tags($getthreads3[title]);

  $getthreads3[author]=strip_tags($getthreads3[author]);
  $getthreads3[important]=strip_tags($getthreads3[important]);
      $important=$getthreads3['important'];
?>
<tr <?php if($important==1) {
    $class = "mainrow1";
} else {
    $class = "mainrow";
}  ?> class="<?php echo $class?>"><td width="3%"><?php if($getthreads3[author] == $puser){ ?> <img src="http://www.runningprofiles.com/images/my folder.gif" alt="My" /> <?}   else { echo 'nooo'; } ?>
   <td width="4%" align="center" valign="middle"><?php  if($getthreads3['forumlock'] == 1){echo' <img src="http://www.runningprofiles.com/images/quick_lock.gif" alt="locked"/>';} ?></td>
<td><a href='index.php?page=message&id=<?php echo $getthreads3[postid] ?>'><? echo $getthreads3[title] ?></a>
        <div align="right"><?php if($id == 1){ ?>
     <a href="index.php?page=editforum&id=<?php echo $getthreads3[postid];?>"><img src="http://www.runningprofiles.com/images/help_icon.gif" border="0"  /></a>
     <?php ;} ?>
   </div><?php include 'editforum.php';?></td>
  <td><?php echo $getthreads3[author]?> </td><td align="center"><?php echo $getthreads3[numreplies]?></td>
  <td><?php echo $getthreads3[showtime]?><br>Last post by <b><?php echo $getthreads3[lastposter]?> </b></td></tr>
<?php
}
?>
</table>

 

as you can see it says

<?php include 'editforum.php';?>

 

 

the thing is it updates the subject and locks it ok but it updates and locks all of then to the same value!!

Link to comment
https://forums.phpfreaks.com/topic/108114-solved-php-edit-is-editing-everything/
Share on other sites

Man, where is $getthreads3[postid] defined? (The one in the SQL query)

 

$query = "UPDATE forumtutorial_posts SET forumlock = '$forumlock', title = '$title' WHERE postid='$getthreads3[postid]' ";

 

You need to pass the id of the value you're editing to the code with a hidden input box or something.

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.