rikhelp Posted April 5, 2007 Share Posted April 5, 2007 currenlt i have a message board that enters information to the data base fine, but where i try to create a detele for individual comments, it does not seem to work, any ideas on how to write a delete for this so that it deletes individual messages <SCRIPT LANGUAGE="Javascript"> function MsgBox(Blank) if username="" { alert("Please Enter Your Name") } if mail="" { alert('Please Enter Your e-mail Address') } </script> </head> <body> <p> <?php //if (!$_POST['submit']) //{ if ($_POST["submit"]) { if ((!$_POST["username"]) || (!$_POST["commentdate"])|| (!$_POST["mail"])|| (!$_POST["message"])) { echo("Please complete all fields."); // form not submitted ?> </p> <p> <?php } else { // get form input // escape input values for greater safety $name = (trim($_POST['username']) == '') ? die ('ERROR: Enter a name') : mysql_escape_string($_POST['username']); $commentdate = (trim($_POST['commentdate']) == '') ? die ('ERROR: Enter a name') : mysql_escape_string($_POST['commentdate']); $mail = (trim($_POST['mail']) == '') ? die ('ERROR: Enter a email') : mysql_escape_string($_POST['mail']); $message = (trim($_POST['message']) == '') ? die ('ERROR: Enter a message') : mysql_escape_string($_POST['message']); // open connection $connection = mysql_connect('localhost', 'root', '') or die ('Unable to connect!'); // select database mysql_select_db('logforum') or die ('Unable to select database!'); // create query $query = "INSERT INTO guest (username, commentdate, mail, message ) VALUES ('$username', '$commentdate', '$mail', '$message')"; // execute query $result = mysql_query($query) or die ("Error in query: $query. " . mysql_error()); // print ID of inserted record echo 'New record inserted with ID ' . mysql_insert_id() . '<br \>'; // print number of rows affected echo mysql_affected_rows() . ' record(s) affected'; // close connection mysql_close($connection); } } ?> <a href="main.php">Click Me to Go back</a> <form action="<?php echo $_SERVER['PHP_SELF']?>" method="post"> <table width="800" height="429" border="0" align="center" bordercolor="#e5e5e5"> <caption align="top"> <span class="style4">Sperm banking User Comment</span> </caption> <tr bgcolor="#9DACDF" background="#9DACDF"> <td colspan="5" background="#9DACDF" bgcolor="#9DACDF"><span class="style14"> <div align="center" class="style8"> </span> <div align="center"> <span class="style14">Query <span class="style10">|</span> Message <span class="style10">|</span> Comments</span> </div> <div align="center" class="style9"></div></td> </tr> <tr> <td width="16" rowspan="6" bgcolor="#9DACDF"> </td> <td colspan="2" bgcolor="#7699Cc">In this Page you can post your queries & messages, give suggestions, which will be displayed in the message board & will be answered if possible. Questions related to sperm Banking & and cancer related issues, can be posted in the site which will be referred to & answered by like subject experts</td> <td width="18" colspan="2" rowspan="6" bgcolor="#9DACDF"> </td> </tr> <tr> <td width="145" bgcolor="#7699Cc"><h5 class="style12">Name: </h5></td> <td width="603" bgcolor="#7699Cc"><input name="username" type="text" size="60"> </td> </tr> <tr> <td bgcolor="#7699Cc">Date:</h5></td> <td bgcolor="#7699Cc"><input name="commentdate" type="text" value="<?PHP echo date("l d F Y");?>" size="30"> </td> </tr> <tr> <td bgcolor="#7699Cc">e-Mail:</h5></td> <td bgcolor="#7699Cc"><input name="mail" type="text" size="30"> *</td> </tr> <tr> <td valign="top" bgcolor="#7699Cc">Message: </h5></td> <td height="105" valign="top" bgcolor="#7699Cc"> <textarea name="message" cols="80" rows="10" id="message"></textarea> </span></td> </tr> <tr bgcolor="#99CCCC"> <td height="21" bgcolor="#7699Cc"> </td> <td height="21" bgcolor="#7699Cc"><div align="center"> <input type="submit" input name ="submit" id="submit" value="submit" > <input type="reset" input name="reset" id="reset" value="Reset"> </div></td> </tr> <tr bgcolor="#99CCCC"> <td height="21" colspan="5" bgcolor="#9DACDF"><p>(<span class="style19">*</span>) <span class="style25">Fill Required </span> </td> </tr> </table> </form> <div class="footer"> <?php include ("footer.html") ?> </div> </body> </html> Link to comment https://forums.phpfreaks.com/topic/45761-deleting-comments-from-database/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.