Expiration date

I wanted to have an expiration date on one webpage which I made with Adobe Muse. I could use PHP or Javascript to achieve this. I can also have the expiration date in mysql as well.

My question is how to setup an expiration date for my webpage, so it does not show after the expiration date. Also, next question is how can I have this hiden, so the user can't check the view source and see the expiration date at all.
Angha110Asked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
GaryConnect With a Mentor Commented:
<?php
if (time() > strtotime("07/01/2014 12:00AM"))
{
	header("HTTP/1.1 404 Not Found");
	header("Location: http://www.mysite.com/404.html"); 
	exit;
}
?>
<!DOCTYPE html>
...
,..

Open in new window


It's PHP so cannot be seen in the browser
0
 
Angha110Author Commented:
I just did a test and it did not work,
Here is what I did,

I opened my myPage.html and add the php part on top of the page. and uploaded it to my server.

Please advice
0
 
Cornelia YoderArtistCommented:
Whatever you do, as long as the date is NOT coded in the HTML, it will not be visible to the user.  Put it in the php directly (as Angha110 shows), or in a database where you retrieve it with php, either would work.
0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

 
GaryCommented:
It won't work in an HTML page, it needs to be a .php page so the php can be processed.
0
 
Dave BaldwinFixer of ProblemsCommented:
You have to name the page "myPage.php" so the PHP interpreter will be run.  You can also something similar in javascript.  Like this.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
 "http://www.w3.org/TR/html4/loose.dtd">

<html>
<head>
<title>Javascript Date check</title>
<script type="text/javascript">
<!--
var today = new Date();
var d1 = new Date("January 4, 2014 11:13:00");
if(today > d1) {
	alert("This is expired.");
}
window.location.assign("http://www.google.com");
// -->
</script>
</head>
<body>
<h1>Javascript Date check</h1>

</body>
</html>

Open in new window

0
 
GaryCommented:
Dave - They don't want the date to be viewable
0
 
Dave BaldwinFixer of ProblemsCommented:
Then load it from an external file.  If it's "expired" and you get rid of the alert, no one will see it when it redirects.  And only developer will think to look in the external file.

Of course, they could just actually delete the file...
0
 
Ray PaseurCommented:
You can use PHP on an HTML page (one with the .html suffix) if you parse the .html files through PHP.  I do this with this line in my .htaccess file

AddType application/x-httpd-php5 .html .htm .php

If you use something like this, you can choose a solution like the one here:
http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/Q_28332787.html#a39763536
0
 
Cornelia YoderArtistCommented:
If you don't care that the user sees a 404 or similar, just use php and this:

<?php
if (time() <= strtotime("07/01/2014 12:00AM"))
{
?>

Put your whole HTML code here

<?
}


That will simply show a white page after the expiration date.
0
 
Cornelia YoderArtistCommented:
Or even this:

<?php
if (time() <= strtotime("07/01/2014 12:00AM"))
{
?>

Put your whole HTML code here

<?
}
else
{
  echo "This page intentionally left blank.";
}
0
 
Ray PaseurCommented:
As I think about this a little bit, it sounds like a "loaded question" with a subtext we may not understand.  Can you please step back from the technical details a little bit and just describe why you want to do this?  Why do you want the pages to expire?  Why do you want to keep the expiration date a secret?  If we understand the business reasons for this, we may be able to offer a more mainstream solution.
0
 
GaryCommented:
@yodercm
Why are you posting multiple solutions which are just a rehash of my initial solution with the only difference being you have changed > to <=
0
 
Cornelia YoderArtistCommented:
The only difference is that in mine, the result after the expiration date is a blank page, or a message, rather than a redirect to an error page.

Please note, Angha, that if you like my idea, be sure to share some of the points with cathal :)
0
 
Angha110Author Commented:
I changed the html to php and it worked fine. (Thank you Cathal).

The reason I want this is to have an expiration date when I make demo pages for my clients. I want it to expire after certain date.

Also it would be nice to prevent them to copy the code from the demo which I believe need another ticket and conversation.

I think the php works fine, but maybe having the expiration in the database be another option.

What would you advice in these case?
0
 
Dave BaldwinFixer of ProblemsCommented:
It is not possible to prevent someone from copying HTML and images from a web page.  Every web browser that they would use to view it allows you to Save the page and images to their computer.
0
 
GaryCommented:
For that scenario you are just adding an unnecessary step by using a database to hold a date for a single page.  It would be easier to just hardcode a set date as and when you create the pages.

There would be nothing stopping them copying the HTML and there is nothing you can do about that
0
 
Angha110Author Commented:
Thank you
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.