Jump to content

[PHP]frame problem


Recommended Posts

hey im starting with a small linkdump for my friends

so the links they add are stored in link.txt

now

i cant figure out how to let the link open in a new windows iframe

to a new page wasnt such a big problem

its all stored in the add.php and afterwards he shows the parsed txt

content of add.php

<?php
include "style.php";
$filename = 'link.txt'; // edit this

function addlink($link_name,$link_url,$by,$email) {
global $filename;
$html = "<a href='$link_url' target='_blank'>$link_name</a>, posted by <a href='mailto:$email'>$by\n";
$fp = fopen($filename, 'a+');
fputs($fp, $html) or die("Could not open file!");
echo 'The link was added successfully.<br><br>';
}

function showlinks() {
global $filename;
$html = implode('<br/>',array_reverse(file($filename)));
echo $html;
}

If (!$link_url){
print "You must enter a Link Address";
} elseif (!$link_name){
print "You must enter a Link Name";
} elseif (!$by){
print "You must enter your Name";
} elseif (!$email){
print "You must enter a Email Address";
} else {
addlink($link_name,$link_url,$by,$email);
print "<b>Existing Links</b>:<br>"; // adds new link
showlinks(); // display's list of links
}
?>

how can i load the page that he gets out of a txt to load in a page with an iframe

the content of the link.txt

<a href='http://www.msfn.org' target='_blank'>Microsoft Software Forum Network </a>, posted by <a href='mailto:the_orangeman@hotmail.com'>orange

maybe another solution is that i can add the nfo to the mysql db that i got but i dont know how to get data out of the db

the script is located @ hxxp://orange.djhost.nl/linkdump

if anyone can help me it would be nice

it can be done i know i website that has it but the webmaster dont give out the script (i understand it) so im looking for my self how to get out of this problem

that website that has this feature is hxxp://www.linkdump.be

note im a newbie with making websites i get alot of help from my friends also one here from the board but i cant keep asking the same people over and over again but if anyone is willing to help me im gratefull :)

Edited by orange
Link to comment
Share on other sites


I am not sure if this will do what you want, but here goes:

In your HTML/PHP code:

<iframe id="NAMEYOURFRAME" src="whateverfile.htm"></iframe>

In your PHP, change the fragment marked in bold:

$html = "<a href='$link_url' target='_blank'>$link_name</a>

Change it to target='NAMEYOURFRAME'

Hope it helps? :}

Link to comment
Share on other sites

  • 2 months later...

That can be done in a number of ways, and the old text-based "database" isn't the best solution, but it's not impossible.

I would probarly use a regular expression:

$s = '<a href="http://www.msfn.org" target="_blank">Microsoft Software Forum Network </a>, posted by <a href="mailto:the_orangeman@hotmail.com">orange';
preg_match('^<a href="([^"]+)', $s, $matches);
$link_addr = $matches[1];

Now, I haven't tested the above code, but it should help you on the right path :-)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...