Basic website template, + ways to cut monthly transfer

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

Post Reply
1veedo
Forum Commoner
Posts: 31
Joined: Thu Feb 19, 2004 3:59 pm
Location: With my computer wherever that may be.
Contact:

Basic website template, + ways to cut monthly transfer

Post by 1veedo »

I recently got interested in web developement, I know C++ but not PHP.

I have to wait till the end of this month or ther begining of next to try this (monthly transfer isues.. should of got a biger package) but I thought I'd ask to find out if there were any mistakes, if there's beter way to do this etc.

Code: Select all

<html><head>
<title>Title</title>
</head><body>
<?php
$tem = "1"; //template number, going to use cookies later

$head = file("http://www.1veedo.com/main/head".$tem.".html"); //everything for the top of the page and source to start menus
                                                             //on the left
echo "<aligh = "Top">";
echo $head;

$bigMenu = flie("http://www.1veedo.com/main/bigMenu".$tem.".html"); //begins individule <tr>s for each menu
&endMenu = file("http://www.1veedo.com/main/endmenu".$tem.".html"); //ends individule <tr>s for each menu
&bigContent = file("http://www.1veedo.com/main/bigContent".$tem.".html"); //used to end the left side of the table compleetly

echo "<align = "Left">";
echo $bigMenu;

$menu = file("http://www.1veedo.com/main/menu.html"); //menu content.. individual links

echo $menu;
echo $endMenu;
//echo any sub menus with <br> between

//echo main page content, color dependent on template

$end = file("http://www.1veedo.com/main/end".$tem.".html");

echo $end;
?>
This is going to be my new website [hopefuly]. A basic template. I'm not sure if everything is coded corectly though... :lol: Basicaly, I want the user to choose which color scheem. Another thing: is there a way to say $this = something.php, and tell it to execute the code contained in the variable.. execute($this);? That way I can cut back on my monthly data trasfer! Although, most of it goes with my [not to good] programs and not html files...
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Post by josh »

u mispelt align lol
1veedo
Forum Commoner
Posts: 31
Joined: Thu Feb 19, 2004 3:59 pm
Location: With my computer wherever that may be.
Contact:

Post by 1veedo »

So with that aside it should work?
1veedo
Forum Commoner
Posts: 31
Joined: Thu Feb 19, 2004 3:59 pm
Location: With my computer wherever that may be.
Contact:

Post by 1veedo »

Ok, I tried one file.. tem.php

Code: Select all

<html><head>
<title>Title</title>
</head><body>
<?php
$tem = "1"; //template number

$head = file("http://www.1veedo.com/main/head".$tem.".html"); //everything for the top of the page and source to start menus

echo "<align = "Top">";
echo $head;

$bigMenu = file("http://www.1veedo.com/main/bigmenu".$tem.".html"); //For the header
$endmenHeader = file("http://www.1veedo.com/main/endmenheader".$tem.".html");
$endMenu = file("http://www.1veedo.com/main/endmenu".$tem.".html"); //ends individule <tr>s for each menu
$bigContent = file("http://www.1veedo.com/main/bigcontent".$tem.".html"); //used to end the left side of the table compleetly

echo "<align = "Left">";
echo $bigMenu;
echo "Main Menue";

$menu = file("http://www.1veedo.com/main/menu.html"); //menu content.. individual links

echo $menu;
echo $endMenu;
//echo any sub menus with <br> between

//echo main page content, color dependent on template
//echo key words
$end = file("http://www.1veedo.com/main/end".$tem.".html");

echo $end;
?>
I already got the parts out of a new [better looking] template. Not graphics though, I'm saving data transfer. Anyhow, here's my eror:

Parse error: parse error, expecting `','' or `';'' in /home/x1veedo/public_html/tem.php on line 9

Do you count down from <html> or <?php..?, I'm not sure which line the error is on.. Maby you count from the very top of the file? If you want to see it on my website, it's http://www.1veedo.com/tem.php
d3ad1ysp0rk
Forum Donator
Posts: 1661
Joined: Mon Oct 20, 2003 8:31 pm
Location: Maine, USA

Post by d3ad1ysp0rk »

You need to escape each quote in your HTML output, and please use the [ php] bbcode instead of the [ code] ones. :)

