Solved

Convert small asp script to php

Posted on 2003-11-18
4
364 Views
Last Modified: 2013-12-13
Hi,

I am attempting to set up my first shopping cart system for my first web site using 1shoppingcart.com.  Unfortunately, I just found out my web hosting company does not support asp.  However, they do support php.  Is this a normal occurence of web hosting companies?

1shoppingcart.com gives the following asp script with the following directions so that their url does not show up in my customers browser, but my url will.  I was told by my web hosting company that the same results can be obtained with php.  So basically I just need a php script that will accomplish the same result as this asp script.  I'm not a programmer, so please keep your explanations on how I use your script simple.

Thank you.

(Is 1shoppingcart.com a reputable company and/or do you have any other suggestions for a shopping cart system?)
The following is the 1shoppingcart.com asp script:


<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<%
'// Command Script generated and powered by
'// 1ShoppingCart.com(c) 2003
'// http://www.1shoppingcart.com

dim merchantID,cmd,dest,baseurl

merchantID="67928"
cmd=Request("cmd")
baseurl="http://www.1shoppingcart.com"
dest=baseurl&"/app/default.asp?id="&merchantid

if request("productid")<>"" then
      if cmd="checkout" then
            dest=baseurl&"/app/javanof.asp?merchantid="&merchantID&"&"&request.querystring
      else
            dest=baseurl&"/app/netcart.asp?merchantid="&merchantID&"&"&request.querystring
      end if
elseif cmd<>"" then
      select case cmd
            case "cart"
                  dest=baseurl&"/app/netcart.asp?merchantid="&merchantid
            case "checkout"
                  dest=baseurl&"/app/javanof.asp?merchantid="&merchantid
            case "login"
                  dest=baseurl&"/app/aflogin.asp?merchantid="&merchantid
            case "signup"
                  dest=baseurl&"/app/afsignup.asp?merchantid="&merchantid
            case "cancel"
                  dest=baseurl&"/app/removesave.asp?merchantid="&merchantid&"&clientid="&request("id")&"&removear=Yes"
            case "update" 'change
                  dest=baseurl&"/app/r.asp?merchantid="&merchantid&"&id="&request("id")&"&c=1"
            case else 'home
                  dest="www.thebatteryshoppe.com"
      end select
else
      if request("af")<>"" then 'aftrack
            dest=baseurl&"/app/aftrack.asp?afid="&request("af")&"&u="&request("u")
      elseif request("ad")<>"" then 'adtrack
            dest=baseurl&"/app/adtrack.asp?adid="&request("ad")
      elseif request("email1")<>"" then 'contact
            dest=baseurl&"/app/contactsave.asp?merchantid="&merchantid
            if request.querystring<>"" then dest=dest & "&" & request.querystring
            if request.form<>"" then dest=dest & "&" & request.form
      end if
end if

response.redirect(dest)
response.end()
%>


Directions of 1shoppingcart.com for the use of their script above:

With 1ShoppingCart.com and our simple Command Script, your links, ads, and affiliate traffic will all be pointed to your domain, rather than to http://www.1shoppingcart.com. Just follow the easy instructions in this setup wizard!
If you would prefer not to use the Command Script, just click the Skip button at bottom to start creating shopping cart products immediately.
First, choose a script platform, then copy-paste all of the code from the text box into a simple text editor (Notepad or Textpad, etc).
Next, save the code as cmd.asp (ASP) to your local hard drive.
After you have saved the file, upload it to your website. ASP users, just save the file to any folder on your site - we recommend you put it in the root ("home") folder.
Now, enter the URL for your Command Script file here.
Example: http://www.mydomain.com/cmd.asp
Press  Save and Continue

Thats all the more directions I can provide at this time.  I was told that my web host company uses a Linux based system, but my web site consists of html, php, javascript, and sql.  I was told by my web hosting company that the same results as the asp script above can be obtained with php.  

I sincerely appreciate your help.

