Thread: Auto link add
View Single Post
Old 09-08-2006, 04:34 PM   · #2
Barrucadu
Formally Mikor.
 
Barrucadu's Avatar
 
Name: Michael Walker
Location: East Yorkshire, England
Trader Rating: (7)
Join Date: Aug 2005
Posts: 2,538
NP$: 163.25 (Donate)
Barrucadu is a splendid one to beholdBarrucadu is a splendid one to beholdBarrucadu is a splendid one to beholdBarrucadu is a splendid one to beholdBarrucadu is a splendid one to beholdBarrucadu is a splendid one to beholdBarrucadu is a splendid one to behold
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++;
}


Please register or log-in into NamePros to hide ads
__________________
Me | Blog | Last.fm | F@h | Archlinux.co.uk

archlinux User
Barrucadu is offline   Reply With Quote
Site Sponsors
Grow your forum! Grow your forum! Arcade Script
Advertise your business at NamePros
All times are GMT -7. The time now is 09:36 PM.


Powered by: vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.