Go Back   Web Hosting UK Forums | Linux Windows Dedicated Server and cPanel VPS Hosting Forum > Support > php issues.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 01-13-2008, 09:23 PM
Senior Member
 
Join Date: Dec 2006
Posts: 544
Send a message via MSN to karimali831
Default Need a little help..

I'm new to this and need help with 2 things.
You'll maybe not understand, hope you do though

1)

I setup a website @ http://team-300.net/templates/1/index.php and for any php page I create it would show the contents of the first page from http://team-300.net/templates/1/index.php?site=news and for example, if I do create a link "awards.php" http://team-300.net/templates/2/index.php?site=awards would still point to index.php?page=news showing the contents of that page (No redirection) the page itself

2)

Also have 5 designs of that website, trying to show the contents of news.php for each news.php for each design e.g. http://team-300.net/templates/1/index.php?page=site the same as http://team-300.net/templates/2/index.php?page=site
I have no clue of doing this, seems a little complicated. I do not want to do this manually for each theme as this will take very long and as I know there's another way but I just don't know how

I can't point http://team-300.net/templates/2/index.php?page=news to templates/1/index.php?page=news as it would show template 1 and can't do the same for templates/2/index.php?page=news to point to templates/1/news.php as this will just show the contents, not the design/index.php iteslf.

Also, try not to comment on frames if you can BUT if that's the only way, then I got no choice.

Yeah, problem 1 is the main thing so if you can help I'll appreciate it.

Thanks!
Karim

Last edited by karimali831; 01-13-2008 at 09:25 PM.
Reply With Quote
  #2 (permalink)  
Old 01-15-2008, 08:52 PM
Senior Member
 
Join Date: Dec 2006
Posts: 544
Send a message via MSN to karimali831
Default

I take it no one is able to help me because they don't have the knowledge to do so, or my post is just really POOR and unclear?
Reply With Quote
  #3 (permalink)  
Old 01-16-2008, 02:35 PM
Senior Member
 
Join Date: Jan 2007
Posts: 939
Default

Hi Karim,
I am afraid that I don't understand your post, not sure what you mean.

Maybe if you could explain it again and maybe deal with one problem at a time, then someone here might be able to help?? Also explain where the page info is coming from. Database?

I had a quick look at your site and the first thing that i noticed was the coding for the page shows head and body sections repeated a few times.
Copied below:
Code:
 
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252" x-undefined>
<title>New Page 1</title>
</head>
<body>
</body>
</html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252" x-undefined>
<title>New Page 1</title>
</head>
<body>
</body>
</html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252" x-undefined>
<title>New Page 1</title>
</head>
<body>
</body>
</html>
<html>
<head>
Good luck
__________________
West Dorset Community
Reply With Quote
  #4 (permalink)  
Old 01-16-2008, 07:29 PM
Senior Member
 
Join Date: Dec 2006
Posts: 544
Send a message via MSN to karimali831
Default

I'll try explain 1 again with codes.

I am able to use this fine ->
Code:
<td width="196" height="42" valign="top"><? include("sc_files.php"); ?></td>
Which means if I create a file "sc_files.php" it will work fine aswell as editing it etc

BUT When using this code, it doesn't work. The index.php?site=gallery will just point to a different unspecified php page

Code:
<a href="index.php?site=gallery" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image41','','Bilder/gallery1_47.jpg',1)"><img src="Bilder/gallery_47.jpg" name="Image41" width="167" height="15" border="0"></a></td>
So if I create file "gallery.php" it would show the contents of another page not that one I created.


I tried

Code:
<? include("sc_files.php"); ?><onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image41','','Bilder/gallery1_47.jpg',1)"><img src="Bilder/gallery_47.jpg" name="Image41" width="167" height="15" border="0"></a></td>
But I know this is soo wrong.. so how can I get that last code to work?

Thanks for your reply

Last edited by karimali831; 01-16-2008 at 07:32 PM.
Reply With Quote
  #5 (permalink)  
Old 01-16-2008, 09:03 PM
Senior Member
 
Join Date: Jan 2007
Posts: 939
Default

I think if you are going to be 'including' text in the form of ?site=gallery then somewhere (usually stored in a database) there is a field entitled 'gallery' which also contains a text field.

For instance; on my main index.php page i would first need to create a variable that gets the content of site, so.........
$site=$_GET['site'];

Then if i clicked on the link: <a href="index.php?site=gallery">
I would query the database: $query="SELECT * FROM db WHERE title = '$site'"
this would then get the text that i need from the database.

If the files are static pages then you could use the example above but instead of using a database you could use (from your example):
<td width="196" height="42" valign="top"><? include($site.".php"); ?></td>
A bit unconventional though, database is best option.

Or do you mean something different?
__________________
West Dorset Community
Reply With Quote
  #6 (permalink)  
Old 01-16-2008, 10:46 PM
Senior Member
 
Join Date: Dec 2006
Posts: 544
Send a message via MSN to karimali831
Default

Quote:
Originally Posted by jon123 View Post
I think if you are going to be 'including' text in the form of ?site=gallery then somewhere (usually stored in a database) there is a field entitled 'gallery' which also contains a text field.

For instance; on my main index.php page i would first need to create a variable that gets the content of site, so.........
$site=$_GET['site'];

Then if i clicked on the link: <a href="index.php?site=gallery">
I would query the database: $query="SELECT * FROM db WHERE title = '$site'"
this would then get the text that i need from the database.

If the files are static pages then you could use the example above but instead of using a database you could use (from your example):
<td width="196" height="42" valign="top"><? include($site.".php"); ?></td>
A bit unconventional though, database is best option.