Steve
www.thebatteryshoppe.com

0
Comment
Question by:Steve234
4 Comments
 
LVL 2

Assisted Solution

by:errows
errows earned 75 total points
Comment Utility
You could see the following script to convert your ASP script in PHP: http://asp2php.naken.cc/

Don't know anything about shopping carts...

errows
0
 
LVL 4

Accepted Solution

by:
intrwrks earned 350 total points
Comment Utility
I tried re-writing the code listed above. I am unable to test but it should work.

<?php
$merchantID = "67928";
$cmd = $_REQUEST['cmd'];
$baseurl = "http://www.1shoppingcart.com";
$dest = $baseurl . "/app/default.asp?id=$merchantID";

// get all the post values in a string
while (list ($key,$value) = each($_POST))
{
      $post .= "&$key=$value";
}

if ($_REQUEST['productid'] != "")
{
     if ($cmd == "checkout")
          $dest = "$baseurl/app/javanof.asp?merchantid=$merchantID&" . $_SERVER['QUERY_STRING'];
     else
          $dest = "$baseurl/app/netcart.asp?merchantid=$merchantID&" . $_SERVER['QUERY_STRING'];
}
elseif ($cmd != "")
{
     switch($cmd)
     {
          case "cart":
              $dest = "$baseurl/app/netcart.asp?merchantid=$merchantID";
      break;
          case "checkout":
              $dest = "$baseurl/app/javanof.asp?merchantid=$merchantID";
      break;
          case "login":
                $dest = "$baseurl/app/aflogin.asp?merchantid=$merchantID";
      break;
          case "signup":
                $dest = "$baseurl/app/afsignup.asp?merchantid=$merchantID";
      break;
          case "cancel":
                $dest = "$baseurl/app/removesave.asp?merchantid=$merchantID&clientid=" . $_REQUEST['id'] . "&removear=Yes";
      break;
          case "update":
                $dest = "$baseurl/app/r.asp?merchantid=$merchantID&id=" . $_REQUEST['id'] . "&c=1";
      break;
          default:
                $dest = "www.thebatteryshoppe.com";
      break;
     }
}
else
{
     if ($_REQUEST['af'] != "")
     {
         $dest = "$baseurl/app/aftrack.asp?afid=" . $_REQUEST['af'] . "&u=" . $_REQUEST['u'];
     }
     elseif ($_REQUEST['ad'] != "")
     {
         $dest = "$baseurl/app/adtrack.asp?adid=" . $_REQUEST['ad'];
     }
     elseif ($_REQUEST['email1'] != "")
     {
          $dest = "$baseurl/app/contactsave.asp?merchantid=$merchantID";

          if ($_SERVER['QUERY_STRING'] <> "")
      $dest .= "&" . $_SERVER['QUERY_STRING'];

          if ($_POST <> "")
      $dest .= "$post";
     }
}

header( "location: $dest" );
exit;
?>
0
 
LVL 11

Assisted Solution

by:Zontar
Zontar earned 75 total points
Comment Utility
This is not a good script since it uses the generic Request object rather than specifying whether GET or POST is to be used (Request.QueryString or Request.Form in ASP, $_GET or $_POST in PHP). This makes it easy to hack, since POST values can be sent in the querystring by a user.

(I'm talking about the original, not the translation offered in the previous post.)

PHP hosting is generally cheaper than ASP hosting, since PHP, MySQL, Linux, and Apache are all free and Windows and SQL Server aren't.

There are numerous PHP shopping cart scripts out there -- use the Google and find one. :^)
0
 

Author Comment

by:Steve234
Comment Utility
Hi everyone,

I apologize, I did not remember that I had this question open.

For various reasons, I could not use that shopping cart software, so I don't know if the script above actually worked.

Thank you for taking your time to try and help me.

Steve


I'm posting another question in this section, if you're available.

Thanks.
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
This article discusses how to create an extensible mechanism for linked drop downs.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to dynamically set the form action using jQuery.

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now