How do i use php

remnightfall

New Member
Messages
20
Reaction score
0
Points
0
Okay sory if this has already been answered or if its in the wrong section, the search button isn't working.


Okay my problem is i want to be able to edit every single page at once. And i googled it, and it said there was a thing called PHP, and i tried it on x10hosting and it either doesn't work for me or im not doing it wrong.


This is my website and if you look in the top left corner it will say *Recent forum posts * and i realized i would have to go to every single page to change that, so if someone knows how to use PHP please explain to me, cause im really really confused.

http://bluehedgehog.pcriot.com/index.php (under construction nothing works right now)
 
Last edited:

techairlines

x10 Flyer
Community Support
Messages
2,867
Reaction score
165
Points
63
You can try using PHP includes for that function.

Create a file with the information/code you want to include there and name the file recent.php. On the main pages, replace the recent posts code with:

Code:
<?php include("recent.php"); ?>

Name all your website pages .php rather than .html. Upload all the files to the same directory.

Example:

On your main index page, have the following code:
Code:
<html>
<body>
<?php include ("recent.php")?>
<p>Welcome!</p>
</body>
</html>

On your recent.php file, have the following code:
Code:
<div id="recentrecord"><img width="229" height="70" src="recentforumposts2.png" title="" alt="">
<ul>
<li>test</li>
<li>this is just a test</li>
<li>test</li>
<li>mhmm still a test<br>
</li>
<li>testomg</li></ul>
<div class="clearthis">&nbsp;</div></div>

When others view your website, they will load the following source code:
Code:
<html>
<body>
<div id="recentrecord"><img width="229" height="70" src="recentforumposts2.png" title="" alt="">
<ul>
<li>test</li>
<li>this is just a test</li>
<li>test</li>
<li>mhmm still a test<br>
</li>
<li>testomg</li></ul>
<div class="clearthis">&nbsp;</div></div>
<p>Welcome!</p>
</body>
</html>

A full detailed tutorial on PHP Includes can be found at: http://www.w3schools.com/PHP/php_includes.asp
 
Last edited:

Livewire

Abuse Compliance Officer
Staff member
Messages
18,169
Reaction score
216
Points
63
PHP is functioning on the x10 servers so you'll want to try a tutorial, but there's at least one big key point I should make here.

PHP doesn't work if the page extension is .html (such as index.html) - it has to be index.php or the server will not attempt to parse the php code correctly. That might've been causing your problems where it wasn't working :)


EDIT: Oh, and you have to code the file it's including; when you include recent.php, you have to have a recent.php there for it to include.
 
Last edited:

remnightfall

New Member
Messages
20
Reaction score
0
Points
0
you can try using php includes for that function.

Create a file with the information/code you want to include there and name the file recent.php. On the main pages, replace the recent posts code with:

Code:
<?php include("recent.php"); ?>
name all your website pages .php rather than .html. Upload all the files to the same directory.

example:

on your main index page, have the following code:
Code:
<html>
<body>
<?php include ("recent.php")?>
<p>welcome!</p>
</body>
</html>
on your recent.php file, have the following code:
Code:
<div id="recentrecord"><img width="229" height="70" src="recentforumposts2.png" title="" alt="">
<ul>
<li>test</li>
<li>this is just a test</li>
<li>test</li>
<li>mhmm still a test<br>
</li>
<li>testomg</li></ul>
<div class="clearthis">&nbsp;</div></div>
when others view your website, they will load the following source code:
Code:
<html>
<body>
<div id="recentrecord"><img width="229" height="70" src="recentforumposts2.png" title="" alt="">
<ul>
<li>test</li>
<li>this is just a test</li>
<li>test</li>
<li>mhmm still a test<br>
</li>
<li>testomg</li></ul>
<div class="clearthis">&nbsp;</div></div>
<p>welcome!</p>
</body>
</html>
a full detailed tutorial on php includes can be found at: http://www.w3schools.com/php/php_includes.asp





thank you!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! so mucchhhhhh:biggrin::biggrin::biggrin::biggrin::biggrin::biggrin::biggrin::biggrin::biggrin::biggrin:
 

remnightfall

New Member
Messages
20
Reaction score
0
Points
0
PHP is functioning on the x10 servers so you'll want to try a tutorial, but there's at least one big key point I should make here.

PHP doesn't work if the page extension is .html (such as index.html) - it has to be index.php or the server will not attempt to parse the php code correctly. That might've been causing your problems where it wasn't working :)


EDIT: Oh, and you have to code the file it's including; when you include recent.php, you have to have a recent.php there for it to include.
Okay i did that :biggrin:
 

remnightfall

New Member
Messages
20
Reaction score
0
Points
0
Ohkay I did everything i was suppose to do...Now all i see is test tes tes test and "Welcome" and recent forum post banner? is this suppose to happen
 

techairlines

x10 Flyer
Community Support
Messages
2,867
Reaction score
165
Points
63
thank you!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! so mucchhhhhh

You're welcome. Glad I could help.

Ohkay I did everything i was suppose to do...Now all i see is test tes tes test and "Welcome" and recent forum post banner? is this suppose to happen

My code snippet I posted above was just for the Recent Post area. Remember to add the rest of the site's content to the code for each page. If you have any more dynamic content, you can always create more PHP files and include more.
 
Top