echo "<div align="center">";
becomes
echo "<div align=\"center\">";

and <align> is not a tag

you can use <p>, <div>, <span> or any of the other general tags to align your code.
User avatar
redhair
Forum Contributor
Posts: 300
Joined: Fri May 30, 2003 4:36 pm
Location: 53.23N-6.57E
Contact:

Post by redhair »

LiLpunkSkateR wrote: you can use <p>, <div>, <span> or any of the other general tags to align your code.
Or in case he wants:

Code: Select all

<?php

$align="left";

?>
and then in html,

<TD align="<?php echo $align; ?>">
User avatar
dethron
Forum Contributor
Posts: 370
Joined: Sat Apr 27, 2002 11:39 am
Location: Istanbul

Post by dethron »

Please read,use the PHP-Manual from
http://www.php.net/manual/en/
Since you know c++, it doesn't take so much time.

And also http://www.w3schools.com will be helpfull for you ;)

Good Luck.
1veedo
Forum Commoner
Posts: 31
Joined: Thu Feb 19, 2004 3:59 pm
Location: With my computer wherever that may be.
Contact:

Post by 1veedo »

Thanks alot, I always thought align was one.. o well. I've read some from php.net - the first couple chapters, and looked up special functions. I'll go back and pick of where I left of. Until then my website should function when I fix the above code, I'm geting ready to go camping this weekend though. So I'll fix it next week.

Again. thanks alot!
d3ad1ysp0rk
Forum Donator
Posts: 1661
Joined: Mon Oct 20, 2003 8:31 pm
Location: Maine, USA

Post by d3ad1ysp0rk »

Camping instead of coding?

I.. I don't get it..

why?

;)
1veedo
Forum Commoner
Posts: 31
Joined: Thu Feb 19, 2004 3:59 pm
Location: With my computer wherever that may be.
Contact:

Post by 1veedo »

Lol, I'm in the boy scouts. I plan to get a scholership through them so I stay. Anyhow, back to my template.. :lol:, should I use fopen ("..", q); or something like that (I forgot the actual function to open files)? Go back to the above link, you'l see it's not working like I expected. Well, I'm going to look up that function and try it.

Code: Select all

<html><head>
<title>Title</title>
</head><body>
<?php
$tem = "1"; //template number

$head = file("http://www.1veedo.com/main/head".$tem.".html"); //everything for the top of the page and source to start menus

echo $head;

$bigMenu = file("http://www.1veedo.com/main/bigmenu".$tem.".html"); //For the header
$endmenHeader = file("http://www.1veedo.com/main/endmenheader".$tem.".html");
$endMenu = file("http://www.1veedo.com/main/endmenu".$tem.".html"); //ends individule <tr>s for each menu
$bigContent = file("http://www.1veedo.com/main/bigcontent".$tem.".html"); //used to end the left side of the table compleetly

echo $bigMenu;
echo "Main Menue";

$menu = file("http://www.1veedo.com/main/menu.html"); //menu content.. individual links

echo $menu;
echo $endMenu;
//echo any sub menus with <br> between

//echo main page content, color dependent on template
//echo key words
$end = file("http://www.1veedo.com/main/end".$tem.".html");

echo $end;
?>
I basicaly took out align, I figure the html in the files are going to take care of that.
Edit:
I got it working.. sortof, it was but I added graphics and changed the path to find the graphics in each file.. now it wont load, anyhow here's the updated source:

Code: Select all

<html><head>
<title>Title</title>
</head><body>
<?php
$tem = "1"; //template number

$head = implode('', file('http://www.1veedo.com/main/head'.$tem.'.html'));

echo $head;

$bigMenu = implode('', file('http://www.1veedo.com/main/bigmenu'.$tem.'.html'));
$endmenHeader = implode('', file('http://www.1veedo.com/main/endmenheader'.$tem.'.html'));
$endMenu = implode('', file('http://www.1veedo.com/main/endmenu'.$tem.'.html'));
$bigContent = implode('', file('http://www.1veedo.com/main/bigcontent'.$tem.'.html'));

echo $bigMenu;
echo "Main Menue";

$menu = implode('', file('http://www.1veedo.com/main/menu.html'));

