brisanje iz baze php

brisanje iz baze php

offline
  • Pridružio: 18 Dec 2007
  • Poruke: 95

evo ovako iam jednu vezbu iz php-a u kojoj upisujemo neke web adrese i iste mozemo i da brisemo.Medjutim ta skripta za brisanje podataka neradi tj. kada oznacim sta da brisem on to ne skonta i samim tim nece da brise ako neko ima volje da pomogne poslacu mu skriptu posto ja nemogu da pronadjem gresku!



Registruj se da bi učestvovao u diskusiji. Registrovanim korisnicima se NE prikazuju reklame unutar poruka.
offline
  • Pridružio: 20 Dec 2004
  • Poruke: 2887
  • Gde živiš: Na Balkanu

Da bi ti neko pomogao prvo postavi skriptu da je vidimo.



offline
  • Pridružio: 24 Mar 2004
  • Poruke: 3962
  • Gde živiš: Zemun

proveri prvo sql da li je dobar.... mozes u phpmyadmin da ga uneses i da vidis hoce li lepo to odraditi.
ako odradi onda je do php-a

brisanje...
logika je da brise po ID ili sta ti je vec primarni kljuc u bazi, ili da se ne radi brisanje nego update baze i to polja koje sluzi kao objava... pa ako je 1ili true da se vidi, ako je 0 ili false da se ne vidi....

ali svakako da bi ti neko pomogao moras da okacis kod ovde

offline
  • Pridružio: 18 Dec 2007
  • Poruke: 95

ovo je delete_bms.php
<?php
require_once('bookmark_fns.php');
session_start();

//create short variable names
$del_me = $HTTP_POST_VARS['del_me'];
$valid_user = $HTTP_SESSION_VARS['valid_user'];

do_html_header('Brisanje podataka');
check_valid_user();
if (!filled_out($HTTP_POST_VARS))
{
echo 'Niste nista izabrali za brisanje.
Molimo pokusajte ponovo.';
display_user_menu();
do_html_footer();
exit;
}
else
{
if (count ($HTTP_POST_VARS['del_me']) >0)
{
foreach($del_me as $url)
{
if (delete_bm($valid_user, $url))
echo 'Deleted '.htmlspecialchars($url).'.<br />';
else
echo 'Could not delete '.htmlspecialchars($url).'.<br />';
}
}
else
echo 'Niste izabrali podatak/ke za brisanje';
}
// get the bookmarks this user has saved
if ($url_array = get_user_urls($valid_user))
display_user_urls($url_array);

display_user_menu();
do_html_footer();
?>
data_valid_fns.php
<?php

function filled_out($form_vars)
{
// test that each variable has a value
foreach ($form_vars as $key => $value)
{
if (!isset($key) || ($value == ''))
return false;
}
return true;
}

function valid_email($address)
{
// check an email address is possibly valid
if (ereg('^[a-zA-Z0-9_\.\-]+@[a-zA-Z0-9\-]+\.[a-zA-Z0-9\-\.]+$', $address))
return true;
else
return false;
}

?>
output_fns.php
<?php

