PHP - Make Approve Deny And Delete Queries Work
I can't seem to figure this out. The queries seem to need to be in the foreach loop. The queries will then work but they update every blog post in my table. I only want it to update the 1 that has the button associated with it. So for instance... only delete the blog post where post_id = ${post['id']}
Do I make the queries be outside of the foreach? If I do that then MySQL fails because my foreach is using the $post variable. Code: [Select] <?php if (isset($_POST['approve'])) { $sql = " UPDATE `blog_posts` SET `approved` = 1 WHERE `post_id` = '${post['id']}' "; mysql_query($sql) or die(mysql_error()); } else if (isset($_POST['deny'])) { $sql = " UPDATE `blog_posts` SET `approved` = -1 WHERE `post_id` = '${post['id']}' "; } else if (isset($_POST['delete'])) { mysql_query("DELETE FROM `blog_posts` WHERE `post_id` = {$post['id']}") or die(mysql_error()); } foreach ($posts as $post) { ?> <div class="post" id="post<?php echo $post['id']; ?>"> <form action="blog.php" method="post" id="blogform" class="man"> <fieldset class="mvs buttonfield"> <span class="button"> <label> <input type="submit" id="starttop" name="approve" class="invis dark_grey" value="Approve" /> </label> </span> <span id="smarktop" class="button disabled"> <label> <input type="button" id="marktop" name="deny" class="invis dark_grey" value="Deny" disabled="disabled" /> </label> </span> <span id="sdeletetop" class="button disabled"> <label> <input type="submit" id="deletetop" name="delete" class="invis dark_grey" value="Delete" disabled="disabled" /> </label> </span> </fieldset> </form> </div> <?php } ?> Similar TutorialsUPDATE: If I remove lastedit = NOW() from the query, and just leave SET content = $var, it works. :/ If already double checked to see if a user would make it to this point in the code, and they do. And the variable $pid IS assigned a value. I've also done a quick check and changed the UPDATE queries to SELECT queries, and then echoed out the number of rows and it returned a successful result. Yet, people still can't seem to have their posts updated...why? My code: //if it's a thread, update the thread, if it's a post, update the post if($type == 2) { //update thread mysql_query("UPDATE threads SET lastedit = NOW() AND content = '{$content}' WHERE id = {$id}") or die(mysql_error()); //send them to their post redirect('viewthread.php?forum='. $forum_id .'&id='. $id .'&page='. $page); } else { //update post mysql_query("UPDATE posts SET lastedit = NOW() AND content = '{$content}' WHERE id = {$pid}") or die(mysql_error()); //send them to their post redirect('viewthread.php?forum='. $forum_id .'&id='. $id .'&page='. $page .'&post='. $post); } Hi there, As the question says i tried several things but i can't work it out and my knowledge about php isn't that well. Hi im new to php and I need help making webpage that queries a mysql database based on a 3 check boxes and displays results on the same page or on another page. The table being queried has 4 columns, name, gps, wifi, bluetooth. So for example a row in the table would be like, samsung galaxy s2, yes, yes, yes. The idea is for it to be a website that will display phones according to their features. So the idea is depending on if the boxes were ticked the samsung galaxy would be displayed as a result. So i need some help understanding how to make this. Some1 gave me the code below in attempt to help me (im not sure it works or not) but im not sure how fully use it, ie what pages i need to make and how i create the connection to the mysql database, and how to use the query that they wrote to display the results thanks code: Code: [Select] <form action="?do=filter" method="post"> <table cellspacing="0" cellpadding="3" border="1"> <tr> <td>GPS<input type="checkbox" name="gps" value="checked"></td> <td>Wifi<input type="checkbox" name="wifi" value="checked"></td> <td>Bluetooth<input type="checkbox" name="bluetooth" value="checked"></td> </tr> <tr><td><input type='submit' name='filter' value='Filter'></td></tr> </table> </form> </html> <?php function filterMe($filter){ if(isset($_POST[$filter])){ return "Yes"; }else{ return "No"; } } if(isset($_POST['filter'])){ echo "Gps - " . filterMe('gps'); echo " Wifi - " . filterMe('wifi'); echo " Bluetooth - " . filterMe('bluetooth'); } ?> All you need to do is use a query something like SELECT name,gps,wifi,bluetooth FROM `product` WHERE `gps`='".filterMe('gps')."' AND `wifi`='".filterMe('wifi')."' AND `bluetooth`='".filterMe('bluetooth')."' Hi, I dont know what doing wrong Code: [Select] <form ... <?php if($_POST['DeleteActor']) { mysql_query( 'DELETE FROM `n_dramaact` WHERE `n_dramaact_id` = "' . $_POST['n_dramaact_id'] . '"'); } // Reload from dBase $QueryDramActReturn = mysql_query( 'SELECT `n_dramaact`.`n_dramaact_id`, `n_dramaact`.`n_dramaact_dramid`, `n_dramaact`.`n_dramaact_dramact`, `n_actor`.`n_actor_id`, `n_actor`.`n_actor_fname`, `n_actor`.`n_actor_name`, `n_drama`.`n_drama_id`, `n_drama`.`n_drama_title` FROM `n_dramaact` Inner Join `n_actor` ON `n_actor`.`n_actor_id` = `n_dramaact`.`n_dramaact_dramact` Inner Join `n_drama` ON `n_drama`.`n_drama_id` = `n_dramaact`.`n_dramaact_dramid` WHERE `n_drama`.`n_drama_id` = "' . $REQUEST['n_drama_id'] . '" ORDER BY `n_actor_fname` ASC '); // Check query if(!$QueryDramActReturn) { echo mysql_error(); exit; } // Request query while($REQUESTDR = mysql_fetch_array ($QueryDramActReturn)) { ?> <div style="display: block; float: left; margin-left: 5px; margin-bottom: 5px;"> <?php echo $REQUESTDR['n_actor_fname'] . ' ' . $REQUESTDR['n_actor_name'];?> <input type="submit" name="DeleteActor" value="<-X" class="SubmitDelActor" /> <input type="hidden" name="n_dramaact_id" value="<?php echo $REQUESTDR['n_dramaact_id'];?>" /> </div> <?php }?> ....</form> I dont understand why when a push one of the listed DeleteActor submit button delete the last n_dramaact_id from table - every listed Submit button have the own (hidden) n_dramaact_id? thanx in advanced T Hi I have made this simple login page by setcookies function and I want now to make a logout button. Here the codeĀ <?php /* PHP Form Login Remember Functionality with Cookies */ if(!empty($_POST["remember"])) { setcookie ("username",$_POST["username"],time()+ 3600); setcookie ("password",$_POST["password"],time()+ 3600); setcookie ("color",$_POST["color"],time()+ 3600); //3600 = 1 hour //86400 = 1 day //(8640*30) = 1 month echo "Cookies Set Successfuly"; } else { setcookie("username",""); setcookie("password",""); setcookie("color",""); echo "Cookies Not Set"; } ?> <form action="Cookies.php" method="post" style="border: 2px dotted blue; text-align:center; width: 400px;"> <p>Welcome <?php echo ( !empty($_POST ['username']) ) ? $_POST ['username'] : 'USER'; ?> </p> <p>Username: <input name="username" type="text" value="<?php if(isset($_COOKIE["username"])) { echo $_COOKIE["username"],( !empty($_POST ['username']) ) ? $_POST ['username'] : '';} ?>" > </p> <p>Password: <input name="password" type="password" value=" <?php if(isset($_COOKIE["password"])) { echo $_COOKIE["password"]; } ?>" > </p> <p>Choose Your Favorite Color: <input name="color" type="color" value="<?php if(isset($_COOKIE["color"])) { echo $_COOKIE["color"]; } ?>"> </p> <p><input type="checkbox" name="remember" /> Remember me</p> <p><input type="submit" value="Login"></p> </form> Any idea ?? Hi guys can any one see hy tis won't work <?php require_once 'login.php'; $db_server = mysql_connect($db_hostname, $db_username, $db_password); if (!$db_server) { die ("Unabl to connect to MySQL" . mysql_error()); } mysql_select_db($db_database, $db_server) or die("Unable to connect to database: " . mysql_error()); if (isset($_POST['author'])&& isset($_POST['title'])&& isset($_POST['category'])&& isset($_POST['year'])&& isset($_POST['isbn'])) { $author = get_post('author'); $title = get_post('title'); $category = get_post('category'); $year = get_post('year'); $isbn = get_post('isbn'); if (isset($_POST['delete']) && $isbn != "") { $query = "DELETE FROM tblCLassics WHERE isbn='$isbn'"; if (!mysql_query($query, $db_server)) { echo "DELETE failed: $query<br />" . mysql_error() . "<br /><br />"; } } else { $query = "INSERT INTO tblClassics VALUES" . "('$author','$title','$category','$year','$isbn')"; if (!mysql_query($query, $db_server)) { echo "INSERT Failed: $query<br />" . mysql_error() . "<br /><br />"; } } } echo <<<_END <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Welcome to the Book Club</title> </head> <body> <form action="connectionTest.php" method="post"><pre> Author: <input type="text" name="author" /> Title: <input type="text" name="title" /> Category: <input type="text" name="category" /> Year: <input type="text" name="year" /> ISBN: <input type="text" name="isbn" /> <input type="submit" value="ADD RECORD" /></pre> </form> _END; $query = "SELECT * FROM tblClassics"; $results = mysql_query($query); if (!$results) { die("Database access failed: " . mysql_error()); } $rows = mysql_num_rows($results); for ($j = 0; $j < $rows ; ++$j) { $row = mysql_fetch_row($results); echo <<<_END <pre> Author: $row[0] Title: $row[1] Category: $row[2] Year: $row[3] ISBN: $row[4] </pre> <form action="connectionTest.php" method="post"> <input type="hidden" name="delete" value="yes" /> <input type="hidden" name="isbn" value="$row[4]" /> <input type="submit" value="DELETE RECORD" /> </form> _END; } echo "</body>"; echo "</html>"; mysql_close($db_server); function get_post($var) { return mysql_real_escape_string($_POST[$var]); } ?> cheers. I have some code which deletes a record from my database (which has been selected from the previous page). Only problem is, it comes up with error code, but still deletes from the database? Error: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /www/110mb.com/t/h/e/b/l/a/c/k/theblackwatch/htdocs/150749deleted.php on line 28 Code: Code: [Select] <?php $id = $_GET[id]; // Start the connection to the database $conn = mysql_pconnect("***", "***", "***"); // Select the database to use mysql_select_db("***", $conn); // Create the MySQL command to retrieve all records $sql = "DELETE FROM **** WHERE id ='$id'"; $result = mysql_query($sql, $conn); $array = mysql_fetch_array($result); // Echo each entry as the value of the text boxes. This brings in the current info in the database echo "<p>Entry has been deleted.</p>"; ?> Any way round it? Hi, Im using a button to delete each entry from my database, however it doesnt. I have tried it with linking to a delete page and works fine with the same mysql query, but i need to hve the button to delete and not a URL. Can someone please help me to see what is wrong? thanks in advance guys <?php include ("../include/global.php"); include ("../include/function.php"); if (loggedin()==FALSE) { Header("Location: ../login.php"); exit(); } $_SESSION['username']=='$username'; $username=$_SESSION['username']; $getid=mysql_query("SELECT id FROM users WHERE username='$username'"); while($row=mysql_fetch_array($getid)) { $usersid=$row['id']; } if (isset($_POST['add']) && $_POST['add']) { $subject = addslashes(strip_tags($_POST['subject'])); $text = addslashes(strip_tags($_POST['text'])); $update=mysql_query("INSERT INTO users_notes (user_id, subject, note) VALUES ('$usersid','$subject','$text')"); } if (isset($_POST['remove']) && $_POST['remove']) { $delete=mysql_query("DELETE FROM users_notes WHERE user_id='$usersid' AND AND id='$id'"); } ?> <html> <head> <script type="text/javascript" src="/js/jquery.js"></script> <script type="text/javascript" src="/js/jquery.validate.js"></script> <script type="text/javascript"> $(document).ready(function(){ $("#form").validate(); }); </script> </head> <body> <p>You are logged in! <a href="logout.php">Log out</a> </p> <p> </p> <p><td><? $getmsg=mysql_query("SELECT * FROM users_notes WHERE user_id='$usersid'"); while($row=mysql_fetch_array($getmsg)) { $id=$row['id']; $msgsubject=$row['subject']; $msgnotes=$row['note']; echo"<table width='800' border='1'>"; echo" <tr> <td width='50'>".$msgsubject."</td> <td width='50'>".$msgnotes."</td> <td width='40'><form id='form' method='post' action=''> <input type='submit' name='remove' value='remove' /> </form></td> <td> </td> </tr> "; } echo "</table>"; ?> </td> </p> <p> </p> <form action="" method="POST" id="form"> <p> Subject: <br/> <input type="text" name="subject" class="required"> </p> <p> Your Note: <br/> <textarea name="text" id="text" cols="45" rows="15" class="required"></textarea> </p> <p> <input type="submit" name="add" value="Add" > </p> </form> </body> Hello Everyone, I am writing a simple CMS system for someone. I am having trouble getting the delete function to work. I pick the user that I want to remove from the system. I verify that this is the right person to remove. Then the record is deleted from the database. The part that picks the person and verifies that it is the right person to remove from the database work fine. It is the part that actually deletes the record. It takes me back to the pick_user.php. If someone could help me with this I would appreciate it This is the code from the show_user_del.php <?php if (!$_POST[id]) { header ("LOCATION: pick_user.php"); exit; } if ($_COOKIE[auth] != "ok") { header("Location: ../login.php"); } require('../includes/auth_user.php'); //build and issue query $sql = "SELECT * FROM $table WHERE id = '$_POST[id]'"; $result = mysql_query($sql, $connection) or die(mysql_error()); while ($row = mysql_fetch_array($result)) { $f_name = $row['f_name']; $l_name = $row['l_name']; $username = $row['username']; $password = $row['password']; } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Add Classified Ad</title> </head> <body> <h2><em>Delete user from Database</em></h2> <h3>User being deleted <?php echo "$f_name $l_name"; ?></h3> <form method="POST" action="do_delete_user.php"> <input type="hidden" name="id" value="<?php echo "$_POST[id]"; ?>" /> <input type="hidden" name="f_name" value="<?php echo "$f_name"; ?>" /> <input type="hidden" name="l_name" value="<?php echo "$l_name"; ?>" /> <p> <strong>Name:</strong> <?php echo "$f_name $l_name"; ?> </p> <p> <strong>Username:</strong> <?php echo "$username"; ?> </p> <p> <strong>Password:</strong> <?php echo "$password"; ?> </p> <p> <input type="submit" name="submit" id="name" value="Delete User" /> </p> </form> <p><a href="../admin_menu.php">Return to Administration Menu</a></p> </body> </html> When the submit button is clicked in the above code. It is supposed to bring you to the page below saying that the record was deleted. When the submit button is clicked it sends you back to the pick user page. <?php if ((!$_POST[f_name]) || (!$_POST[l_name])) { header ("LOCATION: show_user_del.php"); exit; } if ($_COOKIE[auth] != "ok") { header("Location: ../login.php"); } require('../includes/auth_user.php'); $sql = "DELETE FROM $table WHERE id = '$_POST[id]'"; $result = mysql_query($sql, $connection) or die(mysql_error()); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <body> <h1>User has been removed</h1> <h2><em>User <?php echo "$_POST[f_name] $_POST[l_name]"; ?> has been deleted from the <?php echo "$table"; ?> table</em></h2> <p><a href="pick_user.php">Delete another person</a></p> <p><a href="../admin_menu.php">Administration Menu</a></p> </body> </html> I am attempting to build an online shopping cart, however I have a problem with the Delete /Remove Item function. Add New and Update Item work perfectly fine, just the Remove Item doesn't. It seems to be mirroring the same functionality as Update Item. http://www.tottonc.co.nz to see my problem in action. Any help or solutions would be much appreciated... I want to delete a file, I'm using Windows XP, however, it gives me Permission Denied: Code: [Select] $file =$row['img'] ; $filedel = "mages/".$file; unlink ($filedel); Is the code wrong? I tried setting permission to the folder but in vain... Not sure how to go about making it so that I can delete and edit a post.. So I am stumped on how to make it to delete and edit post. The key factor for getting the information is the id field. And I am able to get it and display it, but how can I get it to work between all my functions? This is what I have so far. <?php include 'test.php'; function connection() { $connection = @mysql_connect('localhost','root','') or die('could not connect to mysql'); $select_db = @mysql_select_db('tutorials') or die('could not connect to database'); } function delete_post($id) { connection(); $query = "DELETE FROM `posts` WHERE `id` = '$id'"; $result = mysql_query($query); } function find_posts() { connection(); $query = 'SELECT `posts`.`title`, `posts`.`body`, `posts`.`id`, `users`.`username` FROM `posts`, `users` WHERE `posts`.`user_id` = `users`.`id`'; $result = mysql_query($query); while ($row = mysql_fetch_array($result)) { $id = $row['id']; echo '<b>' . $row['title'] . '</b>' .'<a href=/practice/model/posts.php?action=delete>[delete]</a> <a href=/practice/model/posts.php?action=edit>[edit]</a>' . '<br/>'; echo $row['body'] . '<br/>'; echo $row['username'] . '<p>'; } } function find_post($id) { connection(); $query = "SELECT `posts`.`title`, `posts`.`body`, `posts`.`id`, `users`.`username` FROM `posts`, `users` WHERE `posts`.`user_id` = `users`.`id` AND `posts`.`id` = '$id'"; $result = mysql_query($query); $row = mysql_fetch_array($result); echo '<b>' . $row['title'] . '</b>' . '<br/>'; echo $row['body'] . '<br/>'; echo $row['username'] . '<p>'; } function create_post() { connection(); $title = $_POST['title']; $body = $_POST['body']; $query = "INSERT INTO `posts` SET `title` = '$title', `body` = '$body', `created_at` = NOW(), `user_id` = 53"; $result = mysql_query($query); if(!$result) { echo mysql_error(); } } delete_post(7); find_posts(); ?> <?php $action = $_GET['action']; switch ($action) { case 'create': echo 'created' . '<br/>'; create_post(); break; case 'delete': echo 'deleted' . '<br/>'; delete_post($id); break; } ?> <form action="/practice/model/posts.php?action=create" method="POST"> <input type="text" col="40" name="title" /><br/> <textarea cols="30" rows="5" name="body"> </textarea><br/> <input type="submit" name="submit" /> </form> So yea, I am not sure how to get the 'id' parameters linked between everything that needs it. Sorry for the vague description, but its kind of hard to put it into words. If you need a more detailed description please let me know and I will try to. Pretty much want to be able to delete and edit my posts. Thank you! I need help in coding an approve script. I still can't figure out myself how can I approve a comment through my comment page. Example : John comments on my page and I can choose whether I can approve his comment or not. Please help me. Thanks ! hi guys. i need some help with some code i wrote. i have a login script where there are some cookies get set like this: setcookie('user_id', $row['user_id']); in a logout script these cookies are supposed to be deleted and lost into oblivion... like this: setcookie('user_id', '', time() - 3600); The thing is... cookies wont die! i use firefox 3.6.8. i have tried some things like changing the ('') quotes with the ("") quotes. i ve changed the time to : time() - 993600 just to be sure. i ve even used the unset fucntion like this: unset($_COOKIE['user_id']); Even the cookie created by the session_start() is not get deleted with this: if (isset($_COOKIE[session_name()])) { setcookie(session_name(), '', time() - 93600); unset($_COOKIE[session_name()]); } does anyone have any idea what am i doing wrong. please? thank you for your time. I am trying to find some example code where the user could click a button to approve or disapprove a certain topic. Or even like a voting type of code where they vote yes or no. The database would just update a running count each time the user clicked on the approve or disapprove buttons. I'll also need each user to only be allowed to vote once on a particular topic. Any ideas for some examples somewhere? Seems like I could write something like Code: [Select] <?php //topic variable passed through a link I assume $topic = 2343; //user clicks on approve $approve = "UPDATE topic SET a_count = a_count + 1 WHERE topic_id = $topic"; //user clicks on disapprove $disapprove = "UPDATE topic SET d_count = d_count + 1 WHERE topic_id = $topic"; //The rest I am unsure of how to control the user from clicking approve 500 times. Maybe in a $_SESSION? ?> In the form below how do I alter the code so when someone types something into the email that is clearly not recognized an an email address it either asks the customer to recheck or fails
<tr> <td align="right"><?php echo $LANG['index_email_add']; ?> </td> <td>:</td> <td align="left"> <input name="email" type="text" id="email" required></td> </tr> <tr> <td align="right"><?php echo $LANG['index_pass'] ; ?></td> <td>:</td> <td align="left"><input name="password" type="password" required id="password"></td> </tr> <tr> <td align="right"><?php echo $LANG['postcode'] ; ?> </td> <td>:</td> <td align="left"><input class="input" id="geocomplete" type="text" placeholder="<?php echo $LANG['index_location']; ?>" name="address" required> <input name="action" type="hidden" id="action" value="joinNow" /></td> </tr>The problem I have is that any data can be added to the 3 fields and by anything even using !@#$%^&*():"{}';<>., How do I prevent those special characters from being used. When it asks for email I can enter ; When it asks for password I can enter ' and last PostCode I can enter: ] How to prevent this from happening? Thanks i need help trying to get this delete feature to work its not deleting from the database (by the way i took out my database names and passwords at the top of the file) is it possible someone could help me, ive been working on this for like a week and cant figure out the problem. thanks! you can email me at spr_spng@yahoo.com picture 2.png is showing what it looks like Code: [Select] <?php $host="localhost"; // Host name $username="username"; // Mysql username $password="password"; // Mysql password $db_name="database_name"; // Database name $tbl_name="table_name"; // Table name // Connect to server and select databse. mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); $sql="SELECT * FROM $tbl_name"; $result=mysql_query($sql); $count=mysql_num_rows($result); ?> <style> /*table affects look of the whole table look */ table { margin-left: auto; margin-right: auto; border: 1px solid #330000; border-collapse:collapse; width:70%; border-width: 5px 5px 5px 5px; border-spacing: 1px; border-style: outset outset outset outset; border-color: #330000 #330000 #330000 #330000; border-collapse: separate; background-color: #330000; #800517 f535aa #330000 school color #9A0000 school color2 #991B1E school color3 #CCCC99 school color4 #9A0000 } /*th is table header */ th { text-align: left; height: 2.5em; background-color: #330000; color: #FC0; font-size:1.5em; } /*td is table data or the cells below the header*/ td { text-align: left; height:1.0em; font-size:1.0em; vertical-align:bottom; padding:10px; border-width: 5px 5px 5px 5px; padding: 8px 8px 8px 8px; border-style: outset outset outset outset; border-color: #9A0000 #9A0000 #9A0000 #9A0000; background-color: #CCCC99; -moz-border-radius: 0px 0px 0px 0px; } </style> <table width="400" border="0" cellspacing="1" cellpadding="0"> <tr> <td><form name="form1" method="post" action=""> <table width="400" border="0" cellpadding="3" cellspacing="1" bgcolor="#CCCCCC"> <tr> <td bgcolor="#FFFFFF"> </td> <td colspan="4" bgcolor="#FFFFFF"><strong>Pick Which Rows you want to delete, Then press delete.</strong> </td> </tr> <tr> <td align="center" bgcolor="#FFFFFF"><strong>Id</strong></td> <td align="center" bgcolor="#FFFFFF"><strong>Name</strong></td> <td align="center" bgcolor="#FFFFFF"><strong>Lastname</strong></td> <td align="center" bgcolor="#FFFFFF"><strong>Email</strong></td> <td align="center" bgcolor="#FFFFFF">delete</td></tr> <?php while($rows=mysql_fetch_array($result)){ ?> <tr> <td bgcolor="#FFFFFF"><? echo $rows['id']; ?></td> <td bgcolor="#FFFFFF"><? echo $rows['name']; ?></td> <td bgcolor="#FFFFFF"><? echo $rows['lastname']; ?></td> <td bgcolor="#FFFFFF"><? echo $rows['email']; ?></td> <td align="center" bgcolor="#FFFFFF"><input name="checkbox[]" type="checkbox" id="checkbox[]" value="<? echo $rows['id']; ?>"></td> </tr> <?php } ?> <tr> <td colspan="5" align="center" bgcolor="#FFFFFF"><input name="delete" type="submit" id="delete" value="Delete"></td> </tr> <? // Check if delete button active, start this // edited if($delete){ for($i=0;$i<$count;$i++){ $del_id = $checkbox[$i]; $sql = "DELETE FROM $tbl_name WHERE id='$del_id'"; $result = mysql_query($sql); } // if successful redirect to delete_multiple.php if($result){ echo "<meta http-equiv=\"refresh\" content=\"0;URL=delete_multiple.php\">"; } } mysql_close(); ?> </table> </form> </td> </tr> </table> I've got a question, I thought I'd be able to do this fairly easily. I don't want to do an .htaccess solution also. I tried this, define('ACCESS', TRUE); // then on other page if(!defined('ACCESS'){die('Direct access not allowed.');} Need some assistance, appreciated. I have created a lightbox where you can accept of deny friends. Each friend that is displayed has approved or deny buttons next to them. The approve button has a name like... approverequest[2] The delete button has a name like... denyrequest[2] where 2 is the users id My problem is that I can't get the data to update in mysql. Am I going about this the wrong way? Code: [Select] if (isset($_POST['acceptrequest'])) { if (is_array($_POST['acceptrequest'])) { $keys = array_keys($_POST['acceptrequest']); $id = $keys[0]; $sql = "UPDATE `partners` SET `approved` = 1, `approved_date` = NOW() WHERE `user_id` = '$id'"; header("Location: " . $_SERVER['PHP_SELF'] . "?" . $_SERVER['QUERY_STRING'] ); } } else if (isset($_POST['denyrequest'])) { if (is_array($_POST['denyrequest'])) { $keys = array_keys($_POST['denyrequest']); $id = $keys[0]; $sql = "UPDATE `partners` SET `approved` = -1, `approved_date` = NOW() WHERE `user_id` = '$id'"; header("Location: " . $_SERVER['PHP_SELF'] . "?" . $_SERVER['QUERY_STRING'] ); } } if (isset($sql) && !empty($sql)) { mysql_query($sql); } Hi guys, I want something to be clarified. The supervisor of my system is responsible for approving accounts. When he logged into the system he should be able to view the customer records based on customer ID. That is when he types the relevant customer ID and clicks on search button the relevant record is displayed in a form. That part is OK. Thereafter he should approve the account by clicking on "Approve Account" button. I want to know how can he make sure relevant customer_id is approved or not. customer table includes fields of, customer_id, nic, full_name, name_with_initials, address, contact_number, gender. I want to whether i have add an extra field to my customer table saying "approves status" or whatever. Can anyone give me a suggestion?? Thanks, Heshan |