echo $menu;
echo $endMenu;
//echo any sub menus with <br> between
echo $bigContent

//echo main page content, color dependent on template
//echo key words
$end = implode('', file('http://www.1veedo.com/main/end'.$tem.'.html'));

echo $end;
Hm.. server probablems, it cant find anything and I got erors whith ftp.. I disconected and it said something wird then I tried to reconect and it timed out..
Edit2: Seems liek I'm talking to myself..
Thought I'd let you know the above works, I didn't seperate the template good though.. I'm going to look for another one. Thanks for all the help.
1veedo
Forum Commoner
Posts: 31
Joined: Thu Feb 19, 2004 3:59 pm
Location: With my computer wherever that may be.
Contact:

Cookie probablems

Post by 1veedo »

I don't meen to continuously post after myself but I don't see a need to post a new thread. I have probablems with cookies.. I saw a thread about cookies but I didn't wat to take away from the starter's probablem.

Anyhow, I'm trying to change the color scheem by user's choice. It may be my browser but it's not working. I tried this and everytime I refreshed I got the same message - "you need to refresh the page cause the cookie isn't set"

Code: Select all

<?php
if(isset($value)) { 
echo "$value"; 
} else { 
$value = "hi tim"; 
setCookie ("testcookie", $value); 
echo "you need to refresh the page cause the cookie isn't set"; 
} 
?>
Anyhow, I have one php file that takes care of cookies and others that call it when the color scheem is changed. Here's a sample page:

Code: Select all

<html><head> 
<title>Title</title> 
</head><body> 
<?php 
//if (!$_COOKIE['layout']){
   //$tem = "1";}
//else {
   $tem =  isset($value);//}

$head = file("http://www.1veedo.com/main/head".$tem.".html"); //everything for the top of the page and source to start menus 

echo $head; 

$bigMenu = file("http://www.1veedo.com/main/bigmenu".$tem.".html"); //For the header 
$endmenHeader = file("http://www.1veedo.com/main/endmenheader".$tem.".html"); 
$endMenu = file("http://www.1veedo.com/main/endmenu".$tem.".html"); //ends individule <tr>s for each menu 
$bigContent = file("http://www.1veedo.com/main/bigcontent".$tem.".html"); //used to end the left side of the table compleetly 

echo $bigMenu;
echo "<b>Main Menue</b>";

$menu = implode('', file('http://www.1veedo.com/main/menu.html'));

echo $endmenHeader;
echo $menu;
echo $endMenu;

echo "<b>Points of interests</b>";
echo $endmenHeader;
echo '<a href="http://www.eff.org/" target="_blank">EFF</a><br>
            <a href="http://alrecenk.cjb.net/" target="_blank">Alrecenk</a><br>
            <a href="http://www.atomintersoft.com/products/alive-proxy/proxy-list/" target="_blank">Proxie List</a><br>
            <a href="http://alrecenk.cjb.net/" target="_blank"> </a><br><br><br>';
//############   HERE   ##########
echo '<form action="http://www.1veedo.com/switch.php" method="post">
<input type="hidden" value="http://www.1veedo.com/tem.php" name="location">
<select name = "layout" size = "1">
<option value = "2">Dark Green</option>
<option value = "1">Light Blue</option>
</select>
<input type="submit" value="Go"></form>';
			
echo $endMenu;
echo $bigContent;
echo "Blablabla.. main page content..";

$end = file("http://www.1veedo.com/main/end".$tem.".html"); 

echo $end; 
?>
And the file that takes care of cookies:

Code: Select all

<?php
ob_start(); //I thought this would help

setcookie("Pref", $_POST['layout']);
header($_POST['location']); 

ob_end_flush();
//exit;  that should be there - I think

//if(!$_COOKIE['layout']){
  // echo "Cookies not enabled, your preferences won't be saved.";}
//else{
  // echo "Successful";}

echo '<br><br>';
echo '<form action="'; 
echo $_POST['location'];
echo '" method="post"> <input type="submit" value="Continu"></form>';

?>
I tried $_COOKIE[] but when I searched the borads I found isset(). So um, what's wrong? Test page:
Last edited by 1veedo on Sun Feb 22, 2004 4:42 pm, edited 2 times in total.
User avatar
markl999
DevNet Resident
Posts: 1972
Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)

