Web Analytics Made Easy -
StatCounter Create web page accessible only with keyword and only within a certain time frame? - CodingForum

Announcement

Collapse
No announcement yet.

Create web page accessible only with keyword and only within a certain time frame?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Create web page accessible only with keyword and only within a certain time frame?

    I originally posted this in General Web Building (http://www.codingforum.net/showthread.php?t=237240), but the more I think about it the more I realize this needs to be server side from client input. Then again, I may be totally wrong!

    I want to make an offer available to clients through my web site, but only for a certain time period and only if they enter the key word. The problem I hit was that if this is a simple redirect to another web page, then all they have to do is enter that URL and bypass the "gatekeeper" form to get the discount or special offer.

    But what if the user enters the correct keyword within the time frame, and it simply triggers a php INCLUDE or something like that? The URL doesn't change, does it? It just allows the page to insert the html of the "special offer" page, yes?

    Am I on the right track?

    Ed

  • #2
    Include would allow that if you are on PHP version 5.2+ and have enabled allow_url_include. Otherwise there are many techniques in which you can read remote files into yours including fopen techniques, curl, soapservices if available, sockets and others.
    As long as they do not need to fill out a form on the remote website as rewriting the underlying HTML to redirect to your site would constitute a phishing site.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 
    Been gone for a few months, and haven't programmed in that long of a time. Meh, I'll wing it ;)

    Comment


    • #3
      Ouch! Yah, part of the process would be to introduce a form that would give them the special offer.

      Maybe instead, the code (whatever it is) can generate a "special code number", which automatically copies to the clipboard, and then take them back to my regular form where they can paste it into the form to get their special. Doesn that actually sound more like JavaScript than php?

      Sheesh! Here I thought this was going to be a simple "all you do is this"!!
      Ed

      Comment


      • #4
        Originally posted by EdNerd View Post
        Ouch! Yah, part of the process would be to introduce a form that would give them the special offer.

        Maybe instead, the code (whatever it is) can generate a "special code number", which automatically copies to the clipboard, and then take them back to my regular form where they can paste it into the form to get their special. Doesn that actually sound more like JavaScript than php?

        Sheesh! Here I thought this was going to be a simple "all you do is this"!!
        Ed
        PHP isn't capable of interacting with a client, so a copy to clipboard would be javascript. Why not contact the companies in question and see if there is a way to uniquely identify your site referring them to each special? That would be easier. That's how places like paypal work, you provide them with a return to page, and all the processing is done at their site and when complete they send them back to your site and issue you a reply as well.
        PHP Code:
        header('HTTP/1.1 420 Enhance Your Calm'); 
        Been gone for a few months, and haven't programmed in that long of a time. Meh, I'll wing it ;)

        Comment


        • #5
          Why not contact the companies in question and see if there is a way to uniquely identify your site referring them to each special? That would be easier.
          I don't understand what you mean??
          Like creating a different PayPal offer button for each special?

          Ed

          Comment


          • #6
            Originally posted by EdNerd View Post
            I don't understand what you mean??
            Like creating a different PayPal offer button for each special?

            Ed
            No I mean that the company itself keeps record of whom you are based on a unique identifier, and uses this to track back any referrals you provide them with. You don't need different buttons or anything like that, it simply comes down to what data is being passed back and forth. Its easier if you are an affiliate and they provide you with a unique code to send your referrals through, preferably one that changes with each set of specials to prevent direct linking.
            PHP Code:
            header('HTTP/1.1 420 Enhance Your Calm'); 
            Been gone for a few months, and haven't programmed in that long of a time. Meh, I'll wing it ;)

            Comment


            • #7
              Oh, I see the communication problem - I'm not a vendor selling a product through my site; I'm a service provider. *I* am the product. There is no other company; it's all me.

              I do use a forms service (because I haven't learned how to do my own forms yet!) and I do have a PayPal button. But other than that, this is all contained within my own site.

              Ed

              Comment


              • #8
                Then I'm confused as to why you need to read an external file. You cannot do this with something like paypal, you would need to use their api in order to pass them the data that they expect. Find information about this on developer.paypal.com. They will also provide you with a sandbox to play in.
                You cannot use a forms service either. You will need to take care of these on your own. I don't recommend novice programmers do anything with ecommerce related websites; you will need to learn the fundamentals of PHP and how it is used with HTML prior to learning the ecommerce side.
                PHP Code:
                header('HTTP/1.1 420 Enhance Your Calm'); 
                Been gone for a few months, and haven't programmed in that long of a time. Meh, I'll wing it ;)

                Comment


                • #9
                  I think we're not on the same page. I'll send you a PM.

                  Comment


                  • #10
                    Originally posted by EdNerd View Post
                    I think we're not on the same page. I'll send you a PM.
                    No, you can describe what it is you are doing here.
                    PHP Code:
                    header('HTTP/1.1 420 Enhance Your Calm'); 
                    Been gone for a few months, and haven't programmed in that long of a time. Meh, I'll wing it ;)

                    Comment


                    • #11
                      Sorry - didn't mean to overstep. I totally appreciate the time you're taking.

                      I'm a magician, specializing in children's and family shows. I'd like to offer a special deal to those attending a show: "just for you, for the next 24 hours (or whatever), you can use this link (or code or however) to book a show and get a discount/upgrade/etc." There's no product, no ecommerce, not hardly even much of a web site (FamilyFunMagic.com). A form (via an online service) and a PayPal button.

                      I jsut want to somehow prevent the link or code from getting texted/emailed/otherwise saved for others to use months later. All I can see is to create a special page just for that event and then take it down. If I use a code or a link to a "special offer" page that's always available, then all that's necessary to avaoid full price is use that URL and pull up that page any time.

                      Unless there's a way to use the validation code or link to allow a page to import a "special offer" page with a special price button in a way that won't change the URL (which is why I thought of php and INCLUDE).

                      Again, thanks for your assist.

                      Comment


                      • #12
                        That's fine; you should always post on the forums so that others can contribute.

                        For this I would create a session and determine. It can be done very easily:
                        PHP Code:
                        <?php
                        session_start
                        ();

                        // I'll use a function
                        // This is where you determine if they *should* be allowed a discount.  Can be random if you want.
                        // Could be based on the time of the day, or whatever you want.
                        // All that matters is that $a['discountUntil'] is set IF they are to be discounted.
                        // You can add any fields as you see fit.
                        function isDiscounted(array &$a)
                        {
                            
                        $a['discountUntil'] = strtotime('+1 hour');
                        }

                        isDiscounted($_SESSION);
                        Then when you process the page, you can even show it then:
                        PHP Code:
                        <?php
                        session_start
                        ();
                        if (isset(
                        $_SESSION['discountUntil']) && $_SESSION['discountUntil'] >= time())
                        {
                            
                        printf('Book now and receive a discount!  Offer expires at %s'date('H:i:s'$_SESSION['discountUntil']));
                        }

                        // Then when processing, you simply check if the discount is valid.
                        // This would be when you issue a 'claim' for it, so filing out a form and sent here.
                        // You can deal with all other information as you see fit, this just indicates if you are discounted.
                        $isDiscounted = isset($_SESSION['discountUntil']) ? $_SESSION['discountUntil'] > time() : false;

                        // Discount has been claimed.  Destroy it so that a sessionid cannot
                        // be passed and reused.
                        unset($_SESSION['discountUntil']);
                        $isDiscounted will now contain a boolean to indicate if the session is eligible for a discount.

                        I was mistaken in what you were doing with Include, I somehow assumed you were going external.
                        PHP Code:
                        header('HTTP/1.1 420 Enhance Your Calm'); 
                        Been gone for a few months, and haven't programmed in that long of a time. Meh, I'll wing it ;)

                        Comment


                        • #13
                          Wow!! Thanks so very much!!

                          I put all your code into a web page (adding two ?>) and loaded it to my site. When I opened it, i came up with two errors:

                          Warning: session_start() [function.session-start]: Cannot send session cookie
                          Warning: session_start() [function.session-start]: Cannot send session cache limiter

                          (www.familyfunmagic.com/discount.php)

                          Also, I was thinking I could have a text file set up like:
                          KEYWORD, DATE
                          Read that into an array, parsed by the comma.

                          If they enter the correct keyword for that event, and the date is not later than NOW(), then the discount applies.

                          Then the DATE from my array would become the 'discountUntil' variable?
                          Or is that a bad idea?

                          Ed

                          Comment


                          • #14
                            Nope, just make sure that the text file is in a location above the directory root so that a user cannot directly access it.

                            If you have access to a database, it would be easier as you can then simply query for the provided key or the date for which it expires.

                            The error you have is because session_start is placed in the document after it has returned the headers. This includes any prints, html or whitespace prior to <?php. session_start should be among the very first instructions you provide if you intend to use them.
                            PHP Code:
                            header('HTTP/1.1 420 Enhance Your Calm'); 
                            Been gone for a few months, and haven't programmed in that long of a time. Meh, I'll wing it ;)

                            Comment


                            • #15
                              Okay - got the SESSION errors sorted out.
                              I'll work on the array and the rest and post back for more help.

                              Thank you for sticking with me on this!
                              Ed

                              Comment

                              Working...
                              X
                              😀
                              🥰
                              🤢
                              😎
                              😡
                              👍
                              👎