Jump to content
Larry Ullman's Book Forums

Paypal - Yearly To Monthly


Recommended Posts

Hello Larry.....fantastic book....one of the best books I have read. I am in the education field and not the computer/programming field and your approach made complex ideas much more understandable...thanks so much!

 

I am wondering which files need to be manipulated or changed in order to switch the payment plan from yearly to monthly? I realize that I need to make some changes in the PayPal code, but which do I change in regards to the downloaded files that you provided? Also, the CONFIG File and information presented on page 58 was very confusing to me. I am not sure where the defined elements need to point to???/

 

 

define ('BASE_URI', '/includes/pdfs'); (should this point to where the pdfs will be downloaded to? if not, what values should be included in the area?)

 

define ('BASE_URL', 'www.samplesite/'); (this should be the site's address..correct?)

 

define ('PDFS_DIR', BASE_URI . '/includeds/pdfs/'); (or is this where the pdfs will be downloaded?)

 

define ('MYSQL', BASE_URI', '/includes/mysql.inc.php'); (mysql file is located in the inlcudes folder.....do i need to include the "includes-folder" here?)

 

 

The CONFIG file is located in the "includes folder".......do I need to include the "include folder" when pointing to a file in the same folder?

 

I appreciate any feedback and/or direction and look forward to hearing back from you.

Link to comment
Share on other sites

define ('BASE_URI', '/path/to/webroot'); <-- file path to local web root OR web root on server wherever you are placing the site online or on intranet testing environment

 

define ('BASE_URL', 'www.samplesite.com'); <-- web URL to web root of site. This could be a testing environment OR website hosted online.

 

define ('PDFS_DIR', BASE_URI . '/includeds/pdfs/'); <-- This is location to the folder your PDF files will be saved to when uploaded

 

define ('MYSQL', BASE_URI', '/includes/mysql.inc.php'); <-- You have a comma where there should be a period and a closing paren without an opening one.

Should be:

 

define ('MYSQL', BASE_URI.'/includes/mysql.inc.php'); <-- instead of using the BASE_URI here I just hardcode the entire path to the MySQL config file.

 

What is being done here is a short hand of sorts, instead of typing out the base URI path it is being taken from the BASE_URI definition and then the includes folder with file is being added to it.

  • Upvote 1
Link to comment
Share on other sites

The CONFIG file is located in the "includes folder".......do I need to include the "include folder" when pointing to a file in the same folder?

------------------------------

 

That depends on where you are linking the file from.

 

I am in the process of creating a modern CMS and with CMS's the core index.php file is being used as a conduit to load and pass information off to the other files within the CMS.

In this case I have a config file included in the main index.php file and since this file is also loading all the other files I don't need to reinclude the config file into all the other files because they inherit that information from the index.php file.

 

If you are working with files that are stand alone and don't know about other files or locations then you need to include the path to the axillary files. Even though you have defined the BASE_URI with the webroot of your site you can't just use that in your files without the files themselves knowing about this definition. In most cases you would indeed link to a file using the full path.

Though once you initially link the config file, using include or require or require_once then you can in future link to files by starting the path off with BASE_URI. This saved typing and auto changes based off of ONE definition which when changed updates ALL the files so they point to the correct location.

 

Long example but short answer is it depends on how your web application is designed and Where these files are being called from.

 

If they are standalone files that are not being called through a proxy file of some sort, like I mentioned how my CMS works above, then you can just do something like:

include('nameofFile.php');

 

If the file calling the above file is in the same folder, this would work.

 

But if you have a directory structure like:

webroot
 |
folder1      -      folder2
 |                   |
file1.php          file2.php

 

 

file1.php and file2.php don't know about each other and the filesystem doesn't know to tell PHP these two files exist, so you need to tell them.

 

 

If you do something like:

webroot
 |
index.php

folder1
 |
file1.php
file2.php

 

 

and index.php loads file1.php

AND

file1.php loads file2.php

 

It may work where you include or require file2.php from file1.php like:

include('file2.php');

 

BUT

 

It is "safer" to code the entire path either through harcode the whole URI path OR symbolic link or definition like Larry uses in the config files in the book.

 

But that can come down to style I guess. I just find it safer and always works to code the entire path to the file when including it.

 

My thoughts, take what works for you and leave the rest.

  • Upvote 1
Link to comment
Share on other sites

Thanks so much for the information Terry. I am very new to this type of information and am lucky I made it as far as I did.

 

In regards to the first two: Can they be the same? I understand that the second needs to point to the web URL, but where (or what) is the webroot? I use Godaddy and have multiple sites.

 

define ('BASE_URI', '/path/to/webroot');

define ('BASE_URL', 'www.samplesite.com');

 

Also, on a whole new topic and perhaps you could point me in the right direction. I am trying to include videos in the various categories for registered/paid users to view. Everything works well in regards to the sign-in process, receiving payments, and allowing only registered/paid users to view content. However, the tiny_mce editor would not display embedded videos so I linked them. The problem is that the entire URL is displayed for each of the videos, allowing users to bypass the whole registration process and view the videos without registering/paying (if they take notice and remember the URL).

 

Am I missing something or forgetting something in one of the files?

 

Again, any help is greatly appreciated.

 

michae

Link to comment
Share on other sites

I explain the differences between URI and URL here --> http://www.larryullman.com/forums/index.php?/topic/180-what-exactly-is-a-uri/

 

Basically URI is the file path to a file or folder.

 

BASE_URI is defined as the file path to the web root.

 

BASE_URL is defined as the URL or internet address to the web root.

 

You actually need both BASE_URI and BASE_URL defined because when you are telling php the locations of your files and folders it is better to tell PHP where things are using the file path on the server where the URL is primarily used in php to see how files are being called, what information is being passed etc... even though technically both point to the same location there is a difference in HOW these are happening.

 

URI and URL are two different things, even though at first glance it seems they both are doing the samething it is done differently.

 

I am trying to come up with an analogy that describes the difference but am having a hard time of it. I guess URI could be considered the back street to the files and folders where the foundation of the files are solid in the ground the physical location, where the URL is like the yellow pages in the phone book where you look up an address and then get in your car, the web browser, and go visit the website.

 

When you FTP your files to the webserver you are uploading to the physical hardware of the server itself, the hard drive of the server the URI of your website. The URL is visiting and displaying the files in your web browser. Though they both get you to the same place, URI is strictly meant to be referenced on the hardware itself where the URL accesses through the internet address.

 

I don't think I did a very good job explaining and my analogies are probably wrong but it is best I can do, at least right now.

 

Now as far as the other issues you are having, I have some news that may not be too happy for you. The hosting service you have chosen is notorious for not working correctly with most things one would want to do with more advanced things like php and mysql. I think that particular host is more suited for static html websites than any dynamic sites, especially a website designed with a shopping cart integrated into it.

 

All I can say is that people that have used your particular host that I have personally talked with or read their experiences online, once they moved to a new host things that never worked just magically started working. It has to do with how they have customized and locked down their services, which by nature prevents what I would call "normal" operation of things from working. I can't really comment further on it other than clients I have had that use that service I required them to move their sites somewhere else before I would touch them.

 

That might be a bit harsh or disconcerting but it is really hard to make a lot of things work if at all, with that particular host. You might be able to find a way but I can't really help with that or give suggestion. If you use what is in the book and it should work but it doesn't, and you have checked for typo's and the like and everyone else can get it to work but you can't, the common denominator I have ever seen with things NOT working correctly is that particular hosting service.

 

You may find it useful to use a testing environment on your own computer, which allows you to run apache, php and mysql from within your own computer so you can test and build your website offline while still being able to interact with it as if it were online. This will make sure that it is not your host without having to get a new host and spending money to determine that.

 

My preferred testing environment for windows is:

Vertrigo if you go to http://www.vertrigo.net it will allow you to download and then install it free of charge.

 

Another one many use is XAMP, there are 3 or 4 different testing environment software out there, all free all automatically integrate Apache, MySQL and PHP and most have same or similar versions of each, the most recent stable versions.

 

If you use a MAC, my understanding is there is one built-in but I don't know anything about that as I don't use Mac.

 

If you do happen to have a second webhost you may want to try uploading your site to that host and seeing if your problems just magically have been fixed.

  • Upvote 1
Link to comment
Share on other sites

 Share

×
×
  • Create New...