PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
nickman013
Forum Regular
Posts: 764 Joined: Sun Aug 14, 2005 12:02 am
Location: Long Island, New York
Post
by nickman013 » Mon Jan 09, 2006 2:12 pm
I am trying to make a script that if someone goes to the url...
http://www.example.com/play.php?page=video1
it will echo that script.
this is what ive got so far...
Code: Select all
<?
if ($page=="gotti1")
{
echo "<html>
<title>The Gotti Adventure</title>
<center>
<BODY BGCOLOR=#808080>
<TABLE BORDER=0 bgcolor=#000000><td bgcolor=#B22222>
<center><font color=white size=5>
The Gotti Adventure
</font><br>
<font color=white size=2>
Stealing Johns Glove
</font>
</td></table>
<p>
<TABLE BORDER="0" bgcolor=#000000><td bgcolor=#B22222>
<font color=white><b>CHECK OUT THE <a href=http://www.regionalplanning.com/nvideos/GottiVideoMain2.php3?gottisn=<? echo $gottisn; ?>>GOTTI VIDEO 2!!</a></b></font>
</td></table><p>
<p>
<TABLE BORDER="0" bgcolor=#000000><td bgcolor=#B22222>
<embed src=GottiAdventure.mp4 width=358 height=320 controller=true autoplay=true loop=false></embed></table>
</font></td>
</table>
</body>
</center>
</html>";
}
if ($page=="gotti2")
{
echo "
<center>
<BODY BGCOLOR=#808080>
<TABLE BORDER=0 bgcolor=#000000><td bgcolor=#B22222>
<center><font color=white size=5>
The Gotti Adventure
</font><br>
<font color=white size=2>
Monkey
</font>
</td></table>
<p>
<TABLE BORDER=0 bgcolor=#000000><td bgcolor=#B22222>
<embed src=GottiAdventure2_mov.mov width=490 height=380 controller=true autoplay=true loop=false></embed></table>
<p>
<TABLE BORDER=0 bgcolor=#000000><td bgcolor=#B22222>
<center><font color=white size=2>
<img src=wm.gif>Windows Media Player users click <a href=GottiAdventure2_mov.wmv>here</a>.
</font>
</td></table>
<p>";
}
?>
i am using php 4 (finally upgraded =] )
also if there is no page in the url i want it to be a regular page... so i guess that would be else.
Last edited by
nickman013 on Mon Jan 09, 2006 2:29 pm, edited 1 time in total.
hawleyjr
BeerMod
Posts: 2170 Joined: Tue Jan 13, 2004 4:58 pm
Location: Jax FL & Spokane WA USA
Post
by hawleyjr » Mon Jan 09, 2006 2:19 pm
Break up your PHP and HTML
Code: Select all
<?php
if ($page=="gotti1")
{
?>
<html>
<title>The Gotti Adventure</title>
<center>
<BODY BGCOLOR=#808080>
<TABLE BORDER=0 bgcolor=#000000><td bgcolor=#B22222>
<center><font color=white size=5>
The Gotti Adventure
</font><br>
<font color=white size=2>
Stealing Johns Glove
</font>
</td></table>
<p>
<TABLE BORDER="0" bgcolor=#000000><td bgcolor=#B22222>
<font color=white><b>CHECK OUT THE <a href=http://www.regionalplanning.com/nvideos/GottiVideoMain2.php3?gottisn=<? echo $gottisn; ?>>GOTTI VIDEO 2!!</a></b></font>
</td></table><p>
<p>
<TABLE BORDER="0" bgcolor=#000000><td bgcolor=#B22222>
<embed src=GottiAdventure.mp4 width=358 height=320 controller=true autoplay=true loop=false></embed></table>
</font></td>
</table>
</body>
</center>
</html>
<?php
}
if ($page=="gotti2")
{
?>
<center>
<BODY BGCOLOR=#808080>
<TABLE BORDER=0 bgcolor=#000000><td bgcolor=#B22222>
<center><font color=white size=5>
The Gotti Adventure
</font><br>
<font color=white size=2>
Monkey
</font>
</td></table>
<p>
<TABLE BORDER=0 bgcolor=#000000><td bgcolor=#B22222>
<embed src=GottiAdventure2_mov.mov width=490 height=380 controller=true autoplay=true loop=false></embed></table>
<p>
<TABLE BORDER=0 bgcolor=#000000><td bgcolor=#B22222>
<center><font color=white size=2>
<img src=wm.gif>Windows Media Player users click <a href=GottiAdventure2_mov.wmv>here</a>.
</font>
</td></table>
<p>
<?php
}
?>
matthijs
DevNet Master
Posts: 3360 Joined: Thu Oct 06, 2005 3:57 pm
Post
by matthijs » Mon Jan 09, 2006 2:22 pm
I think this article at digital web explains exactly what you want:
http://www.digital-web.com/articles/easypeasy_php_2/
It goes like this:
Code: Select all
// Include our header:
include($_SERVER['DOCUMENT_ROOT'] . '/inc/header.php');
// Define our array of allowed $_GET values
$pass = array('intro','bluetruck','redhouse','brownbear');
// If the page is allowed, include it:
if (in_array($_GET['id'], $pass)) {
include ($_SERVER['DOCUMENT_ROOT'] . '/inc/' . $_GET['id'] . '.php');
}
// If there is no $_GET['id'] defined, then serve the homepage:
elseif (!isset($_GET['id'])) {
include ($_SERVER['DOCUMENT_ROOT'] . '/inc/intro.php');
}
But check out the article and downloadable files to see the details.
nickman013
Forum Regular
Posts: 764 Joined: Sun Aug 14, 2005 12:02 am
Location: Long Island, New York
Post
by nickman013 » Mon Jan 09, 2006 2:29 pm
hawleyjr wrote: Break up your PHP and HTML
Code: Select all
<?php
if ($page=="gotti1")
{
?>
<html>
<title>The Gotti Adventure</title>
<center>
<BODY BGCOLOR=#808080>
<TABLE BORDER=0 bgcolor=#000000><td bgcolor=#B22222>
<center><font color=white size=5>
The Gotti Adventure
</font><br>
<font color=white size=2>
Stealing Johns Glove
</font>
</td></table>
<p>
<TABLE BORDER="0" bgcolor=#000000><td bgcolor=#B22222>
<font color=white><b>CHECK OUT THE <a href=http://www.regionalplanning.com/nvideos/GottiVideoMain2.php3?gottisn=<? echo $gottisn; ?>>GOTTI VIDEO 2!!</a></b></font>
</td></table><p>
<p>
<TABLE BORDER="0" bgcolor=#000000><td bgcolor=#B22222>
<embed src=GottiAdventure.mp4 width=358 height=320 controller=true autoplay=true loop=false></embed></table>
</font></td>
</table>
</body>
</center>
</html>
<?php
}
if ($page=="gotti2")
{
?>
<center>
<BODY BGCOLOR=#808080>
<TABLE BORDER=0 bgcolor=#000000><td bgcolor=#B22222>
<center><font color=white size=5>
The Gotti Adventure
</font><br>
<font color=white size=2>
Monkey
</font>
</td></table>
<p>
<TABLE BORDER=0 bgcolor=#000000><td bgcolor=#B22222>
<embed src=GottiAdventure2_mov.mov width=490 height=380 controller=true autoplay=true loop=false></embed></table>
<p>
<TABLE BORDER=0 bgcolor=#000000><td bgcolor=#B22222>
<center><font color=white size=2>
<img src=wm.gif>Windows Media Player users click <a href=GottiAdventure2_mov.wmv>here</a>.
</font>
</td></table>
<p>
<?php
}
?>
thank you both, i tried the script above and it worked just how i wanted it, thanks alot both of you!
nickman013
Forum Regular
Posts: 764 Joined: Sun Aug 14, 2005 12:02 am
Location: Long Island, New York
Post
by nickman013 » Mon Jan 09, 2006 2:36 pm
actually i have one more thing
if there is no page inputted i want a different html code to be activated
my script so far is
Code: Select all
<html><title>Video Page</title>
<?php
if ($page=="gotti1")
{
?>
<html>
<title>The Gotti Adventure</title>
<center>
<BODY BGCOLOR=#808080>
<TABLE BORDER=0 bgcolor=#000000><td bgcolor=#B22222>
<center><font color=white size=5>
The Gotti Adventure
</font><br>
<font color=white size=2>
Stealing Johns Glove
</font>
</td></table>
<p>
<TABLE BORDER="0" bgcolor=#000000><td bgcolor=#B22222>
<font color=white><b>CHECK OUT THE <a href=http://www.regionalplanning.com/nvideos/GottiVideoMain2.php3?gottisn=<? echo $gottisn; ?>>GOTTI VIDEO 2!!</a></b></font>
</td></table><p>
<p>
<TABLE BORDER="0" bgcolor=#000000><td bgcolor=#B22222>
<embed src=GottiAdventure.mp4 width=358 height=320 controller=true autoplay=true loop=false></embed></table>
</font></td>
</table>
</body>
</center>
</html>
<?php
}
if ($page=="gotti2")
{
?>
<center>
<BODY BGCOLOR=#808080>
<TABLE BORDER=0 bgcolor=#000000><td bgcolor=#B22222>
<center><font color=white size=5>
The Gotti Adventure
</font><br>
<font color=white size=2>
Monkey
</font>
</td></table>
<p>
<TABLE BORDER=0 bgcolor=#000000><td bgcolor=#B22222>
<embed src=GottiAdventure2_mov.mov width=490 height=380 controller=true autoplay=true loop=false></embed></table>
<p>
<TABLE BORDER=0 bgcolor=#000000><td bgcolor=#B22222>
<center><font color=white size=2>
<img src=wm.gif>Windows Media Player users click <a href=GottiAdventure2_mov.wmv>here</a>.
</font>
</td></table>
<p>
<?php
}
else {
echo "video page main html";
}
it works but when a page is inputted the other page html is on the bottom of it...
hawleyjr
BeerMod
Posts: 2170 Joined: Tue Jan 13, 2004 4:58 pm
Location: Jax FL & Spokane WA USA
Post
by hawleyjr » Mon Jan 09, 2006 2:44 pm
You need to combine All of your if statements into and if else statement.
nickman013
Forum Regular
Posts: 764 Joined: Sun Aug 14, 2005 12:02 am
Location: Long Island, New York
Post
by nickman013 » Mon Jan 09, 2006 6:40 pm
how do i do that? is there a link or somthing you can show me..
thanks!
hawleyjr
BeerMod
Posts: 2170 Joined: Tue Jan 13, 2004 4:58 pm
Location: Jax FL & Spokane WA USA
Post
by hawleyjr » Mon Jan 09, 2006 6:43 pm
You have two seperate if statements
and
Add an else statement before the second if.
Code: Select all
<?php
}elseif ($page=="gotti2")
{
?>
nickman013
Forum Regular
Posts: 764 Joined: Sun Aug 14, 2005 12:02 am
Location: Long Island, New York
Post
by nickman013 » Mon Jan 09, 2006 8:31 pm
thanks so much it works perfect!!!