R
E
S
O
U
R
C
E
S
       Home      Products & Services      Contact Us      Links


WebHatchers will design & develop your site for you.
_______________________

Website Menu Heaven: menus, buttons, etc.
_______________________

Send us your questions.
_______________________

site search by freefind
_______________________

HOME
SEO, Google, Privacy
   and Anonymity
Browser Insanity
JavaScript
Popups and Tooltips
Free Website Search
HTML Form Creator
Animation
Buttons and Menus
Counters
Captchas
Image Uploading
CSS and HTML
PHP
AJAX
XPATH
Website Poll
IM and Texting
Databases—MySQL
   or Not MySQL
Personal Status Boards
Content Management
   Systems
Article Content
   Management Systems
Website Directory
   CMS Systems
Photo Gallery CMS
Forum CMS
Blog CMS
Customer Records
   Management CMS
Address Book CMS
Private Messaging CMS
Chat Room CMS
JavaScript Charts
   and Graphs




Free Personal Status Boards (PSB™)

Free Standard Free PSB

Free PSB Pro Version

Free Social PSB

Free Social PSB Plus (with Email)

Free Business PSB

Free Business PSB Plus (with Email)

PSB demo

Social PSB demo

Business PSB demo

So what's all this PSB stuff about?

Chart comparing business status boards

PSB hosting diagram

PSB Licence Agreement



Copyright © 2002 -
MCS Investments, Inc. sitemap

PSBs, social networking, social evolution, microcommunities, personal status boards
PSBs, social networking, business personal status boards
website design, ecommerce solutions
website menus, buttons, image rotators
Ez-Architect, home design software
the magic carpet and the cement wall, children's adventure book
the squirrel valley railroad, model railroad videos, model train dvds
the deep rock railroad, model railroad videos, model train dvds

Edit Website Directories: Add URL—Content Management System (CMS)

The cool thing about making website directories is that they can be very useful when you need to go somewhere on the Web but you're not sure of the name. We use our directory as a programmer's resource which is better than Favorites in a browser because you can get a thumbnail and description and other info dynamically just from hovering over a link, without having to click on the link and go there (which you can also do, of course).

You may, of course, choose to leave out the code about thumbnails and dynamic info boxes and just have clickable links for the categories and the URLs, or store your own thumbnails of sites in an images folder and your own descriptions in MySQL fields. You'll need the PrintScreen key for screen capture and a graphics program like ImageForge or at least Irfanview for the thumbnails data.

This page will give you the code needed to add a URL to a website directory. In cms-creating-website-directories.html we saw how to create the website directory, and URLs were added one URL at a time. We'll do that here as well.

We assume you have access to a MySQL database and permission and password and user name, and you know the db name. We assume you know what is in a config file, since the PHP on this page uses include_once"config.php". If this is confusing, see the-configure-file.html. If you wish to see our directory demo, which shows how the directory looks and works, go to cms-view-website-directory-demo.html.

So let's peruse the code. There is a db table called urls—which has the fields url and category and id. If you don't have primary fields, your table will mess up, so we always stick one in, such as id. Don't use the main field as a primary. Note that the tables won't get created if they are already there.

Next comes the input filters. URL names must use acceptable URL characters—our preg_replace() sees to that. Notice that for security, we used strip_tags() and mysql_real_escape_string() on the URLs as well. The strip_tags() is run before the replace so that the acceptable characters between tags, like the B between < and >, are dumped as well as the tags. If these latter were dumped in the preg_replace(), the in-the-tags debris would remain.

Next, the form for entering URLs gets echoed onto the screen. Then we push the categories in the db table into an array—$cat[]. Next the PHP array cat[] is used to load a dropdown form displaying the current existing categories, using:
echo "<option value='".$cat[$i]."'>".$cat[$i]."</option>";. Users must select a category for each URL entered. Before saving, the urls table is searched for the one entered in the form. If it already exists, a message reveals to the user that it exists—no one want duplicate URLs in their directory. It it's new, the URL gets saved in the urls table.

Finally, the HTML code gives users instructions and parameters for URL entry.

SAVE THIS PAGE AS: cms-edit-website-directory-add-url.php

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=windows-1252">
<TITLE>Editing Website Directories—Content Management System (CMS)—Add URL</TITLE>
<meta name="description" content="Editing Website Directories—Content Management System (CMS)—Add URL">
<meta name="keywords" content="Add URL,Editing Website Directories,Content Management System,Content Management System Articles,php,CMS,javascript, dhtml, DHTML">
<script language="javascript">
var cat=new Array();

