Solved

Expiration date

Posted on 2014-01-07
17
331 Views
Last Modified: 2014-01-07
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.
0
Comment
Question by:Angha110
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
  • 3
  • +2
17 Comments
 
LVL 58

Accepted Solution

by:
Gary earned 500 total points
ID: 39763536
<?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
 

Author Comment

by:Angha110
ID: 39763558
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
 
LVL 27

Expert Comment

by:Cornelia Yoder
ID: 39763583
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
Get Database Help Now w/ Support & Database Audit

Keeping your database environment tuned, optimized and high-performance is key to achieving business goals. If your database goes down, so does your business. Percona experts have a long history of helping enterprises ensure their databases are running smoothly.

 
LVL 58

Expert Comment

by:Gary
ID: 39763590
It won't work in an HTML page, it needs to be a .php page so the php can be processed.
0
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 39763593
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
 
LVL 58

Expert Comment

by:Gary
ID: 39763604
Dave - They don't want the date to be viewable
0
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 39763615
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
 
LVL 110

Expert Comment

by:Ray Paseur
ID: 39763690
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
 
LVL 27

Expert Comment

by:Cornelia Yoder
ID: 39763721
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
 
LVL 27

Expert Comment

by:Cornelia Yoder
ID: 39763729
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
 
LVL 110

Expert Comment

by:Ray Paseur
ID: 39763732
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
 
LVL 58

Expert Comment

by:Gary
ID: 39763739
@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
 
LVL 27

Expert Comment

by:Cornelia Yoder
ID: 39763877
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
 

Author Comment

by:Angha110
ID: 39763973
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
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 39763978
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
 
LVL 58

Expert Comment

by:Gary
ID: 39763981
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
 

Author Closing Comment

by:Angha110
ID: 39763988
Thank you
0

Featured Post

Get Database Help Now w/ Support & Database Audit

Keeping your database environment tuned, optimized and high-performance is key to achieving business goals. If your database goes down, so does your business. Percona experts have a long history of helping enterprises ensure their databases are running smoothly.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

751 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question