Or do you mean something different?
Thanks for your reply. Well I wasn't really looking into databases just reading that line I was very confused

But now you say it, I want a database! Have no clue what you just said though, must I create one at first?

I sent you a PM
Reply With Quote
  #7 (permalink)  
Old 01-17-2008, 01:40 PM
Senior Member
 
Join Date: Jul 2007
Posts: 132
Default

Ah if you have no clue of PHP jumping into a database is not the best thing.

First lets look at how you solve the problem.

You need to make a plan of how you want it to work (in the old days it was called a flow chart )

This helps you set the process going.

So if I understand it correctly you want to show index.php with contents of unknown pages (cos you create them at will).

The easiest way to do this is to create text files rather than php.

(the same as importing into macromedia flash)

If you save them ALL in the same folder on the server, you can use php to look at what is in the folder and DO something with it, WITHOUT knowing the file name or contents.

(you could for instance list all files and make them links to content if they are php or html)

Databases are great and I use them alot, BUT you need to get some basic understanding here before treading much deeper technical stuff. I have learnt over the last 4 years php then mySql and I still do not know 100%.
Reply With Quote
  #8 (permalink)  
Old 01-17-2008, 01:55 PM
Senior Member
 
Join Date: Jan 2007
Posts: 939
Default

I think if you are going to use text files and php include, you would be better off creating a standard static website. Too much hassle for little or no benefit imo.

As far as php/mysql and interacting with databases, it is fairly simple to learn as both include learning just the basics. There are plenty of tutorials about just search for google. But as someone mentioned a while back, why reinvent the wheel, there are plenty of free cms available also.
__________________
West Dorset Community
Reply With Quote
  #9 (permalink)  
Old 01-17-2008, 02:36 PM
Foddski's Avatar
new member
 
Join Date: Nov 2007
Posts: 9
Default

There are a number of ways of doing this the easiest IMOP is the following
if (isset($_GET['page'])){$page = $_GET['page'];} check if a variable has been sent.

if(!file_exists("$page.php"))
{ include("home.php");}else {include("$page.php");} includes the correct page and defaults to home page if invalid variable is passed

Good Luck

Rich
Reply With Quote
  #10 (permalink)  
Old 01-17-2008, 03:31 PM
Senior Member
 
Join Date: Dec 2006
Posts: 544
Send a message via MSN to karimali831
Default

I'm afraid nothing makes sense to me if it's php related. I can't read aswell as write php; I've uploaded the index.php .. from what's there and what your all saying I'm totally confused = Total newbie = = Sorry

Thanks for your help
Attached Files
File Type: zip index.zip (3.0 KB, 1 views)
Reply With Quote
  #11 (permalink)  
Old 01-17-2008, 03:41 PM
Foddski's Avatar
new member
 
Join Date: Nov 2007
Posts: 9
Default

What you have got is ok
PHP Code:
$site $_GET['site'] . ".php"

if(
file_exists($site)) { 
    include(
$site); 
} else { 
  include(
'news.php'); 

Quote:
if (isset($_GET['page'])){$page = $_GET['page'];}
is your
Quote:
$site = $_GET['site']
Quote:
if(!file_exists("$page.php"))
{ include("home.php");}else {include("$page.php");}
is your
Quote:
include($site);
} else {
include('news.php');
}
just better written

Last edited by Foddski; 01-17-2008 at 03:47 PM.
Reply With Quote
  #12 (permalink)  
Old 01-17-2008, 05:26 PM
Senior Member
 
Join Date: Dec 2006
Posts: 544
Send a message via MSN to karimali831
Default

Still confused... with that index.php attatchment how could I make all the links work? The 'include' works for each individual file I create? and also if the file doesn't exist.. to go to the news.php
Reply With Quote
  #13 (permalink)  
Old 01-17-2008, 05:39 PM
Senior Member
 
Join Date: Dec 2006
Posts: 544
Send a message via MSN to karimali831
Default

I think I did it... it's this part which needs to be edited

Quote:
$site = $_GET['site'] . ".php";

if(file_exists($site)) {
include($site);
} else {
include('news.php');
include('gallery.php');
(etc..)
}
if(($_GET['site']))
?></td>

Last edited by karimali831; 01-17-2008 at 05:50 PM.
Reply With Quote
  #14 (permalink)  
Old 01-17-2008, 05:50 PM
Senior Member
 
Join Date: Dec 2006
Posts: 544
Send a message via MSN to karimali831
Default

Ok got that theme sorted now for this one;
Is it this bit what needs editing?

Now I want this to be the same as the other one, so all files are included.
"news.php" "gallery.php" etc.. not sure how to add it on this part unless it's something different

see the attatchment

Code:
       <?
    if(!isset($site)) $site="news";
    //Sichheitsl&uuml;cke beheben
    $invalide = array('/','/\/',':','.');
    $site = str_replace($invalide,' ',$site);
    if(!file_exists($site.".php")) $site = "news";
    include($site.".php");
    ?>
Attactchment: Uploaded

Thanks
Attached Files
File Type: zip index.zip (3.0 KB, 2 views)
Reply With Quote
  #15 (permalink)  
Old 01-18-2008, 01:27 PM
Foddski's Avatar
new member
 
Join Date: Nov 2007
Posts: 9
Default

PHP Code:
      <?
    
if(!isset($site)) {$site="news";}
    
//Sichheitsl&uuml;cke beheben
    
$invalide = array('/','/\/',':','.');
    
$site str_replace($invalide,' ',$site);
    if(!
file_exists($site.".php")) {$site "news";}
    include(
$site.".php");
    
?>
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 04:17 AM.
Copyright 2002-2007 WebHosting.uk.com. All rights reserved.
Web Hosting UK Forum