SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Member
    Join Date
    Oct 2013
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Help with If Then Elseif

    Hi im rubbish at programming, but im trying....

    Im trying to get a page to display the details posted to a form. Part of it is working and part of it isnt for some reason.

    Ive declared a new value called "responsecode", responsecode = Request.Form("gtpay_tranx_status_code")
    If the value posted to the form field "gtpay_tranx_status_code" is either "00" (double zero) or "001" then it should
    run the first part of the code below:

    If responsecode = "00" Then '001 is for VISA 00 for interswitch and MIGS

    lblTranxDescription = "<font color=green><b>Transaction Completed Succesfully</b></font>"
    lbltranxID = tranxid
    lblDescription = "<font color=green><b>Payment Approved Succesfully</b></font>"
    lbltraAmt = tra_amt

    But for some reason although the responsecode is 00 it is not running that but jumping to the last part and shoing it as failed instead:

    Else
    lblTranxDescription = "<font color=red><b>Transaction Failed</b></font>"
    lblError = responsecode
    lbltranxID = tranxid
    lblDescription = responsemessage
    lbltraAmt = tra_amt

    Please can someone point out what ive done wrong?
    (Also is it possible to use CreateMHTMLBody "page.asp" to post itself to email or does it have to be another page?)
    Im running out of time to get this working, thank you for your help.
    Joe

    =========================================================================================

    Code:
       <form id="form1" runat="server">
        <div>
        <%
    
                    If Request.Form >"" Then
     
                        Dim responsecode 
    					responsecode = Request.Form("gtpay_tranx_status_code")
                        Dim responsemessage
    					responsemessage = Request.Form("gtpay_tranx_status_msg")
                        
                        Dim tra_amt
    					tra_amt = Request.Form("gtpay_tranx_amt")
                        Dim tranxid 
    					tranxid = Request.Form("gtpay_tranx_id")
                        Dim cust_id
    					cust_id = Request.Form("gtpay_cust_id")
                     	Dim tranx_memo
    					tranx_memo = Request.Form("gtpay_tranx_memo")
    					Dim echo_data
    					echo_data = Request.Form("gtpay_echo_data")
    					
    				  Dim lblTranxDescription
    				  Dim lblDescription
    				  Dim lbltraAmt
    				  
                        If responsecode = "00"  Then   '001 is for VISA  00 for interswitch and MIGS
    
                            lblTranxDescription = "<font color=green><b>Transaction Completed Succesfully</b></font>"
                            lbltranxID = tranxid
                            lblDescription = "<font color=green><b>Payment Approved Succesfully</b></font>"
                            lbltraAmt = tra_amt
    						
    					Elseif responsecode = "001"  Then
    					
    					    lblTranxDescription = "<font color=green><b>Transaction Completed Succesfully</b></font>"
                            lbltranxID = tranxid
                            lblDescription = "<font color=green><b>Payment Approved Succesfully</b></font>"
                            lbltraAmt = tra_amt
    						
                        Else
                            lblTranxDescription = "<font color=red><b>Transaction Failed</b></font>"
    						lblError = responsecode
                            lbltranxID = tranxid
                            lblDescription = responsemessage
                            lbltraAmt = tra_amt
                        End If
    
                    End If
    %>
    
            <table class="htmlForm2">
                <tr>
                    <td>
                       <h3>Your Transaction has been completed please find the status of the transaction below:</h3>
                       </td>
                </tr>
                <tr>
                    <td><% response.write lblError %>
                        </td>
                </tr>
    			 <tr>
                    <td>
                       Order Id: <% response.write cust_id %>
                    </td>
                </tr>
                <tr>
                    <td>
                       Transaction Description: <% response.write lblTranxDescription %>
                    </td>
                </tr>
                <tr>
                    <td>
                        Transaction Reference: <% Response.write lbltranxID %>
                        
                    </td>
                </tr>
                <tr>
                    <td>
                        Response Description: <% response.write lblDescription %>
                    </td>
                </tr>
                <tr>
                    <td>
                        Transaction Amount: N<% response.write lbltraAmt %>
                    </td>
                </tr>
                <tr>
                    <td>&nbsp;
                        </td>
                </tr>
               
            </table>
        
        </div>
        </form>

  2. #2
    Just Blow It bronze trophy
    DaveMaxwell's Avatar
    Join Date
    Nov 1999
    Location
    Mechanicsburg, PA
    Posts
    7,200
    Mentioned
    105 Post(s)
    Tagged
    1 Thread(s)
    It may be something as simple as it not treating responsecode as a string value. Or you may have leading/trailing spaces in your value.

    If you change

    responsecode = Request.Form("gtpay_tranx_status_code")

    To

    responsecode = Trim(Request.Form("gtpay_tranx_status_code"))

    It should work IF the value in the code is what you expect....
    Dave Maxwell - Manage Your Site Team Leader
    My favorite YouTube Video! | Star Wars, Dr Suess Style

  3. #3
    SitePoint Member
    Join Date
    Oct 2013
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I will test it and let you know thanks for the reply...

  4. #4
    SitePoint Member
    Join Date
    Oct 2013
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That seems to have highlighted a problem, in that the code being posted to the page is not what it should have been. Thank you for that...

    Can I ask, if I set up a CDO email script on the bottom of this page, can I use CreateHTML to email this same page back to myself or to
    another email address? Or can I only point this command to annother seperate page?

    (Because once it is working I need to both display the response and email it too.)

  5. #5
    SitePoint Member
    Join Date
    Jan 2014
    Posts
    16
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Place on your page response.write responsecode somewhere below responsecode = Request.Form("gtpay_tranx_status_code"), that will gives you what exactly you getting on post.
    Second part is easier.
    Create your CDO email function and put it either in include file or somewhere on that page as SUB and than call that SUB something like this:

    <%
    dim emailto, emailfrom,textmessage
    emailto=Client Email
    emailfrom=Email Origin-must be authorized on your email server
    textmessage= What ever info you need to send
    call CDOSub(emailto, emailfrom,textmessage)
    %>
    </div>
    </form>
    <%
    sub CDOSub(string emailto, string emailfrom,string textmessage)
    do your CDO staff here
    end sub
    %>


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •