#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2013
    Posts
    5
    Rep Power
    0

    Newbie with script problems


    Hi All,

    " Not an idiot, just a novice."

    I'm putting together a web site at which users will pay a small fee to access the good stuff (not porn, think sideshow!)

    Here are the facts and figs...

    Host: JustHost
    Builder: Dreamweaver CS5
    'Open' pages: Three (home, gateway & contact)
    'Paid' pages: eleven and rising
    Home OS: XP SP3
    Button: Paypal Buy Now
    Mail: Outlook (special folder system)

    Here's what works now...

    *Customer clicks through from home to gateway.
    * Pays the entry fee
    * Gets taken to lobby page
    *IPN tells me someone's paid

    Here's what I want to happen...

    * System sends email to tell customer 'thanks' and that he has 24 hour's site access.
    * System takes timestamp and starts the countdown
    * If customer leaves the site, he can get back in during the access time.
    * After 24 hours, system sends email to tell customer that time's up.

    Now, I've been told that this can be done using IPN, a listener, a cookie (possibly API) and PHP. I've quite a bit of HTML experience, as well as several years' Paypal usage.

    But I need to know stuff like...

    Is there an existing code and if so, where?
    My listener's in HTML in my root directory - is that OK?
    Do the outgoing mails live in 'listener?'
    Will it work or is there a simpler way?

    I've already been to other PHP sites and got nowhere (well, patronized a bit), and I've asked a couple of web developers...no response.

    I could therefore use an illustrated walkthrough.

    Upsides...
    Limitless patience, doggedness, determination, time.

    Downside...
    Freakishly tight budget.

    And if you'd like to take a look, the site's open pages are at the other end of a PM. Anybody wanting to check out the paid pages can also ask for the way in!

    Looking forward, etc....
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    165
    Rep Power
    18
    with just html knowledge this is not something that can be done. First you must work with the paypal API to receive and confirm payment. Once you have confirmed that you have confirmed payment then you will store unix time into a mysql table with a unique id and any other customer information such as an email, name, etc.. After this is stored in your database you need to email your client via the php mail() function. you can either give them a login username password or a unique key in a url.

    the landing page or login script will simply check if TIME()<$Registered_time+86400. $Registered_time being any variable holding the time stored in the database. In order to send an email out after the 24 hours you are going to have to have a scheduled event of some kind like a cron job running a script on a set interval. The script will filter by RegisteredTime>TIME+86400 AND ExpirationEmailSent=False then once again use MAIL() to send to each member that has not recieved an end of 24 hour period and is expired. Then after email is sent go ahead and update EmailSent=true

    Comments on this post

    • davhill agrees : a good outlne!
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2013
    Posts
    5
    Rep Power
    0
    Originally Posted by portcitysoftwar
    with just html knowledge this is not something that can be done. First you must work with the paypal API to receive and confirm payment. Once you have confirmed that you have confirmed payment then you will store unix time into a mysql table with a unique id and any other customer information such as an email, name, etc.. After this is stored in your database you need to email your client via the php mail() function. you can either give them a login username password or a unique key in a url.

    the landing page or login script will simply check if TIME()<$Registered_time+86400. $Registered_time being any variable holding the time stored in the database. In order to send an email out after the 24 hours you are going to have to have a scheduled event of some kind like a cron job running a script on a set interval. The script will filter by RegisteredTime>TIME+86400 AND ExpirationEmailSent=False then once again use MAIL() to send to each member that has not recieved an end of 24 hour period and is expired. Then after email is sent go ahead and update EmailSent=true
    Thank you, portcitysoftwar,

    I've spent some time reading up about PHP, API and IPN. This is why I could mention the parts of the system that are working now.

    It looks to me like my plan is about assembling the right code and putting it in the right places, before going sandbox testing. And that's the crux of it...where to find the code and where to place it

    I'm therefore thinking resources...any pointers greatly appreciated!
  6. #4
  7. Confused badger
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Mar 2009
    Location
    West Yorkshire
    Posts
    1,047
    Rep Power
    487
    I am sure the code to do this will exist somewhere but it'll need to be either customised to the nth degree or re-written anyway to work with your configuration, I'm not sure what you mean about where to place it, the files on your website can't generally be accessed unless someone types their names into the browser so you can add a check like "is this a registered/paid visitor" at the top of the page and tell them to get lost if they're not ...

    You could of course, whack them into a sub-folder if that'd help but again, anyone can just type site.com/subfolder/file to read the file.

    portcitysoftwar has certainly given you a great outline of how it should / could be done the API will more than likely have some kind of testing mode where payments aren't actually taken or processed so think about what he said and go for it (there's bound to be code examples along with the API docs)

    Good luck and if I can just add that for support, this forum is excellent; as long as you're willing to show effort then the guys here'll be more than happy to help you out!
    They've saved my skin on a number of occassions!
    "For if leisure and security were enjoyed by all alike, the great mass of human beings who are normally stupefied by poverty would become literate and would learn to think for themselves; and when once they had done this, they would sooner or later realise that the privileged minority had no function and they would sweep it away"
    - George Orwell, 1984
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2013
    Posts
    5
    Rep Power
    0
    Thanks, badger_fruit,

    Great reply, a bit of hope at last

    By placing code, I mean where to put it on my website. I've built a file called 'listener' for Paypal to chat with. I put it in the root folder and told Paypal where it lives.

    But should it be a .php suffix, or should the php be among the code in an html file?

    Paypal has a sandbox facility, and Justhost lets me have an SQL d/base. You can see I'm on the case.

    To coin a phrase, 'I'll be back...'
  10. #6
  11. Confused badger
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Mar 2009
    Location
    West Yorkshire
    Posts
    1,047
    Rep Power
    487
    It should be a .php file so that your webserver knows to parse it as a script.
    If you want to see what happens if you don't then just create helloworld.html and helloworld.php on your server with the contents below:-

    Code:
    <h1>A test</h1>
    <?php echo "Hello world"; ?>
    You should see that when it's a .html file, you get the <?php and everything in between it displayed to screen instead of it actually writing "hello world".

    Try it and see for yourself

    You can place your listener file anywhere within the structure of your website, for example, if you web root folder is

    /var/www/html

    You can save it anywhere in there or create a subfolder etc - just as long as you tell the API where to return the data to, everything will be A ok !

    So for example if your domain is www.example.com and the listener.php is in the web-root, you would point to it with

    www.example.com/listener.php
    "For if leisure and security were enjoyed by all alike, the great mass of human beings who are normally stupefied by poverty would become literate and would learn to think for themselves; and when once they had done this, they would sooner or later realise that the privileged minority had no function and they would sweep it away"
    - George Orwell, 1984
  12. #7
  13. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2013
    Posts
    5
    Rep Power
    0
    Thanks again, badger_fruit,

    I just did the helloworld thing in html and php, copying your code into Dreamweaver and putting it on the server.

    Hooray! Works like a charm, after I'd...

    1: Realised it doesn't work when pasted into design view (Duh!)
    2: Realised that it should be only this code and absolutely nothing else in 'code' view

    So, have one of these

    Whilst about it, I created 'listener.php' on the server, with this code...

    <h1>A test 2</h1>
    <?php echo "It's Alive!!!"; ?>

    ...and that works too!

    If this lets me, I'm inviting you to take a look, at dedint.co.uk.

    To get into what will be the 'paid' bits, please go to dedint.co.uk/lobby

    You may need 3 x 'w'.

    Any nightmares are not my responsibility
  14. #8
  15. Confused badger
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Mar 2009
    Location
    West Yorkshire
    Posts
    1,047
    Rep Power
    487
    Errrr, "bring my soft tissues" ??! lols
    "For if leisure and security were enjoyed by all alike, the great mass of human beings who are normally stupefied by poverty would become literate and would learn to think for themselves; and when once they had done this, they would sooner or later realise that the privileged minority had no function and they would sweep it away"
    - George Orwell, 1984
  16. #9
  17. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2013
    Posts
    5
    Rep Power
    0
    Originally Posted by badger_fruit
    Errrr, "bring my soft tissues" ??! lols
    Got you thinking

IMN logo majestic logo threadwatch logo seochat tools logo