This is a discussion on "Link submit" within the PHP Forum section. This forum, and the thread "Link submit are both part of the Program Your Website category.
|
|
|
|
|
![]() |
||
Link submit
|
||
| Notices |
![]() |
|
|
LinkBack | Thread Tools |
|
#1
|
||||
|
||||
|
Hello.
I would like a page that people can go onto type in a name of a site and the URL, then it appear in a table on the page. Preferably without MySQL because I don't understand it well.. but if it has to that's okay. Also if possible being able to apply a validation rule so that people can't spam the page with lemonparty.org and goatse.cs thanks!
Last Blog Entry: 3D Chess in your browser! (Mar 14th, 2008)
|
|
|
|
#2
|
|||
|
|||
|
Re: Link submit
When links are submitted, append the URL and the title to a .txt file on a new line with some sort of separator, e.g. http://www.url.com|Title
To display the links: Count the number of lines in the file. e.g.
Now, for each line, explode() it into the different parts and echo() it to the page. e.g.
----------------------------------------------------------------------- EDIT: Forgot you asked about validation. When the user submits it, perform a quick check before adding the data to a file: e.g.
I have posted an alternative (better) way to display the links a bit further down in the topic. EDIT 3 Commented the code to make it more readable. Last edited by balaclave; Jul 13th, 2007 at 15:02. |
|
#3
|
|||
|
|||
|
Re: Link submit
What's the difference between echo and print. Are they interchangeable?
Pete. |
|
#4
|
|||
|
|||
|
Re: Link submit
Quote:
This seems to be one of the most referred to documents on the issue. |
|
#5
|
||||
|
||||
|
Re: Link submit
utterly confused!
But I will read over it and test it. Thanks!
Last Blog Entry: 3D Chess in your browser! (Mar 14th, 2008)
|
|
#6
|
|||
|
|||
|
Re: Link submit
Quote:
Thanks, Pete. |
|
#7
|
|||
|
|||
|
Re: Link submit
I always use echo().
I just realised there is a problem with my code. Using a colon as a seperator wouldn't work, because URLs have colons. :P I changed it to a verticle line thing. ( | ) EDIT: Forget that first post. This works a lot better.
Commented the code. The code in my first post in the topic is now working. Last edited by balaclave; Jul 13th, 2007 at 15:02. |
|
#8
|
||||
|
||||
|
Re: Link submit
Thanks for that
Gunna test it now. and yeah I think that's about the only use for a pipe
Last Blog Entry: 3D Chess in your browser! (Mar 14th, 2008)
|
|
#9
|
||||
|
||||
|
Re: Link submit
Okay it works perfectly
Just need to know how to set up a form so that people can submit a site to the file. How do i do this? Thanks again!
Last Blog Entry: 3D Chess in your browser! (Mar 14th, 2008)
|
|
#10
|
|||
|
|||
|
Re: Link submit
Vertical line things "|" are your friend in JavaScript. The logical operator for 'or' is two vertical line things "||". I hate all of these stupid symbols those cos they are in ridiculous places on your keyboard. Can you get a key pad with just coding symbols on it? If you can't I'm going to make one. I don't know how but I will.
Pete. |
|
#11
|
||||
|
||||
|
Re: Link submit
Actually I swear I saw one a while ago.
it was USB and about the size of the numpad on normal keyboards. Not sure where I saw it though sorry! My keyboards the worst, UK laptop keyboard, set up in US layout. So when I want @ i have to do ". annoying -_-
Last Blog Entry: 3D Chess in your browser! (Mar 14th, 2008)
|
|
#12
|
||||
|
||||
|
Re: Link submit
Found a tutorial
should be okay for now thanks!
Last Blog Entry: 3D Chess in your browser! (Mar 14th, 2008)
|
|
#13
|
|||
|
|||
|
Re: Link submit
Quote:
Piping is one of the most powerful features of the *nix command console. It uses the pipe symbols. See here. Quote:
If you're using XP: Start >> Control Panel >> Regional and Language Options >> Languages >> Details >> Select English (UK) >> Apply Quote:
I'm going out, I'll test it and fix anything that doesn't work. (I think it will work.) |
|
#14
|
||||
|
||||
|
Re: Link submit
you = lifesaver
fo sure someone sticky this? THANKS! -------------- Just one thing I need it to add to the text file on a different line. at the moment it adds it to the same line e.g. http://url.com/ |urlhttp://example.com/ |example. when it needs to be, http://url.com/ |url http://example.com/ |example I'm crap at php... so wouldn't know where to start --------------------------------- Okay all fixed now Thanks!
Last Blog Entry: 3D Chess in your browser! (Mar 14th, 2008)
Last edited by alexgeek; Jul 13th, 2007 at 17:39. Reason: needed editing.. |
|
#15
|
||||
|
||||
|
Re: Link submit
Thanks balacave
Right everythings up and working if you want to see, go here http://www.alexgeek.co.uk/PHP/links.php add your site if you like. And I know I've asked for a lot... but does anyone know how to set a time limit between submitting. like the user submits an URL and needs to wait 30 seconds for another one.
Last Blog Entry: 3D Chess in your browser! (Mar 14th, 2008)
|
|
#16
|
|||
|
|||
|
Re: Link submit
Quote:
Didn't have time to bug check before going out. This should work for your time-check thing. See you and your flat files. Grrrrrrr.
|