Post by markl999 »

Try :
if(!empty($_COOKIE['testcookie'])){
echo $_COOKIE['testcookie'];
} else {
//set it here
}
1veedo
Forum Commoner
Posts: 31
Joined: Thu Feb 19, 2004 3:59 pm
Location: With my computer wherever that may be.
Contact:

Post by 1veedo »

Great, it works!

Code: Select all

<html><head>
<title>Title</title>
</head><body>
<?php
ob_start();
if (!empty($_COOKIE['layout'])){
   $tem = $_COOKIE['testcookie'];}
else {
   $tem =  "1";}

ob_end_flush();

$head = implode('', file('http://www.1veedo.com/main/head'.$tem.'.html'));

echo $head;

$bigMenu = implode('', file('http://www.1veedo.com/main/bigmenu'.$tem.'.html'));
$endmenHeader = implode('', file('http://www.1veedo.com/main/endmenheader'.$tem.'.html'));
$endMenu = implode('', file('http://www.1veedo.com/main/endmenu'.$tem.'.html'));
$bigContent = implode('', file('http://www.1veedo.com/main/bigcontent'.$tem.'.html'));

echo $bigMenu;
echo "<b>Main Menue</b>";

$menu = implode('', file('http://www.1veedo.com/main/menu.html'));

echo $endmenHeader;
echo $menu;
echo $endMenu;

echo "<b>Points of interests</b>";
echo $endmenHeader;
echo '<a href="http://www.eff.org/" target="_blank">EFF</a><br>
            <a href="http://alrecenk.cjb.net/" target="_blank">Alrecenk</a><br>
            <a href="http://www.atomintersoft.com/products/alive-proxy/proxy-list/" target="_blank">Proxie List</a><br>
            <a href="http://alrecenk.cjb.net/" target="_blank"> </a><br><br><br>';

echo '<form action="http://www.1veedo.com/switch.php" method="post">
<input type="hidden" value="http://www.1veedo.com/tem.php" name="location">
<select name = "layout" size = "1">
<option value = "2">Dark Green</option>
<option value = "1">Light Blue</option>
</select>
<input type="submit" value="Go"></form>';
			
echo $endMenu;
echo $bigContent;

echo '<center>
            <h3><big><big>Main</big></big></h3>
            <small>Last updated 2.22.4<br>
            </small>
            <div style="text-align: left;">
<div style="color: rgb(';
if($tem = "1")
   echo '0, 0, 153)';
elseif($tem = "2")
   echo '0, 153, 0)';
elseif ($tem = "3")
   echo '153, 0, 0)';

echo '; text-align: left;"><small>1.22.4 - <small><small><small><small><small><br><br></small></small></small></small>
</small></small></div>&nbsp;&nbsp;&nbsp; Please IM me with any suggestions, if you find
something not working
properly, if you want to add to links, tutorials, or even
software.&nbsp;';?>
Eventually when I get my server I'm going to have a submit feature but
for now I can't.<br>
&nbsp;&nbsp;&nbsp; It came to my attention that allot of my friends
weren't using allot of great software.&nbsp; So I decided to add a <a href="misc/free-software-download.html">new section</a> to misc.&nbsp;
Everything there is going to be free (at least the basic
version).&nbsp; I'll add things periodically as I run across worthy
software, or I realize when I use something that it should be added.<br>
            <br>
            <br>
            </div><?php
echo '            <small> </small>
            <div style="text-align: left;">
            <div style="color: rgb(';
if($tem = "1")
   echo '0, 0, 153)';
elseif($tem = "2")
   echo '0, 153, 0)';
elseif ($tem = "3")
   echo '153, 0, 0)';

echo ';  text-align: left;"><small>1.20.4
- <small><small><small><small><small><br>
            <br>
            </small></small></small></small></small></small></div>'; ?>
