NamePros.Com (http://www.namepros.com/)
-   CODE (http://www.namepros.com/code/)
-   -   Auto link add (http://www.namepros.com/code/236041-auto-link-add.html)

HoldemUniversity 09-08-2006 12:53 PM

Auto link add
 
I'm looking for a script to allow users to automatically add text links on my site. Preferably in html or java.

Anybody know of any?

Barrucadu 09-08-2006 04:34 PM

Originally Posted by HoldemUniversity
I'm looking for a script to allow users to automatically add text links on my site. Preferably in html or java.

Anybody know of any?



Not possible in HTML and I dont know Java, so here it is in PHP, you need to have a MySQL database for this to work:

link.php
PHP Code:
<?php
if($_POST['link']){
     
mysql_connect('server','username','password')or die(mysql_error());
     
mysql_select_db('name')or die(mysql_error());
     
mysql_query('insert into links values("'.$_POST['link'].'","'.$_POST['url'].'"')or die(mysql_error());
     
mysql_close();
}
?>

<form action = 'link.php' method = 'post'>
Link Title: <input name = 'link' type = 'text' /><br />
Link URL: <input name = 'url' type = 'text' /><br />
<input name = 's' type = 'submit' value = 'Add Link' />


view_links.php
PHP Code:
mysql_connect('server','username','password')or die(mysql_error());
mysql_select_db('name')or die(mysql_error());
$links = mysql_query('select * from links order by link asc')or die(mysql_error());
mysql_close();

$i = 0;
while(
$i < mysql_num_rows($links)){
     echo
'<a href = "'.mysql_result($link,$i,'url').'">'.mysql_result($link,$i,'link').'</a><br />';
     
$i++;
}


All times are GMT -7. The time now is 05:50 PM.
Site Sponsors
Advertise your business at NamePros

Powered by: vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 2.4.0