New to PHP looking for help

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Art Shotwell
Forum Newbie
Posts: 15
Joined: Mon Mar 12, 2007 6:16 pm
Location: Anacortes, Wash.

New to PHP looking for help

Post by Art Shotwell »

Hi, I've built a Web site for a friend... they want to add a magazine subsripting page. But, they have several different subscription rates: US, Canada, foreign, 1-, 2-, & 3-years, first class for US, Canada and foreign. I've never done anything in PHP and I've kinda chosen it because the credit card processor needs me to use it to pass subscription info to them. This should be easy, but I have no idea where to start. I've look at a couple online tutorials and I'm totally lost. I've laid out a page with the subscriptions info on it at http://www.nscalemagazine.com/subscribe2.html. Anyone willing to help out???
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Re: New to PHP looking for help

Post by RobertGonzalez »

Art Shotwell wrote:Anyone willing to help out???
This entire community is willing to help. But you gotta start somewhere. Have you coded anything for this yet?
Art Shotwell
Forum Newbie
Posts: 15
Joined: Mon Mar 12, 2007 6:16 pm
Location: Anacortes, Wash.

Post by Art Shotwell »

Yes, I gotta start somewhere, but I don't know where to start. And, I guess I'm violating your rule in your signature line by asking for help without any code yet. Sorry.
User avatar
iknownothing
Forum Contributor
Posts: 337
Joined: Sun Dec 17, 2006 11:53 pm
Location: Sunshine Coast, Australia

Post by iknownothing »

how are you passing subscriber information to the credit card processor? did they give you a direct link with some variables to use (eg. $name, $address, $phone), or do you email them the information along with an order number for example.

It sounds odd that they would use any method such as these, as it can potentially open them up to all kinds of problems. Do they not have their own page where a user submits their details, which your site would link to when a user clicks on "purchase subscription"?
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

You're not viloating any rules yet. New folks to the forums always get a little leniency from me (only a little though :wink:).

Seriously, before you get too far into coding, I would try looking for some tutorials on how to do what you want. There are lot of different way to achieve what you want, so it would make sense to get going in a direction then hit us up for help. Like I said, we are all more than willing to help.
Art Shotwell
Forum Newbie
Posts: 15
Joined: Mon Mar 12, 2007 6:16 pm
Location: Anacortes, Wash.

Post by Art Shotwell »

iknownothing wrote:how are you passing subscriber information to the credit card processor? did they give you a direct link with some variables to use (eg. $name, $address, $phone), or do you email them the information along with an order number for example.

It sounds odd that they would use any method such as these, as it can potentially open them up to all kinds of problems. Do they not have their own page where a user submits their details, which your site would link to when a user clicks on "purchase subscription"?
I don't need to pass any subscriber information, that will be filled out on a form hosted by CyberSource, the processor. I use a security script generated by them, hop.php, to pass vendor information, total amount and tax amount, along with a couple other fields which I have added for the vendor. Because their script needs to have the total amount and tax amount passed in a php script, my intent was to use a single html page, with maybe radio buttons, for a subscriber to choose among the subscription choices, then to post that another page that will, in turn, post to the CyberSource hosted order page.
Art Shotwell
Forum Newbie
Posts: 15
Joined: Mon Mar 12, 2007 6:16 pm
Location: Anacortes, Wash.

Post by Art Shotwell »

Everah wrote:You're not viloating any rules yet. New folks to the forums always get a little leniency from me (only a little though :wink:).

