473,320 Members | 1,612 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

PHP w/cookies to load Flash video????

18
Hi,

I don't know PHP but it seems like the way to do this:

I need a home page that loads a flash video into the HTML page and auto-plays for 1st time visitors. Repeat visitors (within 15 days) will have to click on the video to play it.

I think a PHP script can be used to set or add to a cookie with a count and then check to see the count. If the count is 1 it calls for the auto-play video to be loaded. If the count is 2 or greater, it calls for the click to play video.

I can make the 2 videos but I have no idea how to write the PHP.

So, is this the way to do this or is there a better way?

Can anyone help me put this script together?

Thanks guys!
Aug 14 '07 #1
12 2045
jx2
228 100+
well
its simple
my idea is:
[php]
<?php
//setup *************************************
$videoHTML = "yourVideoPage.html";
$withoutVideo = "yourNotVideoPage.html";
$expire = 604800; //equvalent of 1 week
// end of setup *********************************

if( ! $visited){
setcookie("visited",1,time()+$expire);
include($videoHTML);
}else {
include($withoutVideoHTML);
}
[/php]

save it as yourfilename.php

well that is it :-)

i didnt test it but it should work fine if you have any question post again

regards
jx2
Aug 14 '07 #2
kovik
1,044 Expert 1GB
[php]if( ! $visited)[/php]
This line implies that you are using register_globals. Bad jx2, bad! The correct way to do this is:

[php]if (!$_COOKIE['visited'])[/php]
Aug 14 '07 #3
smarsh
18
Thanks for the script work guys!

One thing though: the video is planned to go on the index.html page. I was hoping to keep visitors there by checking the cookie via PHP, then loading one or the other flash video into the index.html page. Is that possible? Is it too slow? If not, does the index page become a simple redirect to one or the other video pages? If it redirects, I'm concerned with search engines thinking something illegal is going on...

Thanks again!
Aug 14 '07 #4
jx2
228 100+
This line implies that you are using register_globals. Bad jx2, bad! The correct way to do this is:

[php]if (!$_COOKIE['visited'])[/php]
LOL i know I know bad bad lazy me :-)

lol

regards
jx2
Aug 14 '07 #5
jx2
228 100+
Thanks for the script work guys!

One thing though: the video is planned to go on the index.html page. I was hoping to keep visitors there by checking the cookie via PHP, then loading one or the other flash video into the index.html page. Is that possible? Is it too slow? If not, does the index page become a simple redirect to one or the other video pages? If it redirects, I'm concerned with search engines thinking something illegal is going on...

Thanks again!
well if you save the script i wrote for you into index.php
you will not have to do anything more it will work fine
it will not redirect !!! it "change" the contents of index.php
so the adress of your page will be always the same e.g.
www.yourdomain.com/index.php regardless if its displays video or not

regards
jx2
Aug 14 '07 #6
smarsh
18
OK. I think I learned something - let me run this by you...

No index.html instead index.php. index.php is just the script with no HTML anything. The script calls one or the other html web page named in the script. In my case the pages are equivalent except for the video I put in each. All links on the site to "home" are linked to index.php

In this way the script sets a new cookie or reads an existing cookie and then calls the content to take the place of the script. After the browser is done loading, someone viewing the "home page" source would only see the content from the called html page and never the script.

Do I get it?

Also, if I want the "videoHTML" page to be allowed say 3 times (instead of 1) before switching to "withoutVideo" what would I have to change in the script?


For my education: PHP can be written for other applications to be embedded in HTML like javascript right?
Aug 14 '07 #7
jx2
228 100+
OK. I think I learned something - let me run this by you...

No index.html instead index.php. index.php is just the script with no HTML anything. The script calls one or the other html web page named in the script. In my case the pages are equivalent except for the video I put in each. All links on the site to "home" are linked to index.php

In this way the script sets a new cookie or reads an existing cookie and then calls the content to take the place of the script. After the browser is done loading, someone viewing the "home page" source would only see the content from the called html page and never the script.

Do I get it?

Also, if I want the "videoHTML" page to be allowed say 3 times (instead of 1) before switching to "withoutVideo" what would I have to change in the script?


For my education: PHP can be written for other applications to be embedded in HTML like javascript right?
yeah you ve got it :-)
php can be enbedded into html or html can by enbeddet into php :-) i know sounds strange

