NamePros
Welcome, Guest! Ready to make a name for yourself in the domain business? We welcome both the hobbyist and professional domainer to join the discussion as part of the NamePros community.

Click here to create your profile to start earning reputation for posting, and trader ratings for buying & selling in our free e-marketplace. Build your trader rating with each successful sale. Our system has tracked over 100,000 sales and counting!
FAQ & TOS Register Search Today's Posts Mark Forums Read

Go Back   NamePros.com > Website Development Discussion Forums > Programming > CODE
Reload this Page Auto Link Code

CODE This forum is for posting code snippets and example scripts that aren't quite tutorials, but could be useful for others. You may post code snippets and/or completed scripts that you've written and want to share here.

Advanced Search
7 members in live chat ~  


Closed Thread
 
LinkBack Thread Tools
Old 12-11-2006, 06:01 PM THREAD STARTER               #1 (permalink)
Account Suspended
 
antec's Avatar
Join Date: Oct 2006
Posts: 206
antec is an unknown quantity at this point
 



Auto Link Code


Im trying to find a code html or java that allows people automaticly add there link to my blog. does anyone know the code?
antec is offline  
Old 12-12-2006, 09:12 AM   #2 (permalink)
Account Suspended
Join Date: Oct 2005
Location: United Kingdom
Posts: 1,554
NetworkTown.Net is just really niceNetworkTown.Net is just really niceNetworkTown.Net is just really niceNetworkTown.Net is just really nice
 



so you want people to add a button on there site and then when a visitor clicks on it, it blogs it on your site?
NetworkTown.Net is offline  
Old 12-27-2006, 08:12 AM   #3 (permalink)
NamePros Regular
 
Ryder's Avatar
Join Date: Mar 2006
Posts: 227
Ryder is a jewel in the roughRyder is a jewel in the roughRyder is a jewel in the rough
 



I guess you need to code that, using MySQL?

Well, it is not an easy task. You can pay someone to do it for you? Or you can find a good tutorial for it.
__________________
| HexRde.com | NetSuhi.com |
Ryder is offline  
Old 12-27-2006, 08:18 AM   #4 (permalink)
NamePros Regular
 
w1ww's Avatar
Join Date: Oct 2006
Location: Mars.
Posts: 439
w1ww is a jewel in the roughw1ww is a jewel in the roughw1ww is a jewel in the rough
 



Ahm he has just to place a form that saves the URL and the name at the DB and the make a code to read from there!
__________________
:notme:
w1ww is offline  
Old 12-27-2006, 08:59 AM   #5 (permalink)
NamePros Regular
 
Ryder's Avatar
Join Date: Mar 2006
Posts: 227
Ryder is a jewel in the roughRyder is a jewel in the roughRyder is a jewel in the rough
 



True... however, it is possible to do this flat file style, in case he doesn't have mysql!
__________________
| HexRde.com | NetSuhi.com |
Ryder is offline  
Old 12-27-2006, 09:39 AM   #6 (permalink)
NamePros Regular
Join Date: Mar 2006
Location: United Kingdom
Posts: 413
lee101 is a jewel in the roughlee101 is a jewel in the roughlee101 is a jewel in the rough
 




Here's a simple flat-file type thing i have done, i think it does what you need although please note that it includes no validation, or security measures

Form Code
Code:
<form action="add.php" method="post">
Name: <input type="text" name="name" />
<br />
URL: <input type="text" name="url" value="http://" />
<br />
<input type="submit" value="Submit" />
</form>
add.php adds the links
PHP Code:
<?php
//File where all links are stored
$file='links.txt';
//Variables Posted
$name=$_POST['name'];
$url=urldecode($_POST['url']);
//Open File and Add Link
$handle=fopen($file,'a');
//Check that all data is filled in
if($name == '' || $url == ''){
????: NamePros.com http://www.namepros.com/code/268005-auto-link-code.html
    die(
"Please fill in all fields correctly");
} else{
    
fwrite($handle,$name.'=>'.$url.'
'
);
}
?>
parse.php - returns the links
PHP Code:
<?php
//Path to links file
$links='links.txt';
//Open
$links=file($links);
//print_r($links);
//Display
foreach($links as $line){
list(
$name,$url)=explode('=>',$line);
$url=str_replace('
'
,'',$url);
echo 
'<a href="'.$url.'">'.$name.'</a>';
echo 
'<br /><br />';
}
?>
Then just create a blank file called links.txt in the same directory, and make sure it is writeable

Lee

EDIT:

MySQL

Create the following files:

config.inc.php
PHP Code:
<?php
$cfg
['dbhost'] = 'localhost';
$cfg['dbuser'] = 'user';
$cfg['dbpass'] = 'pass';
$cfg['dbname'] = 'database';

