Navigation |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
admin interface for adding and deleting users using mySQL
<?
/*
Copyright 2000-2001 KMR Enterprises
Scripted by TDavid @ http://www.tdscripts.com/
php-scripts.com Example #27
Purpose: to add and remove users from a mySQL table
This code is made available freely to modify as long as
this COMPLETE header is not removed. If you decide to use this
code then please put up a reciprocal link back to our site at
http://www.tdscripts.com/
We cannot, and will not, be held liable for any use or misuse
of the code contained herein. Any upload or execution of the
code implies understanding and agreement of these terms of use.
*/
$db = "DATABASE NAME";
$admin = "MYSQL USER NAME";
$adpass = "MYSQL PASSWORD";
$mysql_link = mysql_connect("localhost", $admin, $adpass);
mysql_select_db($db, $mysql_link);
?>
<HTML>
<BODY>
<script language="php">
if($react == "delete_user") {
if($user) {
$query = "DELETE from login WHERE user='$user' ";
$result = mysql_query($query, $mysql_link);
if(mysql_num_rows($result)) {
print("<strong>$user</strong> successfully deleted<p>");
}
} else {
print("<strong>no users are available to delete yet, sorry.</strong><p>");
}
}
elseif ($react == "add_user") {
if(($user) and ($pass)) {
$query = "INSERT into login VALUES ( ";
$query .= "0, SYSDATE(), '$username', '$password' )";
mysql_query($query, $mysql_link);
} else {
print("<strong>either your user or password field was left blank</strong><p>");
}
}
else {
print("<center>Administration Area - Choose your option</center>");
}
</script>
<form method="POST" action="admin.php3"><div align="center"><center><p>Delete Users
<input type="hidden" name="react" value="delete_user">
<select name="user" size="1">
<script language="php">
$query = "SELECT user FROM login ORDER BY user";
$result = mysql_query($query, $mysql_link);
if(mysql_num_rows($result)) {
// we have at least one user, so show all users as options in select form
while($row = mysql_fetch_row($result))
{
print("<option value="$row[0]">$row[0]</option>");
}
} else {
print("<option value="">No users created yet</option>");
}
</script>
</select><input type="submit" value="Submit"></p></center></div>
</form>
<form method="POST" action="admin.php3">
<input type="hidden" name="react" value="add_user">
<div align="center"><center><p>ADD A New User<br>
User: <input type="text" name="user" size="20"><br>
Pass: <input type="text" name="pass" size="20"><br>
<input type="submit" value="Submit"></p></center></div>
</form>
</BODY>
</HTML>
Reader rated most useful diary entries in descending order
<HTML>
<HEAD>
<title>Reader Rated Most Useful Entries</title>
</HEAD>
<BODY>
<table border="0" width="100%">
<tr>
<td width="6%" bgcolor="#00FFFF"><p align="center"><small><font face="Verdana">Rank</font></small></td>
<td width="7%" bgcolor="#00FFFF"><p align="center"><small><font face="Verdana">Rating</font></small></td>
<td width="11%" bgcolor="#00FFFF"><p align="center"><small><font face="Verdana">Diary Date</font></small></td>
<td width="76%" bgcolor="#00FFFF"><p align="left"><small><font face="Verdana">Description
of Diary Page</font></small>
</td>
<script language="php">
$db = "DATABASE NAME";
$admin = "MYSQL USER NAME";
$adpass = "MYSQL PASSWORD";
$mysql_link = mysql_connect("localhost", $admin, $adpass);
mysql_select_db($db, $mysql_link);
$query = "SELECT * FROM avg_tally ORDER BY average DESC";
$result = mysql_query($query, $mysql_link);
if(mysql_num_rows($result)) {
$rank = 1;
while($row = mysql_fetch_row($result))
{
print("</tr><tr>");
if($color == "#D8DBFE") {
$color = "#A6ACFD";
} else {
$color = "#D8DBFE";
}
print("<td width="6%" bgcolor="$color"><center><small>");
print("<font face="Verdana">$rank</font></small></center></td>");
print("<td width="7%" bgcolor="$color"><center><small>");
print("<font face="Verdana"><strong>$row[1]</strong></font></small></center></td>");
print("<td width="11%" bgcolor="$color"><center><small>");
$url = $row[2] . ".php3";
if(!file_exists($url)) { $url = $row[2] . ".html"; }
print("<font face="Verdana"><a href="$url">$row[2]</a></font></small></center></td>");
print("<td width="76%" bgcolor="$color"><left><small>");
print("<font face="Verdana">$row[3]</font></small></left></td>");
$rank++;
}
}
</script>
</table>
</BODY>
</HTML>
creating a mySQL table using a PHP script
<?
/*
TDs Counter 1.0
Copyright 2000-2001 KMR Enterprises
Scripted by TDavid @ http://www.tdscripts.com/
http://www.php-scripts.com (Example #31,32)
Purpose: a mult-page counter system in PHP / mySQL
This code is made available freely to modify as long as
this COMPLETE header is not removed. If you decide to use this
code then please put up a reciprocal link back to our site at
http://www.tdscripts.com/
We cannot, and will not, be held liable for any use or misuse
of the code contained herein. Any upload or execution of the
code implies understanding and agreement of these terms of use.
*/
$mysql_db = "DATABASE NAME";
$mysql_user = "YOUR MYSQL USERNAME";
$mysql_pass = "YOUR MYSQL PASSWORD";
$mysql_link = mysql_connect("localhost", $mysql_user, $mysql_pass);
mysql_select_db($mysql_db, $mysql_link);
$create_query = "CREATE TABLE tds_counter (
COUNT_ID INT NOT NULL AUTO_INCREMENT,
pagepath VARCHAR(250),
impressions INT,
reset_counter DATETIME,
PRIMARY KEY (COUNT_ID)
)";
mysql_query($create_query, $mysql_link);
print("Table Creation for <b>tds_counter</b> successful!<p>");
$insert = "INSERT into tds_counter VALUES (
0, '/php_diary/021901.php3', 0, SYSDATE()
)";
mysql_query($insert, $mysql_link);
print("Inserted new counter successfully for this page: http://www.php-scripts.com/php_diary/021901.php3<p>");
?>
mySQL based counter script for multiple pages
<?
/*
TDs Counter 1.0
Copyright 2000-2001 KMR Enterprises
Scripted by TDavid @ http://www.tdscripts.com/
http://www.php-scripts.com (Example #31,32)
Purpose: a mult-page counter system in PHP / mySQL
This code is made available freely to modify as long as
this COMPLETE header is not removed. If you decide to use this
code then please put up a reciprocal link back to our site at
http://www.tdscripts.com/
We cannot, and will not, be held liable for any use or misuse
of the code contained herein. Any upload or execution of the
code implies understanding and agreement of these terms of use.
*/
$db = "DATABASE NAME";
$admin = "MYSQL USER NAME";
$adpass = "MYSQL PASSWORD";
$mysql_link = mysql_connect("localhost", $admin, $adpass);
mysql_select_db($db, $mysql_link);
$result = mysql_query("SELECT impressions from tds_counter where COUNT_ID='$cid'", $mysql_link);
if(mysql_num_rows($result)) {
mysql_query("UPDATE tds_counter set impressions=impressions+1 where COUNT_ID='$cid'", $mysql_link);
$row = mysql_fetch_row($result);
if($inv != 1) {
print("$row[0]");
}
}
?>
|
|
|
|
|
|
|
Today, there have been 18 visitors (20 hits) on this page! |
|
|
|
|
|
|
|