function do_html_header($title)
{
// print an HTML header
?>
<html>
<head>
<title><?php echo $title;?></title>
<style>
body { font-family: Arial, Helvetica, sans-serif; font-size: 13px }
li, td { font-family: Arial, Helvetica, sans-serif; font-size: 13px }
hr { color: #3333cc; width=300; text-align=left}
a { color: #000000 }
</style>
</head>
<body>
<img src="bookmark.gif" alt="PHPbookmark logo" border=0
align=left valign=bottom height = 55 width = 57 />
<h1>&nbsp;PHPbookmark</h1>
<hr />
<?php
if($title)
do_html_heading($title);
}

function do_html_footer()
{
// print an HTML footer
?>
</body>
</html>
<?php
}

function do_html_heading($heading)
{
// print heading
?>
<h2><?php echo $heading;?></h2>
<?php
}

function do_html_URL($url, $name)
{
// output URL as link and br
?>
<br /><a href="<?php echo $url;?>"><?php echo $name;?></a><br />
<?php
}

function display_site_info()
{
// display some marketing info
?>
<ul>
<li>Store your bookmarks online with us!</li>
<li>See what other users use!</li>
<li>Share your favorite links with others!</li>
</ul>
<?php
}

function display_login_form()
{
?>
<a href='register_form.php'>Not a member?</a>
<form method='post' action='member.php'>
<table bgcolor='#cccccc'>
<tr>
<td colspan=2>Members log in here:</td>
<tr>
<td>Username:</td>
<td><input type='text' name='username'></td></tr>
<tr>
<td>Password:</td>
<td><input type='password' name='passwd'></td></tr>
<tr>
<td colspan=2 align='center'>
<input type='submit' value='Log in'></td></tr>
<tr>
<td colspan=2><a href='forgot_form.php'>Forgot your password?</a></td>
</tr>
</table></form>
<?php
}

function display_registration_form()
{
?>
<form method='post' action='register_new.php'>
<table bgcolor='#cccccc'>
<tr>
<td>Email address:</td>
<td><input type='text' name='email' size=30 maxlength=100></td></tr>
<tr>
<td>Preferred username <br />(max 16 chars):</td>
<td valign='top'><input type='text' name='username'
size=16 maxlength=16></td></tr>
<tr>
<td>Password <br />(between 6 and 16 chars):</td>
<td valign='top'><input type='password' name='passwd'
size=16 maxlength=16></td></tr>
<tr>
<td>Confirm password:</td>
<td><input type='password' name='passwd2' size=16 maxlength=16></td></tr>
<tr>
<td colspan=2 align='center'>
<input type='submit' value='Register'></td></tr>
</table></form>
<?php

}

function display_user_urls($url_array)
{
// display the table of URLs

// set global variable, so we can test later if this is on the page
global $bm_table;
$bm_table = true;
?>
<br />
<form name='bm_table' action='delete_bms.php' method='post'>
<table width=300 cellpadding=2 cellspacing=0>
<?php
$color = "#cccccc";
echo "<tr bgcolor='$color'><td><strong>Bookmark</strong></td>";
echo "<td><strong>Delete?</strong></td></tr>";
if (is_array($url_array) && count($url_array)>0)
{
foreach ($url_array as $url)
{
if ($color == "#cccccc")
$color = "#ffffff";
else
$color = "#cccccc";
// remember to call htmlspecialchars() when we are displaying user data
echo "<tr bgcolor='$color'><td><a href='$url'>".htmlspecialchars($url)."</a></td>";
echo "<td><input type='checkbox' name='del_me[]'
value='$url'></td>";
echo "</tr>";
}
}
else
echo "<tr><td>Nemate ubacenih podataka</td></tr>";
?>
</table>
</form>
<?php
}

function display_user_menu()
{
// display the menu options on this page
?>
<hr />
<a href="member.php">Home</a> &nbsp;|&nbsp;
<a href="add_bm_form.php">Add BM</a> &nbsp;|&nbsp;
<?php
// only offer the delete option if bookmark table is on this page
global $bm_table;
if($bm_table==true)
echo "<a href='#' onClick='bm_table.submit();'>Delete BM</a>&nbsp;|&nbsp;";
else
echo "<font color='#cccccc'>Delete BM</font>&nbsp;|&nbsp;";
?>
<a href="change_passwd_form.php">Change password</a>
<br />
<a href="recommend.php">Recommend URLs to me</a> &nbsp;|&nbsp;
<a href="logout.php">Logout</a>
<hr />

<?php
}

function display_add_bm_form()
{
// display the form for people to ener a new bookmark in
?>
<form name='bm_table' action='add_bms.php' method='post'>
<table width=250 cellpadding=2 cellspacing=0 bgcolor='#cccccc'>
<tr><td>New BM:</td><td><input type='text' name='new_url' value="http://"
size=30 maxlength=255></td></tr>
<tr><td colspan=2 align='center'><input type='submit' value='Add bookmark'></td></tr>
</table>
</form>
<?php
}

function display_password_form()
{
// display html change password form
?>
<br />
<form action='change_passwd.php' method='post'>
<table width=250 cellpadding=2 cellspacing=0 bgcolor='#cccccc'>
<tr><td>Old password:</td>
<td><input type='password' name='old_passwd' size=16 maxlength=16></td>
</tr>
<tr><td>New password:</td>
<td><input type='password' name='new_passwd' size=16 maxlength=16></td>
</tr>
<tr><td>Repeat new password:</td>
<td><input type='password' name='new_passwd2' size=16 maxlength=16></td>
</tr>
<tr><td colspan=2 align='center'><input type='submit' value='Change password'>
</td></tr>
</table>
<br />
<?php
};

function display_forgot_form()
{
// display HTML form to reset and email password
?>
<br />
<form action='forgot_passwd.php' method='post'>
<table width=250 cellpadding=2 cellspacing=0 bgcolor='#cccccc'>
<tr><td>Enter your username</td>
<td><input type='text' name='username' size=16 maxlength=16></td>
</tr>
<tr><td colspan=2 align='center'><input type='submit' value='Change password'>
</td></tr>
</table>
<br />
<?php
};

function display_recommended_urls($url_array)
{
// similar output to display_user_urls
// instead of displaying the users bookmarks, display recomendation
?>
<br />
<table width=300 cellpadding=2 cellspacing=0>
<?php
$color = "#cccccc";
echo "<tr bgcolor=$color><td><strong>Recommendations</strong></td></tr>";
if (is_array($url_array) && count($url_array)>0)
{
foreach ($url_array as $url)
{
if ($color == "#cccccc")
$color = "#ffffff";
else
$color = "#cccccc";
echo "<tr bgcolor='$color'><td><a href=\"$url\">".htmlspecialchars($url)."</a></td></tr>";
}
}
else
echo "<tr><td>No recommendations for you today.</td></tr>";
?>
</table>
<?php
};

?>

Ko je trenutno na forumu
 

Ukupno su 1176 korisnika na forumu :: 46 registrovanih, 6 sakrivenih i 1124 gosta   ::   [ Administrator ] [ Supermoderator ] [ Moderator ] :: Detaljnije

Najviše korisnika na forumu ikad bilo je 3466 - dana 01 Jun 2021 17:07

Korisnici koji su trenutno na forumu:
Korisnici trenutno na forumu: A.R.Chafee.Jr., amaterSRB, babaroga, bobomicek, bokisha253, ccoogg123, cifra, darkojbn, deLacy, doktor1964, DPera, dragoljub11987, dulleo, FOX, Georgius, Grah0, havoc995, hyla, ivica976, jackreacher011011, Karla, Krvava Devetka, ksyyaj, laganini123, Lucije Kvint, Mercury, milenko crazy north, milimoj, Mixelotti, mkukoleca, opt1, ozzy, panzerwaffe, radoznao, robert1979, Sirius, stalja, stankolich, Steeeefan, theNedjeljko, tomigun, Tores, vukovi, wizzardone, yrraf, zziko