From PHP to VB.NET

Hello

I am working on a ASP.NET (Visual Studio) project and would be grateful for advice on how to translate the following into VB.NET:

<?php if($_POST['robots'] != '') { echo 'Sorry, we don\'t like spammers here!'; } else { // Process the form } ?>

Many thanks!

Bluenose

Well, if I remember my ASP correctly, something like this will work… (Been a long time, PHP is my fav!)
[php]
<%
dim robots
robots=Request.Form(“robots”)
If robots<>"" Then
Response.Write(“Sorry, we don’t like spammers here!”)
Else
// Process form…
End If
%>
[/php]
You don’t really need to set the variable if you don’t want to. MS seems to like to define them, though…
If I remember correctly, ASP does not use braces although they might nowadays and their writes were
based on the “Response” function… Hope that helps…

Very many thanks to you ErnieAlex

That looks just fine!

‘Robots’ is probably necessary in this case because the rest of the script, in HTML and CSS, relates to how to trap spambots without using a Captcha.

I can’t post a link here but it is located on the webdesignerforum.co.uk/topic/68584-anti-spam-form-without-captcha/

Thank you again - appreciated!

You are very welcome. After you have been a member for awhile, you can insert links to websites. That is to
prevent spammers or robots from posting links to their sites. It is in the same line of what your code is for!

I will mark this thread solved. If you run into another issue, please start a new thread! We are mostly PHP
programmers here, but, some have ASP background enough to help… Actually they are very close in the
way they work, but, different enough to be hard to translate some routines…

Thanks again, Ernie

I have already used your code and get no errors in ASP.NET.

These, incidentally (I can’t remember their name) <%…%> are only used in Classic ASP. ASP.NET doesn’t make use of them.

Cheers again!

Yes, Bluenose, <% %> are used in HTML ASP sites to embed ASP into the HTML…
But, it is what I used to use so typed it that way… I use VB.NET and understand the difference…
And, glad you do too…

CYA in the Bitstream…

Thanks again - all’s well with the world when the code is fine!

Sponsor our Newsletter | Privacy Policy | Terms of Service