•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 375,234 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 1,978 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 865 | Replies: 3
![]() |
•
•
Join Date: Jun 2007
Posts: 1
Reputation:
Rep Power: 0
Solved Threads: 0
Hi,
I am using a PHP form and I would like to have the ability to convert any emails and URLs that are in the post to automatically have a hyperlink.
I don't want to enable any other html tag other than the hyperlink in my posts and I am not sure how this can be accomplished.
Thanks in advance for your response.
--
I am using a PHP form and I would like to have the ability to convert any emails and URLs that are in the post to automatically have a hyperlink.
I don't want to enable any other html tag other than the hyperlink in my posts and I am not sure how this can be accomplished.
Thanks in advance for your response.
--
•
•
Join Date: Oct 2006
Location: Sofia, Bulgaria
Posts: 135
Reputation:
Rep Power: 2
Solved Threads: 7
Hmmmm, well, using php, the first thing that comes up to my mind is to do something like this, however, it may turn out to be reaaallly slow with large posts. However, you can try it.
1. After submit, the content of the form gets exploded into an array.
2. Each value of this array is then checked for strings http://, or www., or @
3. If one of the following is found, you have to store the value again in the array with some extra data, which is - if it is an url, it should be something like <a href="value goes here">Value goes here</a>, or if it is an e-mail, it will be <a href="mailto:your value goes here">Your value here</a>.
4. Implode the array into a variable in the same order, in order to maintain text structure.
5. Write the post to a database, or do whatever you want with it.
Maybe the other guys here will figure out a smarter way, as it seems to me this is not the best solution.
Cheers.
1. After submit, the content of the form gets exploded into an array.
2. Each value of this array is then checked for strings http://, or www., or @
3. If one of the following is found, you have to store the value again in the array with some extra data, which is - if it is an url, it should be something like <a href="value goes here">Value goes here</a>, or if it is an e-mail, it will be <a href="mailto:your value goes here">Your value here</a>.
4. Implode the array into a variable in the same order, in order to maintain text structure.
5. Write the post to a database, or do whatever you want with it.
Maybe the other guys here will figure out a smarter way, as it seems to me this is not the best solution.
Cheers.
" Of all the things I've lost,
I miss my mind the most...."
Mark Twain
I miss my mind the most...."
Mark Twain
sounds sensible to me. look into using 'oreg_replace' as you can specify regular expressions to convert the string http://uk2.php.net/manual/en/function.preg-replace.php
When Autumn Falls [ http://www.whenautumnfalls.co.uk ] &&
Designdotworks [ http://www.designdotworks.co.uk ] Web / Graphic / Software Design
Designdotworks [ http://www.designdotworks.co.uk ] Web / Graphic / Software Design
•
•
Join Date: Feb 2002
Location: Lawn Guylen, NY
Posts: 10,873
Reputation:
Rep Power: 32
Solved Threads: 107
Yeah, it's preg_replace, not oreg_replace. Also read up about regex (regular expressions).
Dani the Computer Science Gal
Do you run a computer-related website? Feature it in our niche link directory!
Do you run a computer-related website? Feature it in our niche link directory!
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb PHP Marketplace
Similar Threads
- Is there a conflict between Php 4.3.2 and Php4.2.3? (PHP)
- vBulletin mod_rewrite (PHP)
- I Need Help Please. Adding PHP Code To My Site. (PHP)
- how do i mod a php forum? (PHP)
Other Threads in the PHP Forum
- Previous Thread: Simple Date (GMT)
- Next Thread: PHP - creating subdomains - creating child websites for users



Linear Mode