PDA

View Full Version : Regular expression and textfield - setEditable(false);


Sscotties
10-11-2002, 04:10 AM
Is the a regular expression in PHP to render a string variable as 'SET' - You cannot alter the value

One line of example code is all I ask of you kind folk

Spookster
10-11-2002, 07:57 AM
Could you explain that a bit more and give an example? I'm not sure I understand what you are asking for.

Sscotties
10-11-2002, 11:38 AM
Thank you for your interest - it is for a login page that takes you to a message board - So, when the user logs in to the password textfield and the 'name' textfield, I want that data to persist.

No prob's there, it says "Welcome Sscotties" and the 'Sscotties' is dropped into the textfield. What I would like to do, is to set the text in the second 'name' textfield on the bulletin board appl to non-editable, so that users cannot pretend to be someone else by changing their name.

Thanks ... AND - sorry, but can you PLEASE help with this too!?

Ive used this function OK

$permit = "<br /><u><b><i><pre><big><li>";
$data = strip_tags($data, $permit);

Next, I want it to pick up any word beginning with http://... and wrap the href a tags around it so that it auto linked. As I wasn't very clear in the first post, let me do it in pseudo ...

> search strings for words that start with 'http://'

> isolate the word so that ; - $linkWord = "http://..."

> add tags before and after the $linkWord so that we get this;-

<a href="$linkWord">$linkWord</a>



Hope that's clear now, thanks again.

Sscotties
10-12-2002, 09:25 PM
:)

Spookster
10-12-2002, 11:04 PM
Which message board is this?

Sscotties
10-13-2002, 04:14 AM
It's just a private message board at the university where I attend. I originally 'borrowed' two skeleton text-based systems (non-SQL as the scholl server doesn't support it) and have taken ideas and bits of code from both and developed one that has - to an extent become my own.

The board is a small part of my final year project on e-learning methods - of more importance, it will provide a support network for students studying one part of their IT course in multimedia.

Do you want the log-in? I'll grant you sign on privelidges ...

Thank you for your interest so far

mordred
10-13-2002, 02:19 PM
You might try this snippet I got from the FAQ of the german PHP newsgroup, it works quite good:


function replace_uri($str) {
$pattern = '#(^|[^\\"=]{1})(http://|ftp://|ftp://|mailto:|news:)([^\\s<>]+)([\\s\\n<>]|$)#sm';
return preg_replace($pattern, "\\\\1<a href=\\"\\\\2\\\\3\\">\\\\2\\\\3</a>\\\\4", $str);
}