mactest=(navigator.userAgent.indexOf("Mac")!=-1) //My browser sniffers
is_chrome = navigator.userAgent.toLowerCase().indexOf('chrome') > -1
Netscape=(navigator.appName.indexOf("Netscape") != -1)
msafari=(navigator.userAgent.indexOf("Safari")!= -1)
wsafari=0; if(!mactest&&msafari){wsafari=1;msafari=0}
is_opera = 0; if(window.opera){is_opera=1}
is_ie_mac = 0; is_ie=0;if(document.all){is_ie=1}
if(is_ie&&mactest){is_ie_mac=1}

function fix(){if(Netscape||is_opera){e=document.getElementById('top');e.style.marginTop='1px';e=document.getElementById('info');e.style.marginTop='1px';}}
</script>
<style type="text/css">
BODY {margin-left:0; margin-right:0; margin-top:0;text-align:left;background-color:#ddd}
p, li {font:13px Verdana; color:black;text-align:left}
h1 {font:bold 20px Verdana; color:black;text-align:center}
h2 {font:bold 24px Verdana;text-align:center}
h3 {font:bold 11px Verdana;}
.url {position:absolute;top:0px;left:10px;width:989px}
.form {position:absolute;top:140px;left:200px;width:700px}
.form2 {position:absolute;top:340px;left:200px;width:700px}
.info {position:absolute;top:80px;left:200px;width:600px;border:1px solid blue;padding:6px;background-color:#bbb}
.side {position:absolute;top:160px;left:715px;width:277px;padding:6px;background-color:#bbb;border:1px solid blue}
</style>
</head>
<body onload='fix()'>

<?php

include_once"config.php";

$pattern2 = '/[^a-zA-Z0-9\\.\\,\\!\\;\\-\\_\\*\\@\\=\\+\\$\\/\\&\\[\\]\\#\\?\\047\\:\\(\\)]/i';
$replacement = '';
$U=$_POST['url'];
$CY=$_POST['cy'];
$U=strip_tags($U);
$U=preg_replace($pattern2, $replacement, $U);

$cat=array();

$res = mysql_query("SELECT category FROM categories order by category") or die(mysql_error());
while ($row = mysql_fetch_row($res)) {
array_push ($cat, $row[0]);
}


$num_cats_in_table=mysql_num_rows($res);


echo "<div class='form2'><form name='myform2' method='post' action='cms-edit-website-directory-add-url.php'><table width='700' border='0' cellpadding='2' cellspacing='2' align='center'><tr><td width='60'>URL</td><td><input name='url' type='text' size='66'></td></tr><tr><td>Category</td><td><select name='cy'>";
for ($i=0;$i<$num_cats_in_table;$i++) {
echo "<option value='".$cat[$i]."'>".$cat[$i]."</option>";}
echo "</select></td></tr><tr><td> </td><td><input name='save2' type='submit' value='Add URL to DB'>
<input name='reset2' type='reset' value='Reset'></td></tr></table></form></div>";


if (strlen($U)>4){
$check_user_data = mysql_query("SELECT url FROM urls WHERE url='$U'") or die(mysql_error());
if(mysql_num_rows($check_user_data) >0)
{echo '<script language="javascript">alert("This url exists. Please try again.")</script>;';

}else{

$U=mysql_real_escape_string($U);
mysql_query("INSERT INTO urls (id, url, category)
VALUES ('','$U','$CY')") or die('Error ,saving failed');
$rc = mysql_affected_rows();
if ($rc>0){unset($U);unset($CY);
echo '<script language="javascript">alert("The saving was successfully accomplished.");</script>';}
else{echo '<script language="javascript">alert("The saving was unsuccessful.");</script>';}
}}
mysql_close();

?>

<div id='top' class='url'>
<h1>Editing Website Directories—Content Management System (CMS)—Add URL</h1>
<div id='info' class='info'><h3>No single or double quotes or Enter/Return allowed in urls. URLs must be legitimate urls. Submit URLs, one at a time, selecting categories from the dropdown.</h3></div>
</div>

<?php include("nav.html"); ?>

</body>
</html>