View Full Version : How do you do this?

08-31-2006, 08:28 AM
Hi, I need to know how you can make an updatable link on a page. For instance, have a text field where I or anyone surfing my webpage can type in the link,(ie if they wanted to do www.codingforums.com they would type in "www.codingforums.com" then click submit and have it update the page so that when anyone clicked the link it would take them to codingforums.com. How can this be done?

08-31-2006, 01:35 PM
u have to take all the values ( like links or any other text ) into
DB. then u will make a page with the text field and display
that value in the text field and update the value with simple
update query.

08-31-2006, 09:41 PM
I think I have the code you're looking for ... but I'm not sure.

Are you looking for something that grows and remembers each link that people add or just something that remembers the last link that got typed in?

If it's the former, let me know soon. I'm heading out of town soon but if you e-mail me (savage at bigwhitevan dot com) I'll send you my script(s) and the table file from the DB.

Lee Stevens
08-31-2006, 11:27 PM
Lol, you don't need a Database, to make you send somone to a diffrent page here's a quick script i made up took me 1 min lol.

// By Lee Stevens On: 31/08/06 @ 23:26

if (!empty($_REQUEST['url'])) {
header( "refresh: 3; url=http://".$_REQUEST['url']);
echo '<h1>You will be re-directed in 3 seconds...</h1>';
} else {
<form name="form1" method="post" action="<? $_SERVER['PHP_SELF'] ?>">
URL: <input type="text" name="url">
<input type="submit" name="Submit" value="Submit">

09-01-2006, 12:10 AM
I think you have misunderstood what I am trying to accomplish. I want the person browsing the website to be able to submit their link and have that update the link on the page to whatever they typed in. Then the next time they or anyone else go onto the site that is the link that will show up, until they change it again. Also I do not want multiple links, just one link that can be changed at any time.

09-01-2006, 12:14 AM
// get the link
$link = file_get_contents('link.txt');
echo "<a href='$link'>$link</a>";

//update the link
$f = fopen('link.txt', 'w');
fwrite($f, $link);

Lee Stevens
09-01-2006, 01:17 AM
Still need a eara to edit it here:

<form method="post" action="edit.php?action=edit">
<textarea cols="60" rows="20" name="edit">
$file = "link.txt";
$fh = fopen($file, 'r');
$theData = fread($fh, filesize($file));
echo $theData;
<input type="submit" value="Edit">
if($_GET['action'] == 'edit')
$fh = fopen($file, 'w') or die("can't open file");

$stringData = $_POST['edit'];