&nbsp;&nbsp;&nbsp; I'm making a clone of
my pong game in <a href="project/dead.html">dead
projects</a> right now with C++.&nbsp; Actually It's almost finished as
far as the engine itself goes, just need to work out some bugs.&nbsp;
The main thing keeping me back right now is text!&nbsp; It used to be
the easiest thing but now, in SDL, there aren't 'simple' ways to do
this.&nbsp; If I ever find more then 75 minuets of free time I'll try a
couple engines and see which one I like best.<br>
&nbsp;&nbsp;&nbsp; I'm half way through my next
tutorial as of now!&nbsp; I think I'm going to have to do if
statements in their own little chapter then do the next on loops.&nbsp;
I'll
cover && || etc. in the if statement's chapter too so I can
truly dedicate the next one to loops and loops only.</div>
            <div style="text-align: left;"><br>
            </div>
            </center>
            <br>
            <br>
            <br>
            <div style="text-align: center;"><big>Thoughts:</big><br>
            <br>
            </div><?php
echo'            <div style="color: rgb(';
if($tem = "1")
   echo '0, 0, 153)';
elseif($tem = "2")
   echo '0, 153, 0)';
elseif ($tem = "3")
   echo '153, 0, 0)';
echo '; text-align: left;"><small>1.19.4
- <small><small><small><small><small><br>
            <br>
            </small></small></small></small></small></small></div>
&nbsp;&nbsp;&nbsp; I finally beat Kingdom Hearts, my sister got it for
Christmas.&nbsp;'; ?>
It's hers but she's pretty nice.&nbsp; That
game was awesome!&nbsp; I didn't think it would be very good until I
was
watching her play it.&nbsp; I can't wait for the sequels to come
out.&nbsp;
Supposedly this year with the GBA one, Chain of Memories, coming out
first.&nbsp; The theme behind traveling to deferent worlds is flawed
though.&nbsp; The whole theory behind going to other stars / planets is
through the 4th dimension.&nbsp; It looked pretty 3d to me!&nbsp; Oh
well, it
would be rather confusing, take a look at <a href="http://www1.tip.nl/%7Et515027/hypercube.html" target="_blank">this
applet</a>.<br>
&nbsp;&nbsp;&nbsp; I'm so glad finals are over!&nbsp; This entire
week-end I only studied corresponding etc. angles.&nbsp; And I only
studied those today for like 10 minuets.&nbsp; Don't get me wrong
though, I've ben very productive.&nbsp; I've been coding like 50% of
the
time, not to mention I wrote that <a href="tutorial/programming.html">tutorial</a>
/ added a section in my tutorials.&nbsp; It's incomplete though, I
think I can make it easier for a n00b to enter the programming world.<br>
            <br>
            <br>
            <br>
            <a href="project.html"><span style="font-weight: bold;">Projects</span></a>-<br>
My software.&nbsp; Main reason for having this site.<br>
            <br>
            <a href="link.html"><span style="font-weight: bold;">Links</span></a>-<br>
Collection of links I like.&nbsp; Most are in my favorites/bookmarks.<br>
            <br>
            <a href="tutorial.html"><span style="font-weight: bold;">Tutorials</span></a>-<br>
Collection of tutorials.&nbsp; Very incomplete!<br>
            <br>
            <a href="misc.html"><span style="font-weight: bold;">Misc</span></a>-<br>
Miscellaneous type stuff...<br><?php


//echo key words
$end = implode('', file('http://www.1veedo.com/main/end'.$tem.'.html'));

echo $end;
?>
I altered my tem.php file so I gave you that one.. I'd alter the simpler one but I'm hungry. Here's the new switch file:

Code: Select all

<?php
setcookie("1VPref", $_POST['layout']);

if(!empty($_COOKIE['1VPref'])){ 
echo $_COOKIE['1VPref'];
} else { 
setcookie("1VPref", $_POST['layout']); 
}
//exit;

//if(!$_COOKIE['layout']){
  // echo "Cookies not enabled, your preferences won't be saved.";}
//else{
  // echo "Successful";}

echo '<br><br>';
echo '<form action="'; 
echo $_POST['location'];
echo '" method="post"> <input type="submit" value="Continu"></form>';

?>
I'll get read of the useless coments / redundent statements later, I aded setcookie at the top so the user can change it after the cookie has ben set. I think it had probablems before becasue google user Pref as a cookie.. o well, now it works. Thanks. And ya.. I know something's wrong in the main website..
Post Reply