//connect to the database
function connectdb(){
    global 
$cfg;
    
mysql_connect($cfg['dbhost'],$cfg['dbuser'],$cfg['dbpass']);
    
mysql_select_db($cfg['dbname']);
}
?>
add.php
PHP Code:
<?php
include_once('config.inc.php');
$action=$_POST['action'];
$name=$_POST['name'];
$url=$_POST['url'];
if(
$action == 'add'){
    
//Add User and Link To DB
    
connectdb();
    if(
$name == !'' || $url = !''){
        if(
mysql_query("INSERT INTO `links` VALUES (NULL,'$name','$url')")){
            echo 
"Link Added";
        }
    }
}
?>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<input type="hidden" name="action" value="add" />
Name: <input type="text" name="name" />
<br />
URL: <input type="text" name="url" value="http://" />
<br />
<input type="submit" value="Submit" />
</form>
display.php
PHP Code:
<?php
include_once('config.inc.php');
connectdb();
$query=mysql_query("SELECT * FROM `links`");
$rows=mysql_numrows($query);
$i=0;
while(
$i $rows){
????: NamePros.com http://www.namepros.com/showthread.php?t=268005
    
$name=mysql_result($query,$i,'name');
    
$url=mysql_result($query,$i,'url');
    echo 
'<a href="'.$url.'">'.$name.'</a><br />';
    
$i++;
}
?>
And run the SQL query through phpmyadmin or similar to create the database structure

Code:
CREATE TABLE `links` (
`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`name` TEXT NOT NULL ,
`url` TEXT NOT NULL
)
Once again there is no security in here, so use at your own risk
__________________
Linux Screenshots
Last edited by lee101; 12-27-2006 at 04:39 PM.
lee101 is offline  
Old 12-27-2006, 11:58 AM   #7 (permalink)
Senior Member
Join Date: Dec 2006
Location: England
Posts: 1,565
Matthew. has much to be proud ofMatthew. has much to be proud ofMatthew. has much to be proud ofMatthew. has much to be proud ofMatthew. has much to be proud ofMatthew. has much to be proud ofMatthew. has much to be proud ofMatthew. has much to be proud ofMatthew. has much to be proud of
 


Adoption Breast Cancer Breast Cancer Cancer Survivorship
Am i the only one who believes in php standards anymore lol...Not nagging, i appreciate it's only an example but i do have to have a little rant when i see things like !=''
Matthew. is offline  
Old 12-27-2006, 12:50 PM   #8 (permalink)
Dan
Buy my domains.
 
Dan's Avatar
Join Date: Feb 2006
Posts: 2,792
Dan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant future
 


Autism Autism Autism Autism Autism Autism Autism
Are you talking about the space that isn't there? In that code all I see that has something like != is == ! which I've never seen before.

I don't know if I use standards but I code for readability, etc.
Dan is offline  
Old 03-29-2007, 04:56 PM   #9 (permalink)
NamePros Expert
Join Date: Nov 2004
Location: Esse quam videri
Posts: 8,316
IAmAllanShore has a reputation beyond reputeIAmAllanShore has a reputation beyond reputeIAmAllanShore has a reputation beyond reputeIAmAllanShore has a reputation beyond reputeIAmAllanShore has a reputation beyond reputeIAmAllanShore has a reputation beyond reputeIAmAllanShore has a reputation beyond reputeIAmAllanShore has a reputation beyond reputeIAmAllanShore has a reputation beyond reputeIAmAllanShore has a reputation beyond reputeIAmAllanShore has a reputation beyond repute
 

Member of the Month
January 2005Member of the Month
February 2007
Ethan Allen Fund Child Abuse Child Abuse Child Abuse Child Abuse Save The Children Save The Children Child Abuse Child Abuse Child Abuse Child Abuse VA Tech Memorial Child Abuse Child Abuse Child Abuse Child Abuse Child Abuse Child Abuse Child Abuse Child Abuse Child Abuse Child Abuse
Just used this code on a site - easy and straightforward; many thanks!
-Allan
__________________

Something Witty This Way Comes...
IAmAllanShore is offline  
Old 03-30-2007, 10:02 AM   #10 (permalink)
NamePros Regular
Join Date: Mar 2006
Location: United Kingdom
Posts: 413
lee101 is a jewel in the roughlee101 is a jewel in the roughlee101 is a jewel in the rough
 




No problem, just if you've used the MySQL version then please note that it won't protect against SQL injection attacks etc. So it needs some security adding to it

Lee
__________________
Linux Screenshots
lee101 is offline  
Closed Thread


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools


 
All times are GMT -7. The time now is 03:14 PM.

Domain name forum recommended by Domaining.com Powered by: vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.6.0 Ad Management plugin by RedTyger