index.php e.g. [html]
<html>
<body>
<?php
if( ! $visited) echo"play video - your html";
else echo "dont play video- your html";
?>
</body>
</html>
[/html]or in php
[php]
<?php
echo "<html><body>";

if( ! $visited) echo"play video - your html";
else echo "dont play video- your html";

echo "</body></html>";

?>[/php]

all depends what is more comfortable for you

regards
jx2
Aug 14 '07 #8
smarsh
18
Thanks very very much jx2!!!

I learned a lot from this little exercise...

I'm sticking with the no html .php approach for this one. When I learn more about PHP I'll try some simple embedded scripts.

The last issue with this script is still:

If I want the "videoHTML" page to be allowed say 3 times (instead of 1) before switching to "withoutVideo" what would I have to change in the script?
Aug 14 '07 #9
jx2
228 100+
[i][b]
If I want the "videoHTML" page to be allowed say 3 times (instead of 1) before switching to "withoutVideo" what would I have to change in the script?
lol :-) you really want me to write it for you:-)
okey
lok at that: [php]
<?php
//setup *************************************
$videoHTML = "yourVideoPage.html";
$withoutVideo = "yourNotVideoPage.html";
$expire = 604800; //equvalent of 1 week
// end of setup *********************************
setcookie("visited", $visited++ ,time()+$expire);
if( $visited<3 ){
include($videoHTML);
}else {
include($withoutVideoHTML);
}[/php]

it should work

regards
jx2
Aug 14 '07 #10
smarsh
18
lol :-) you really want me to write it for you:-)
I know... I'm still a novice - in over his head... but I'm trying. I just don't know enough yet...

No matter what I do I can't get the revised version to go past the videoHTML page. I visited way over 3 times but it won't go. Is there a syntax issue or something I just don't see?

Thanks.
Aug 14 '07 #11
jx2
228 100+
[php]<?php
//setup *************************************

$page1 = '<html>page1 ----------- insert your html here---------</html>';

$page2 = '<html>page2 ----------- insert your html here---------</html>';

$expire = 604800; //equvalent of 1 week
$howMany = 3;

//$visited = 0; // uncomment it if you want to reset counter

// end of setup *********************************


$visited++ ;

setcookie("visited", $visited ,time()+$expire);
if( $visited <= $howMany ){
echo $page1;
}else {
echo $page2;
}[/php]

make it simplier is imposible :-)

i hope that helps

regards
jx2
Aug 15 '07 #12
smarsh
18
THANKS jx2!!!

That really helps. And... I really learned something. I made a couple of changes to that last script so that it calls the pages instead of the inserted html. I know that's not much expertise, but it's more than I could do a few days back!

I look forward to learning PHP and maybe one day I can give some help to someone here.
Aug 16 '07 #13

Sign in to post your reply or Sign up for a free account.

Similar topics

115
by: post2google | last post by:
I was thinking about where to go for lunch the other day, so I went to hardees.com to see what the menu looked like these days. What comes up is a big note that my flash version is not new enough...
12
by: Sandman | last post by:
There are some Mac tools to convert pretty much any given video source to a Flash video file (.flv) but I'm wondering if there is any way to do it using a Linux platform tying in to a PHP web...
13
iam_clint
by: iam_clint | last post by:
Starting a thread for flash tutorials and such.. got a good link? pm me. http://www.kirupa.com http://www.actionscript.org/resourc...ries/Tutorials/ http://www.gotoandlearn.com ...
8
by: Neo Geshel | last post by:
Greetings. BACKGROUND: My sites are pure XHTML 1.1 with CSS 2.1 for markup. My pages are delivered as application/xhtml+xml for all non-MS web clients, and as text/xml for all MS web...
3
by: ReGenesis0 | last post by:
Okay, so I want to do this THANG, which involves some fairly ugly screenscraping since it's a mashup with another site that doesn't have friendly, mashable, controls. Problem- I need to log into...
2
by: lionbarrage | last post by:
Hi all, I was just wondering if anyone knows how to grab an image from a flv or a swf when a user uploads a file? Any help would be appreciated!
2
dream party
by: dream party | last post by:
Inserting a Flash (SWF, FLV) file into HTML web page is already an old and familiar thing to all of us. It is a rather non-flexible thing that just to edit some options in the template. However, I...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.