REGEX CHECK WORDPRESS TAGS
posted by Subzero on 2009-07-22 14:41:13
Hi, sorry for my bad english, my question is:
i riceve a tags from post: $tags = $_POST['tags']; //Es: gossip, culture, internet, (the tags of wordpress)
and I would find them with the regex, but that should not exceed 7 words, that is, for example tags1, tags2, tags3, tags4, tags5, tags6, tags7 and stop, if there is tags7 I must leave an error.
my code is:but when I surpass even one tags me it onto the same ...
Thanks
i riceve a tags from post: $tags = $_POST['tags']; //Es: gossip, culture, internet, (the tags of wordpress)
and I would find them with the regex, but that should not exceed 7 words, that is, for example tags1, tags2, tags3, tags4, tags5, tags6, tags7 and stop, if there is tags7 I must leave an error.
my code is:
$tags = $_POST['tags']; if( !preg_match( "/([a-zA-Z0-9\-\_ ]+,){1,7}/s", $tags)){ echo('<noscript>Errore: Tags non validi oppure maggiori di 7!</noscript><script language="JavaScript">alert("Errore: Tags non validi oppure maggiori di 7!");location.href=\'<a href="http://www.mysite.it\';" rel="nofollow" target="_blank">http://www.mysite.it\';</a></script>'); die(); } else { $tags = htmlspecialchars($_POST['tags']); }
Thanks
0
Hello,
Why do you want to use regex? You could use explode(), example:Tell me if it's good for you!
Bye
Why do you want to use regex? You could use explode(), example:
$tags = $_POST['tags']; if (count(explode("," $tags, 8))>7){ echo('<noscript>Errore: Tags non validi oppure maggiori di 7!</noscript><script language="JavaScript">alert("Errore: Tags non validi oppure maggiori di 7!");location.href=\'<a href="<a href="http://www.mysite.it\';"" rel="nofollow" target="_blank">http://www.mysite.it\';"</a> rel="nofollow" target="_blank"><a href="http://www.mysite.it\';" rel="nofollow" target="_blank">http://www.mysite.it\';</a></a></script>'); exit(); } else $tags = htmlspecialchars($tags);
Bye

0

0
i have correct is for ,but now i have an other error in other line:
Parse error: syntax error, unexpected ',' in /membri/socialgeeks/wp-content/themes/prologue/index.php on line 31is for check the url :P
Parse error: syntax error, unexpected ',' in /membri/socialgeeks/wp-content/themes/prologue/index.php on line 31
if ( "/(http|https)(\:\/\/www.|\:\/\/)([a-zA-Z0-9\_\-\&\%\.\/\?\=]*)/s", $link){

0
ok, you were great, the code works perfectly, and I solved the second problem;)
if( preg_match( "/(http\:\/\/|http\:\/\/www\.)[a-zA-Z0-9\_\-\&\%\.\/\?\=]*/s", $link)){
0
Answer the question
Top Users
- dail (12)
- livin52 (3)
- camu (3)
- softweb (2)
- Nadine (1)
- Josware (1)
- lfelipecr (1)
- gregoriohc (1)
- Mitu (1)
- ryan714 (1)