Welcome to WebmasterWorld Guest from 184.108.40.206 , register , free tools , login , search , pro membership , help , library , announcements , recent posts , open posts Become a Pro Member
Adding links ffoeg
I am really new to PHP (Only been doing it for the past two weeks :) and I need a bit of help.
What I basically want to do is to have a text box in a form, with a "submit" button next to it.
What will happen is that the user will type in a URL in the textbox, and press submit. That form then writes that URL to the original page, providing a link to the given URL.
The problem that I can foresee is that when the user refreshes the page, that link that was uploaded would disappear. But I don't want this to happen.
I hope I made myself clear, and I would
really appreciate it if anybody could help!
you could try writing the url to a cookie or a session variable and then fetching the info using php - have a look on google for 'php sessions' or 'php cookies'
the session would last as long as the visitor has his browser window open
the cookie would last as long as you set it to last
hope this helps
I was actually considering using cookies.
But is there no way to write the link into the actual html of the original page when the user clicks the button?
Can anyone else help...please?
I realised that considering forums can do it, there must be a simpler way to do it. Based on the forum scripts.
cookies, sessions or write to db - only way to maintain it (cant think of anything else) choose one and plan your page/code ffoeg
What do you mean by writing to db? is that a Database? topr8
>>But is there no way to write the link into the actual html of the original page when the user clicks the button?
yes of course there is.
search for something like: editing text file php
basically your html page is the text file, submit the form to a php page that gets the form value, opens the text file, adds the url to the text file, closes the text file and finally redirects the user to the html page.
much simpler than it looks once you start.
topr8 u are correct, text file may be the solution to this problem :) i have forgotten it (dont use it too often myself) ffoeg
thanks. i'll search on google or something for that and start learning :) BetterSEO
Why not use GET to append the URL as a variable onto the end of the original URL like:
<?php echo "<a href=\"$url\">$url</a>";?>
<form action="" method="get"> <input type="text" name="url"> <input type="submit" value="Submit"> </form>
Now when the page is refreshed, the variable remains on the end of the original URL like: mydomain.com/index.php?url=example.com