Hi all,

I have to update some classic ASP code and I need to add an if statment to compare if a uppercase value is == "N/A" and to compare value with request("productLink") line 8 and if it is it should by pass validation on line 16.

Any further information required please let me know

Thanks in advance

David

<%@LANGUAGE="VBSCRIPT"%>
<!--#include file="../../includes/functions/insphire.asp"-->
<!--#include file="../../includes/functions/stock.asp"-->
<!--#include file="../../includes/functions/logaccess.asp"-->
<%
    if request("Allow") = "f875eba085941cc78509bd3482dc0294" then
        ' security check passed
        categorycodeSQL = "SELECT StockExpectedCategoryCode FROM StockExpectedCategories WHERE StockExpectedCategoryProductID = '" & replace(request("ProductLink"), "heaters", "heater") & "'"
        set rowCategoryCode = returnrecordsetstock(categorycodeSQL)

        if not rowCategoryCode.eof then
            ' category code found
            response.redirect("available.asp?Allow=" & request("Allow") & "&SONID=" & request("SONID") & "&ProductNo=" & request("ProductNo") & "&ProductQTY=" & request("ProductQTY") & "&ProductIgnore=" & request("ProductIgnore") & "&CategoryFilter=" & rowCategoryCode("StockExpectedCategoryCode"))
        else
            ' category code not found
            response.write("Incompatible Product Type")
        end if
    else
        ' security check failed
        dim CurrentDate, dbLog, IPAddress, logSQL

        CurrentDate = year(date) & "-" & month(date) & "-" & day(date) & " " & formatdatetime(now(), 3)
        IPAddress = request.servervariables("HTTP_X_FORWARDED_FOR")

        if IPAddress = "" then
            ' get ip address
            IPAddress = request.servervariables("REMOTE_ADDR")
        end if

        logSQL = "INSERT INTO LogIP (LogIPDate, LogIPAddress, LogIPPage) VALUES ('" & CurrentDate & "', '" & IPAddress & "', 'sons/allocate/select-group.asp')"
        set dbLog = ExecuteSQL2(logSQL)
    end if
%>

Recommended Answers

All 3 Replies

add an if statment to compare if a uppercase value is == "N/A"

What value are you referring to? Your description is not clear. Please ask your questions one by one and check the line numbers you are referring to. They doent seem to make sense when I look at your posted code.

Hi JorgeM,

Thanks for your reply

On line 8 I run an SQL query which compares a passed value from the previous page ("PoductLink") StockExpectedCategoryProductID = '" & replace(request("ProductLink") as a valid product in DB
ProductLink will contain a various values and one of these is a manual process where N/A is added in an input field because the product does not have a serial number and I need to avoid the validation of N/A because it is not stored in the DB.

After line 5 I wish to add an if statement to check if the value is equal to N/A and if it does I want bypass the validation process which starts on line 6 -17 and continue with the else statement on line 18.

The lines 6 - 17 validates if a serial number is valid. When N/A is passed through ProductsLink at lines 14-17 this rejects the N/A because it is not a serial number. So I want to bypass the validation process by checking with an If statement after line 5 if the value is qual to N/A and if not bypass validation after line 17

I assume it would be something like 'if request("ProductLink")=="N/A"' then do this, but not done much with ASP syntax.

I hope this has made things a little clearer.

David

check if the value is equal to N/A and if it does I want bypass the validation process which starts on line 6 -17 and continue with the else statement on line 18.

I would think that changing line 6 to the following gives you what you are looking for..

What you are asking about isn't really a coding thing, sounds like you just need to get the logic correct.

You can use the existing if condition and use other operators like And and <> (not equal to) so you can get the desired result. if I understand you correctly, this should work..

if request("Allow") = "f875eba085941cc78509bd3482dc0294" And request("ProductLink") <> "N/A" then

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.