Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Web Programming > HTML > HTML Code Clinic
|
HTML Code Clinic Do you have some HTML code you'd like to share and get suggestions from others for tweaking or improving it? This discussion is the place.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the HTML Code Clinic section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 29th, 2012, 08:51 AM
Authorized User
 
Join Date: Dec 2004
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
Default Html & PHP - In and Out

Hi, you'l have to bear with me, because it's a little obscure.

Exposee:

The first page on my website is "index.php" which initializes some SESSION variables (site language, user name & password, login datetime etc.). This page then calls via php "include" the main webpage (Html+PHP), called "startpage.php", which is dynamic since it can be generated in 3 languages (default + 2).

On the main webpage ("startpage.php") - there are flags for the 2 other languages, which, when clicked, change the SESSION['lang'] variable accordingly thru a PHP script and then try to redraw the main webpage ("startpage.php") in the selected language.

My folder structure is the following (htdocs being "/"):

/index.php
/source/xxx.html & yyy.php - all .html and .php files
/images/...
/css/...

In order to draw the main webpage, I use "include" in index.php (the first file that starts everything). And then I use "include" again in the PHP script that has changed the SESSION['lang'] variable. But this time, the PHP script is in a subfolder of index.php (/source), AND I GET AN ERROR or a CORRUPTED MAIN PAGE, depending on how I refer to "startpage.php" i.e. "/source/startpage", "source/startpage" or just "startpage".

I am sure that if I'd put all "code" pages (html & PHP) in the same place - i.e. in htdocs, I wouldn't get the errors. But that's risky from a SECURITY point of view, isn't it ?


If you understood all the above , the questions are:

Is using "include" or "require" PHP functions the right way to do it ?

If it is, why isn't it working ?
If it isn't, what should I do ?


Thanks a lot in advance.
Cheers,

Mikey
 
Old March 2nd, 2012, 06:51 AM
Authorized User
 
Join Date: Dec 2004
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Ok, guys,

it's solved !

The whole thing was about how to reference your folders in HTML (actually images & scripts in those folders) - as far as I understand, you must precede them with "/" (in Ubuntu) or "\" (in Windows) - "\" referring to the DocumentRoot of your Apache Server.

Otherwise, if you just write <a href="scripts/script_one.html" ....> for a link and press it twice, the second time you'll get the error scripts/scripts/script_one.html not found (or similar), because your path has been written as a relative, not an absolute one (I gather).

At least, this solved my problem.

Cheers,

Mike
 
Old September 15th, 2012, 06:53 AM
Registered User
 
Join Date: Sep 2012
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default re

good ans by mike..i agree





Similar Threads
Thread Thread Starter Forum Replies Last Post
begin php & mysql - chapter 12, user_form.php jon_stubber Beginning PHP 1 March 9th, 2006 10:57 AM
MSXML4.0: 1) Getting Started & 2) First XSL & HTML BigOcean XSLT 1 February 25th, 2005 05:44 PM
HTML & IIS moggie HTML Code Clinic 3 November 22nd, 2004 03:16 PM
Error: movie.php & commit.php on p182-186, ch6 willburke BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 0 October 12th, 2004 02:48 PM
strip html tags & PHP trangd Beginning PHP 6 October 21st, 2003 10:28 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.