nuar07 0 Report post Posted May 28, 2008 (edited) ak dh wat coding tuk delete tp guna lam php4 tp bila ak run lam php5 dia xjalan..nie ak bg coding tuk korang tolong tgk, kalo ade masalah bg tau r..// Check if delete button active, start this if($delete){for($i=0;$i<$count;$i++){$del_id = $checkbox[$i];$sql = "DELETE FROM $tbl_name WHERE id_lokasi='$del_id'";$result = mysql_query($sql);}// if successful redirect to feedback/FeedBackDeleteLokasi.phpif($result){echo "<meta http-equiv=\"refresh\" content=\"0;URL=feedback/FeedBackDeleteLokasi.php\">";}}mysql_close();?></table></body></html><?phpmysql_free_result($Recordset1);?>ak suspek part delete nie je problem...database blueh retrive, bila nk delete x jln. kalo run kat pc laen blueh guna apache php4 tp run kat computer ak guna wamp php 5 xjln pelik...harap dpt bantu Edited May 28, 2008 by nuar07 Quote Share this post Link to post Share on other sites
GeeIra 0 Report post Posted May 28, 2008 (edited) $submit==$HTTP_POST_VARS["submit"]; if($submit=="Delete") { if(isset($HTTP_POST_VARS["id"])) { // create the query $id=$HTTP_POST_VARS["id"]; $sql="SELECT * FROM tbl_name WHERE id='$id'"; // execute query $result=mysql_query($sql) or die("SQL select statement failed"); if($submit=="confirm??") { $id=$HTTP_POST_VARS["id"]; $sql = "DELETE FROM tbl_name WHERE id='$id'"; $result = mysql_query($sql); echo "<hr><H3>RECORD DELETED</H3><hr><br>"; } Kite pun xtau sgt..tp awk try la goreng2 coding tu.ada satu cr lg..tp tgh bingung2 ni x leh nk ingt ar.. Edited May 28, 2008 by GeeIra Quote Share this post Link to post Share on other sites
ejoe 0 Report post Posted May 28, 2008 code yg ko bg tidak penuhbtw aku rasa masalah register globalRegister Global(register_globals) adalah salah satu konfigurasi yg terdapat dlm php. Konfigurasi register_globals merupakan ciri di dalam PHP di mana kesemua pembolehubah global boleh dicapai secara automatik sekiranya register_globals di pasang (on). Namun pencapaian pembolehubah secara global boleh menyebabkan risiko keselamatan. Konfigurasi register_globals boleh diubah di dalam fail php.ini. PHP 4.2.0 dan keatas secara defaultnya menutup register_globals untuk tujuan keselamatan.http://www.ejoe.net/forum/tutorial_view.ph...e=php&id=76 Quote Share this post Link to post Share on other sites
amin007 1 Report post Posted May 28, 2008 $submit==$HTTP_POST_VARS["submit"]; if($submit=="Delete") { if(isset($HTTP_POST_VARS["id"])) { // create the query $id=$HTTP_POST_VARS["id"]; $sql="SELECT * FROM tbl_name WHERE id='$id'"; // execute query $result=mysql_query($sql) or die("SQL select statement failed"); if($submit=="confirm??") { $id=$HTTP_POST_VARS["id"]; $sql = "DELETE FROM tbl_name WHERE id='$id'"; $result = mysql_query($sql); echo "<hr><H3>RECORD DELETED</H3><hr><br>"; } Kite pun xtau sgt.. tp awk try la goreng2 coding tu. ada satu cr lg.. tp tgh bingung2 ni x leh nk ingt ar.. memandangkan skrg dah php5 kena tukar sikit $submit=$_POST["submit"]; if($submit=="Delete") { if(isset($_POST["id"])) { // create the query $id=$_POST["id"]; $sql="SELECT * FROM tbl_name WHERE id='$id'"; // execute query $result=mysql_query($sql) or die("SQL select statement failed"); if($submit=="confirm??") { $id=$_POST["id"]; $sql = "DELETE FROM tbl_name WHERE id='$id'"; $result = mysql_query($sql); echo "<hr><H3>RECORD DELETED</H3><hr><br>"; } sekian wasalam Quote Share this post Link to post Share on other sites
rindu 0 Report post Posted May 28, 2008 laaa.. ingatkan saper tadi kena rogol Quote Share this post Link to post Share on other sites
ejoe 0 Report post Posted May 28, 2008 $id=$_POST["id"];mungking juga dia guna method GETkalo GET $id=$_GET["id];or bleh guna $id=$_REQUEST["id"]; kalo untuk 2-2 GET & POST Quote Share this post Link to post Share on other sites
amin007 1 Report post Posted May 29, 2008 laaa.. ingatkan saper tadi kena rogolrogol??? tu yang pelik ni Quote Share this post Link to post Share on other sites
nuar07 0 Report post Posted May 29, 2008 anyway thanks for helping me..ni full codingnye<?php # BuildNav for Dreamweaver MX v0.2 # 10-02-2002 # Alessandro Crugnola [TMM] # sephiroth: [email protected] # http://www.sephiroth.it # # Function for navigation build :: function buildNavigation($pageNum_Recordset1,$totalPages_Recordset1,$prev_Recordset1,$next_Recordset1,$separator=" | ",$max_links=10, $show_page=true) { GLOBAL $maxRows_Recordset1,$totalRows_Recordset1; $pagesArray = ""; $firstArray = ""; $lastArray = ""; if($max_links<2)$max_links=2; if($pageNum_Recordset1<=$totalPages_Recordset1 && $pageNum_Recordset1>=0) { if ($pageNum_Recordset1 > ceil($max_links/2)) { $fgp = $pageNum_Recordset1 - ceil($max_links/2) > 0 ? $pageNum_Recordset1 - ceil($max_links/2) : 1; $egp = $pageNum_Recordset1 + ceil($max_links/2); if ($egp >= $totalPages_Recordset1) { $egp = $totalPages_Recordset1+1; $fgp = $totalPages_Recordset1 - ($max_links-1) > 0 ? $totalPages_Recordset1 - ($max_links-1) : 1; } } else { $fgp = 0; $egp = $totalPages_Recordset1 >= $max_links ? $max_links : $totalPages_Recordset1+1; } if($totalPages_Recordset1 >= 1) { # ------------------------ # Searching for $_GET vars # ------------------------ $_get_vars = ''; if(!empty($_GET) || !empty($HTTP_GET_VARS)){ $_GET = empty($_GET) ? $HTTP_GET_VARS : $_GET; foreach ($_GET as $_get_name => $_get_value) { if ($_get_name != "pageNum_Recordset1") { $_get_vars .= "&$_get_name=$_get_value"; } } } $successivo = $pageNum_Recordset1+1; $precedente = $pageNum_Recordset1-1; $firstArray = ($pageNum_Recordset1 > 0) ? "<a href=\"$_SERVER[PHP_SELF]?pageNum_Recordset1=$precedente$_get_vars\">$prev_Recordset1</a>" : "$prev_Recordset1"; # ---------------------- # page numbers # ---------------------- for($a = $fgp+1; $a <= $egp; $a++){ $theNext = $a-1; if($show_page) { $textLink = $a; } else { $min_l = (($a-1)*$maxRows_Recordset1) + 1; $max_l = ($a*$maxRows_Recordset1 >= $totalRows_Recordset1) ? $totalRows_Recordset1 : ($a*$maxRows_Recordset1); $textLink = "$min_l - $max_l"; } $_ss_k = floor($theNext/26); if ($theNext != $pageNum_Recordset1) { $pagesArray .= "<a href=\"$_SERVER[PHP_SELF]?pageNum_Recordset1=$theNext$_get_vars\">"; $pagesArray .= "$textLink</a>" . ($theNext < $egp-1 ? $separator : ""); } else { $pagesArray .= "$textLink" . ($theNext < $egp-1 ? $separator : ""); } } $theNext = $pageNum_Recordset1+1; $offset_end = $totalPages_Recordset1; $lastArray = ($pageNum_Recordset1 < $totalPages_Recordset1) ? "<a href=\"$_SERVER[PHP_SELF]?pageNum_Recordset1=$successivo$_get_vars\">$next_Recordset1</a>" : "$next_Recordset1"; } } return array($firstArray,$pagesArray,$lastArray); } ?> <?php require_once('../Connections/db.php'); ?> <?php function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { $theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue; switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } $editFormAction = $HTTP_SERVER_VARS['PHP_SELF']; if (isset($HTTP_SERVER_VARS['QUERY_STRING'])) { $editFormAction .= "?" . $HTTP_SERVER_VARS['QUERY_STRING']; } if ((isset($HTTP_POST_VARS["MM_insert"])) && ($HTTP_POST_VARS["MM_insert"] == "form1")) { $insertSQL = sprintf("INSERT INTO lokasi (nama_lokasi) VALUES (%s)", GetSQLValueString($HTTP_POST_VARS['nama_lokasi'], "text")); mysql_select_db($database_db, $db); $Result1 = mysql_query($insertSQL, $db) or die(mysql_error()); $insertGoTo = "lokasi baru.php"; if (isset($HTTP_SERVER_VARS['QUERY_STRING'])) { $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?"; $insertGoTo .= $HTTP_SERVER_VARS['QUERY_STRING']; } header(sprintf("Location: %s", $insertGoTo)); } $maxRows_Recordset1 = 20; $pageNum_Recordset1 = 0; if (isset($HTTP_GET_VARS['pageNum_Recordset1'])) { $pageNum_Recordset1 = $HTTP_GET_VARS['pageNum_Recordset1']; } $startRow_Recordset1 = $pageNum_Recordset1 * $maxRows_Recordset1; mysql_select_db($database_db, $db); $query_Recordset1 = "SELECT * FROM lokasi"; $query_limit_Recordset1 = sprintf("%s LIMIT %d, %d", $query_Recordset1, $startRow_Recordset1, $maxRows_Recordset1); $Recordset1 = mysql_query($query_limit_Recordset1, $db) or die(mysql_error()); $row_Recordset1 = mysql_fetch_assoc($Recordset1); if (isset($HTTP_GET_VARS['totalRows_Recordset1'])) { $totalRows_Recordset1 = $HTTP_GET_VARS['totalRows_Recordset1']; } else { $all_Recordset1 = mysql_query($query_Recordset1); $totalRows_Recordset1 = mysql_num_rows($all_Recordset1); } $totalPages_Recordset1 = ceil($totalRows_Recordset1/$maxRows_Recordset1)-1; ?> <html> <head> <title>Daftar Lokasi</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <link rel=stylesheet type="text/css" href="image/style.css"> </HEAD> <script language="JavaScript" type="text/JavaScript"> <!-- function tmt_confirm(msg){ document.MM_returnValue=(confirm(unescape(msg))); } //--> </script> </head> <body background="image/logo.gif"> <table width="100%" border="0"> <tr> <td width="20%"> </td> <td width="52%"><table width="100%" border="0"> <tr> <td> </td> </tr> <tr> <td><font size="2" face="Arial, Helvetica, sans-serif"><strong><a href="adminpage.php"><<Kembali</a></strong></font></td> </tr> <tr> <td><p><font size="2" face="Arial, Helvetica, sans-serif"></font></p></td> </tr> <tr> <td><form action="<?php echo $editFormAction; ?>" name="form1" method="POST"> <p><strong><font size="2" face="Geneva, Arial, Helvetica, sans-serif">Lokasi baru :</font> <input name="nama_lokasi" type="text" id="nama_lokasi3"> <input type="submit" name="Submit" value="Submit"> <font size="2"> </font></strong><a href="Senarai%20lokasi.php"><font size="2" face="Arial, Helvetica, sans-serif"> </font></a></p> <input type="hidden" name="MM_insert" value="form1"> </form></td> </tr> <tr> <td height="21"> </td> </tr> </table></td> <td width="28%" valign="top"> </td> </tr> <tr> <td height="154"> </td> <td><form name="frm1" method="POST" onSubmit="return ValidateForm()"> <?php $host="localhost"; // Host name $username="root"; // Mysql username $password=""; // Mysql password $db_name="onlinee-aduan"; // Database name $tbl_name="lokasi"; // 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); ?> <table width="100%" > <tr> <td width="12%" bgcolor="#CC99FF" ><div align="center"><font color="#000000" size="2" face="Arial, Helvetica, sans-serif"><strong>Select</strong></font></div></td> <td width="88%" bgcolor="#CC99FF" ><div align="center"><strong><font size="2" face="Arial, Helvetica, sans-serif">SENARAI LOKASI</font></strong></div></td> </tr> <?php do { ?> <tr> <td bgcolor="#9999CC"><div align="center"><font size="2" face="Geneva, Arial, Helvetica, sans-serif"> <input name="checkbox[]" type="checkbox" id="checkbox[]2" value="<?php echo $row_Recordset1['id_lokasi']; ?>"> </font></div></td> <td bgcolor="#9999CC"> <div align="left"><font size="2" face="Geneva, Arial, Helvetica, sans-serif"><?php echo $row_Recordset1['nama_lokasi']; ?></font></div></td> </tr> <?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?> <tr> <td> </td> <td> <div align="left"></div></td> </tr> <tr> <td> </td> <td><div align="center"> <?php # variable declaration $prev_Recordset1 = "« previous"; $next_Recordset1 = "next »"; $separator = " | "; $max_links = 4; $pages_navigation_Recordset1 = buildNavigation($pageNum_Recordset1,$totalPages_Recordset1,$prev_Recordset1,$next_Recordset1,$separator,$max_links,true); print $pages_navigation_Recordset1[0]; ?> <?php print $pages_navigation_Recordset1[1]; ?> <?php print $pages_navigation_Recordset1[2]; ?> </div></td> </tr> <tr> <td> </td> <td><div align="center"><font color="#000000"> <input name="delete" type="submit" id="delete" onClick="tmt_confirm('HAPUSKAN%20DATA');return document.MM_returnValue" value="Padam"> <input type="reset" name="Reset" value="Kosongkan"> </font> </div></td> </tr> </table> </form></td> <td valign="top"> </td> </tr> <tr> <td colspan="3"> </td> </tr> <? // Check if delete button active, start this if($delete){ for($i=0;$i<$count;$i++){ $del_id = $checkbox[$i]; $sql = "DELETE FROM $tbl_name WHERE id_lokasi='$del_id'"; $result = mysql_query($sql); } // if successful redirect to feedback/FeedBackDeleteLokasi.php.php if($result){ echo "<meta http-equiv=\"refresh\" content=\"0;URL=feedback/FeedBackDeleteLokasi.php\">"; } } mysql_close(); ?> </table> </body> </html> <?php mysql_free_result($Recordset1); ?> [/code]ak dah try gune post method tp tak berhasil gaktak tau r nak wat cmne lgak suspect pon de prob kt register globaltp ak pon tak tau nak tgk cmne..thankslaaa.. ingatkan saper tadi kena rogolsape yg kne rogol?? get n post ad different ke??yg ak tau post lbey secure n unlimited data Quote Share this post Link to post Share on other sites
ejoe 0 Report post Posted May 29, 2008 aku dah mula confius ngan checkbox ko tuni delete semua data or delete 1-1?btw kalo taknak ubah coding bleh gak ubah php.iniklik icon wamserver > php > php.inicari register_globals = Off tukarkan kepada register_globals = On Quote Share this post Link to post Share on other sites
Rayquaza 1 Report post Posted May 29, 2008 code yg ko bg tidak penuhbtw aku rasa masalah register globalhttp://www.ejoe.net/forum/tutorial_view.ph...e=php&id=76register global leh di "off"kan dengan menggunakan php flag pada .htaccess... php_flag register_globals off atau php_flag register_globals off Order allow,deny Allow from all Quote Share this post Link to post Share on other sites
nuar07 0 Report post Posted May 29, 2008 aku dah mula confius ngan checkbox ko tuni delete semua data or delete 1-1?btw kalo taknak ubah coding bleh gak ubah php.iniklik icon wamserver > php > php.inicari register_globals = Off tukarkan kepada register_globals = Onak nk delete 1-1 data,ak dh on kn php.ini kat wamp5 tetap xblueh gak tukar bnde tu ade affect ke..time kasih eh ko nk tgk system nie ke..sbnrnye ak pn altersystem org laen gak nie..dulu dia pakai apache version2 gan php 4...pas 2 transfer msuk wamp5 register global leh di "off"kan dengan menggunakan php flag pada .htaccess... php_flag register_globals off atau php_flag register_globals off Order allow,deny Allow from allphp_flag register_globals tu kat mana lam wamps ke Quote Share this post Link to post Share on other sites
ejoe 0 Report post Posted May 29, 2008 ko kena restart wamp5 tu... Quote Share this post Link to post Share on other sites
edzal79 0 Report post Posted June 3, 2008 (edited) Hello nak mencelah sikit mcm mana nak delete 2 table secara serentak1. table transaksi_baucar (id[amik id dari transaksi_baucarxlo],no_baucar)2.table transaksi_baucarxlo (id,id_xlo,kod_syarikat,no_akaun,amaun)ni contoh coding aku delete dari satu table<?session_start();include 'dbase.inc.php';include 'config.inc.php';$userid = $_REQUEST["uid"];$queDel = "DELETE FROM transaksi_baucarxlo WHERE id = '$userid'";$resDel = mysql_db_query(_DBDB, $queDel);if($resDel == 1) { errTrap("Transaksi baucar telah dibuang"); echo "<meta http-equiv=\"refresh\" content=\"0;URL=menu.php?t=3&opt=senaraibaucartanpalo\">";}?> Edited June 3, 2008 by edzal79 Quote Share this post Link to post Share on other sites
cyberfly 1 Report post Posted June 3, 2008 Hello nak mencelah sikit mcm mana nak delete 2 table secara serentak1. table transaksi_baucar (id[amik id dari transaksi_baucarxlo],no_baucar)2.table transaksi_baucarxlo (id,id_xlo,kod_syarikat,no_akaun,amaun)ni contoh coding aku delete dari satu table<?session_start();include 'dbase.inc.php';include 'config.inc.php';$userid = $_REQUEST["uid"];$queDel = "DELETE FROM transaksi_baucarxlo WHERE id = '$userid'";$resDel = mysql_db_query(_DBDB, $queDel);if($resDel == 1) { errTrap("Transaksi baucar telah dibuang"); echo "<meta http-equiv=\"refresh\" content=\"0;URL=menu.php?t=3&opt=senaraibaucartanpalo\">";}?>tambah je code delete satu lagi Quote Share this post Link to post Share on other sites
edzal79 0 Report post Posted June 4, 2008 (edited) mcm ni ker? tapi ada error lah -> Parse error: syntax error, unexpected T_BOOLEAN_OR<? session_start(); include 'dbase.inc.php'; include 'config.inc.php'; $userid = $_REQUEST["uid"]; $queDel2 = "DELETE FROM transaksi_baucar WHERE id = '$userid'"; $resDel2 = mysql_db_query(_DBDB, $queDel2); $queDel = "DELETE FROM transaksi_baucarxlo WHERE id = '$userid'"; $resDel = mysql_db_query(_DBDB, $queDel); if($resDel == 1)||($resDel2 == 1))Â Â { Â Â Â Â errTrap("Transaksi baucar telah dibuang"); Â Â Â Â echo "<meta http-equiv=\"refresh\" content=\"0;URL=menu.php?t=3&opt=senaraibaucartanpalo\">"; } ?> Edited June 4, 2008 by edzal79 Quote Share this post Link to post Share on other sites
ejoe 0 Report post Posted June 4, 2008 (edited) line ni problem if($resDel == 1)||($resDel2 == 1)) {sepatutnya if(($resDel == 1)||($resDel2 == 1)) {tp aku rasa better camniif ( (!$resDel) || (!$resDel2)) { echo "tak dpt delete"; }else{ echo "berjaya delete"; }sebab salah satu atau semua takleh delete akan keluar error Edited June 4, 2008 by ejoe Quote Share this post Link to post Share on other sites
edzal79 0 Report post Posted June 4, 2008 ok thanks dah berjaya Quote Share this post Link to post Share on other sites