Jump to content

Recommended Posts

here is my code.. but i dont think i have done it right

 

<?php
    
if (isset($_POST['edit'])) {

$threadid =  mysql_real_escape_string( $_POST['id']);
$message = $_POST['message'];
echo $message; 
 $query = "UPDATE forumtutorial_posts SET  post = '$message' WHERE postid='$threadid' ";
echo $query;
mysql_query($query) or die('Error, query failed');
header( "refresh: 0; url=http://www.runningprofiles.com/members/index.php?page=message&forum=general&id=$id");  
}
elseif if(isset($_POST['deletepost'])){

	mysql_query("DELETE FROM forumtutorial_posts WHERE postid='$threadid'") 
or die(mysql_error()); 



}else{


?>

<script src="../../css/SpryCollapsiblePanel.js" type="text/javascript"></script>
      <link href="http://www.runningprofiles.com/css/SpryCollapsiblePanel.css" rel="stylesheet" type="text/css" />
      <div id="CollapsiblePanel1" class="CollapsiblePanel">
  <div class="CollapsiblePanelTab" tabindex="0"> Edit</div>
  <div class="CollapsiblePanelContent">
<form name='input' action='index.php?page=message&forum=general&id=<? echo $id ?>' method='post'>
<input type="hidden" name="id" value="<?php echo $getreplies3['postid'] ?>">
<div align="center">
  <label>
  <textarea class='inputforum' name="message" id="message" cols="500" rows="5"><? echo $message; ?></textarea>
  </label>
      	  <input type='checkbox' name='deletepost'> 
 delete post<br/>
  <br/>
  
  
    <input type='submit' name='edit' class="submit-btn"  value=''/>
  </div>
</form>	  <?
}
?></div>
</div>


<script type="text/javascript">
<!--
var CollapsiblePanel1 = new Spry.Widget.CollapsiblePanel("CollapsiblePanel1", {contentIsOpen:false});
//-->
      </script>

 

 

you see i want it so if  <input type='checkbox' name='deletepost'>  is ticked then it deletes the post and i thought i would do it by this elseif if(isset($_POST['deletepost'])){

 

mysql_query("DELETE FROM forumtutorial_posts WHERE postid='$threadid'")

or die(mysql_error());  but will that detect if ticked do it of not just do if (isset($_POST['edit'])) {

I could be wrong (guru's, correct me if I am), but I think $_POST['deletepost'] will be set whether it's checked or not, so isset isn't what you want.  Instead, add a value to the HTML:

 

<input type="checkbox" name="deletepost" value="deletepost" />

 

Then, check if $_POST['deletepost'] == 'deletepost'.

ok i gave it ago and

 

<?php
    
if (isset($_POST['edit'])) {

$threadid =  mysql_real_escape_string( $_POST['id']);
$message = $_POST['message'];
echo $message; 
 $query = "UPDATE forumtutorial_posts SET  post = '$message' WHERE postid='$threadid' ";
echo $query;
mysql_query($query) or die('Error, query failed');
header( "refresh: 0; url=http://www.runningprofiles.com/members/index.php?page=message&forum=general&id=$id");  
}
elseif ($_POST['deletepost'] == 'deletepost'){

	mysql_query("DELETE FROM forumtutorial_posts WHERE postid='$threadid'") 
or die(mysql_error()); 



}else{


?>

<script src="../../css/SpryCollapsiblePanel.js" type="text/javascript"></script>
      <link href="http://www.runningprofiles.com/css/SpryCollapsiblePanel.css" rel="stylesheet" type="text/css" />
      <div id="CollapsiblePanel1" class="CollapsiblePanel">
  <div class="CollapsiblePanelTab" tabindex="0"> Edit</div>
  <div class="CollapsiblePanelContent">
<form name='input' action='index.php?page=message&forum=general&id=<? echo $id ?>' method='post'>
<input type="hidden" name="id" value="<?php echo $getreplies3['postid'] ?>">
<div align="center">
  <label>
  <textarea class='inputforum' name="message" id="message" cols="500" rows="5"><? echo $message; ?></textarea>
  </label>
      	  <input type="checkbox" name="deletepost" value="deletepost" />
 delete post<br/>
  <br/>
  
  
    <input type='submit' name='edit' class="submit-btn"  value=''/>
  </div>
</form>	  <?
}
?></div>
</div>


<script type="text/javascript">
<!--
var CollapsiblePanel1 = new Spry.Widget.CollapsiblePanel("CollapsiblePanel1", {contentIsOpen:false});
//-->
      </script>

 

will update the post still so thats all good.... but will not delete post if its checked

 

ah yes i see...i did this tho elseif ($_POST['deletepost'] == 'deletepost'){

$threadid =  mysql_real_escape_string( $_POST['id']);

mysql_query("DELETE FROM forumtutorial_posts WHERE postid='$threadid'")

or die(mysql_error()); 

 

 

and still fails to delet

ah ok hang on iv just relised something

 

<?php if (isset($_POST['edit'])) {

$threadid =  mysql_real_escape_string( $_POST['id']);
$message = $_POST['message'];
echo $message; 
 $query = "UPDATE forumtutorial_posts SET  post = '$message' WHERE postid='$threadid' ";
echo $query;
mysql_query($query) or die('Error, query failed');
header( "refresh: 0; url=http://www.runningprofiles.com/members/index.php?page=message&forum=general&id=$id");  
}
elseif ($_POST['deletepost'] == 'deletepost'){
	$threadid =  mysql_real_escape_string( $_POST['id']);
	mysql_query("DELETE FROM forumtutorial_posts WHERE postid='$threadid'") 
or die(mysql_error()); ?>

 

its not even going to elseif ($_POST['deletepost'] == 'deletepost'){  because i keep getting header( "refresh: 0; url=http://www.runningprofiles.com/members/index.php?page=message&forum=general&id=$id"); 

ah ok hang on iv just relised something

 

its not even going to elseif ($_POST['deletepost'] == 'deletepost'){   because i keep getting header( "refresh: 0; url=http://www.runningprofiles.com/members/index.php?page=message&forum=general&id=$id"); 

 

then this must always be true:

 

if (isset($_POST['edit'])) {

 

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.