Jump to content

Check textarea if it includes <a> tag


sean14592

Recommended Posts

I have tried...

 

if ((strstr($main_desc, "<a")) || (strstr($area_desc, "<a")) || (strstr($getthere_desc, "<a"))){
echo '<br><center>';
echo 'Opps! Looks like we have a problem....<br><br>';
echo '<b>Error: <FONT COLOR="#FF3300"><u>You cannot include links in your any part of your listing unless specifically asked!</u></b></font>';
echo '<br><br><a href="'.$siteurl.'index.php?p=oaddprop5"><img src="'.$siteurl.'style/form/fix_error.gif" width="240" height="40" border="0" /></a>';
exit;
}

 

...sadly didnt work, i used <a> and didn't get any error, I will try other now :)

 

I have also tried...

 

if (  strpos( $_POST['main_desc'], '<a' ) !== FALSE  ){
    echo 'Found an <a> tag!';
}

 

...still dosent work

Sean

Link to comment
Share on other sites

If those don't work for you, you can try:

 

$post = "Lololol <a href=\"lol.php\">O_O</a>";
if (eregi('<a(.*)>', $post)) {
echo "Here!\n";  
//stuff
}
else {
  echo "Nope\n";
  //other stuff
}

 

Ok, when i try this i get....

Warning: eregi() [function.eregi]: REG_BADRPT in ******/public_html/pages/oaddprop6.php on line 154
Nope 

 

 

line 154 is....

if (eregi('<a(.*)>', $post)) {

 

 

Cheers

Sean

 

Link to comment
Share on other sites

Let me see what's actually in your variable.  Because it works for me.    Please show us the output of echo $_POST['whatever'] (I don't know which key you're using, lol), and obviously put in the correct key.

 

(And you're making me use PHP 5 for this. =(  PHP6 doesn't use ereg anymore.  That's why I wrote a PCRE one too, lol.)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.