Seriously, before you get too far into coding, I would try looking for some tutorials on how to do what you want. There are lot of different way to achieve what you want, so it would make sense to get going in a direction then hit us up for help. Like I said, we are all more than willing to help.
I have looked at several tutorials, but because I'm new to scripting languages, it's mostly Greek. My tendancy would be to use radio buttons to choose from among: US subscriptions, Canadian and Foreign subscriptions; then shipping to Washington state address; then 1 year, 2 years or 3 years; then regular second class or first class; with someway to add sales tax for Washington subscriptions, then pass along the total cost & tax (that's the way Cybersouce wants it) via post to their site.
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

Seems straightforward enough. Do you at least have an HTML form that we could see. The HTML, not the rendering of the HTML.
Art Shotwell
Forum Newbie
Posts: 15
Joined: Mon Mar 12, 2007 6:16 pm
Location: Anacortes, Wash.

Post by Art Shotwell »

Everah wrote:Seems straightforward enough. Do you at least have an HTML form that we could see. The HTML, not the rendering of the HTML.
Hah! My first attempt was the lazy way. I created a page with the options and links to a separate page with the cost hard-coded into the page and the hop.php from there. My background is actually as a UI designer, with next to no coding background. I use Dreamweaver. No real coding background, except to tweak or fix Dreamweaver code. I'll work on a form.
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

Get your form done. Then we can look at getting your code worked out. Be prepared to learn because we teach like crazy.
Art Shotwell
Forum Newbie
Posts: 15
Joined: Mon Mar 12, 2007 6:16 pm
Location: Anacortes, Wash.

Post by Art Shotwell »

Okay, here are forms from two pages. I've removed most of the html to make the forms easier to read. I need the second page because the line with the InsertSignature in it needs the total sales amount. What I've got her lacks is: no way to add sales tax for Washington deliveries. I could add four more radio inputs, but that seems inelegant. I need to be able to move from the first page to the second: total amount, tax amount, description of what's being purchased.

---------------subscribe.html-----------------

Code: Select all

<form action="order.php" method=post>

<p><strong>United States delivery address  (We add sales tax for Washington state shipping addresses)</strong></p>
<p><input type=radio name="subscribe" value="domestic_1_year">1 year - $28.00<br> 
<input type=radio name="subscribe" value="domestic_2_years">2 years - $53.50<br> 
<input type=radio name="subscribe" value="domestic_3_years">3 years - $79.00</p>

<p><strong>Foreign & Canada</strong></p>
<p><input type=radio name="subscribe" value="foreign_1_year">1 year - $32.00<br> 
<input type=radio name="subscribe" value="foreign_2_years">2 years - $61.50<br> 
<input type=radio name="subscribe" value="foreign_3_years">3 years - $91.00</p>

<p><strong>First Class</strong></p>
<p><input type=radio name="subscribe" value="domestic_first_class">U.S. & Canada: 1 year - $42.00<br> 
<input type=radio name="subscribe" value="foreign_first_class">Foreign: 1 year - $64.00</p>

<p><input type=submit name="submit" value="Continue"> <input type=reset value="Clear"></p>
---------------order.php--------------

Code: Select all

<?php include("HOP.php") ?>
<? 
$amount=$_POST["total_amount"];
?>
<?
$taxamount=$_POST["taxamount"];
?>
<html>
<form action="https://orderpage.ic3.com/hop/orderform.jsp" method=post>

<?php InsertSignature($amount, "usd") ?>

Your total charge will be <?php echo $amount; ?>
	
<input type=radio name="merchantDefinedData1" value="new"> New Subscription?</p>
<input type=radio name="merchantDefinedData1" value="renewal"> Renewal Subscription </p>

If Renewal, please enter account number 
<input name="merchantDefinedData2" size=15 maxlength=20></p>

<input type=submit name="submit" value="Checkout"> 
<input type=reset name="reset" value="Clear"> </p>

<input type=hidden name="orderPage_transactionType" value="sale">
<input type=hidden name="comments" value="1 year subscription, standard delivery">
</form>
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

Code: Select all

<?php 
include("HOP.php");
// These should be run through an isset() check
$amount = $_POST["total_amount"];
$taxamount = $_POST["taxamount"];
?>
<html>
<form action="https://orderpage.ic3.com/hop/orderform.jsp" method=post>

<?php InsertSignature($amount, "usd"); ?>

Your total charge will be <?php echo $amount; ?>
       
<input type=radio name="merchantDefinedData1" value="new"> New Subscription?</p>
<input type=radio name="merchantDefinedData1" value="renewal"> Renewal Subscription </p>

If Renewal, please enter account number
<input name="merchantDefinedData2" size=15 maxlength=20></p>

<input type=submit name="submit" value="Checkout">
<input type=reset name="reset" value="Clear"> </p>

<input type=hidden name="orderPage_transactionType" value="sale">
<input type=hidden name="comments" value="1 year subscription, standard delivery">
</form>
Art Shotwell
Forum Newbie
Posts: 15
Joined: Mon Mar 12, 2007 6:16 pm
Location: Anacortes, Wash.

Post by Art Shotwell »

Everah wrote:

Code: Select all

<?php 
include("HOP.php");
// These should be run through an isset() check
$amount = $_POST["total_amount"];
$taxamount = $_POST["taxamount"];
?>
I think I can do that...but...if they're not set, then we're losing necessary data for the transaction. And, they should be set in the POST from the html. Of course, they're not in my html 'cause I don't know how to use them. I got that code from CyberSource support.

My problem first, though, is how to get the first page running...
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

Art Shotwell wrote:I think I can do that...but...if they're not set, then we're losing necessary data for the transaction.
That is why you check that they are set. If they are not, then you really shouldn't processing the form data, right?
Art Shotwell wrote:And, they should be set in the POST from the html. Of course, they're not in my html 'cause I don't know how to use them. I got that code from CyberSource support.
You mean like pushing that information from the first form to the second form so they are already filled out in the second form?
Art Shotwell wrote:My problem first, though, is how to get the first page running...
The first page is only a form, correct? Can it be static HTML to start?
Art Shotwell
Forum Newbie
Posts: 15
Joined: Mon Mar 12, 2007 6:16 pm
Location: Anacortes, Wash.

Post by Art Shotwell »

The first page IS html. I had thought I'd have to change it to php to move the form results to the second page. I can set the form radio values to dollars/cents and, thus, move the price to the second page. But, I also want to be able to move a description for each item. I want to be able to echo the description and price for the item. Also move the description to the card processor. too. And, I haven't figured out how to add state tax to people who say they're ordering subscriptions for Washington state.
Post Reply