PHP if exist trouble

Greetings All, I am attempting to use some small php statement to check if a certain ‘box’ (field? var?) has been filled in on a User Registration form. If any data is entered in this field, I would like the registration to fail (anti-bot idea). The php is this:

[php]if (null !==$_POST[‘ICQ’])
}
exit (“Bot Warning”) ;
}[/php]

…and the var I am attempting to reference I think is defined later here (it’s a .tpl file in phpBB 2x):

<td class="row1"><span class="gen">{L_ICQ_NUMBER}:</span></td> <td class="row2"> <input type="text" name="icq" class="post" style="width: 100px" size="10" maxlength="15" value="{ICQ}" /> </td>

Any help would be thoroughly appreciated chaps-- I have no idea what I’m doing here!

[php]if ( strlen(trim($_POST[‘ICQ’])) > 0)[/php]

Thank you kindly for that suggestion. However, when I modify my code as such, a bit of this code line appears as text at the beginning of the Reg Form page: “0) { exit (“Bot Warning”) ; } ?>”…

Have I screwed this up? Did I place the php code in the wrong place in the file (now at the beginning of the .tpl)? Or in th wrong file (now in profile_add_body)? Any ideas? Thanks a lot!

Curent php
[php]<?php
if (strlen(trim($_POST[‘ICQ’])) > 0)
{
exit (“Bot Warning”) ;
}
?>[/php]

Considering it is php, it doesn’t go in a top file.

Hmmm… I am confused. Into which file should this php code be placed, considering that this is a BB forum. Does it go into the index.html, or one of the .tpl files? In the correct file, does it need to sit somewhere specifically within that file?

Well, if you are using it to prevent automated spam: you will need to have it before the code that processes the post request.

Thanks astonecipher, yes I do have. This php code is in the file “profile_add_body.tpl”. It is placed at the start of that file before any other comment, the first of which (below) is <form action… In fact, I have tried moving my php to other parts of this same file, always with identical results. Do you reckon that this is indeed the correct place for the code, or I have I got it wrong?

I don’t know of tpl files that execute php, they are template files because the logic is not a part of their purpose, or shouldn’t be.

Sponsor our Newsletter | Privacy Policy | Terms of Service