Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Web Programming > HTML > HTML Code Clinic
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old February 29th, 2012, 08:51 AM
Authorized User
Points: 173, Level: 3
Points: 173, Level: 3 Points: 173, Level: 3 Points: 173, Level: 3
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Dec 2004
Location: , , .
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
Reply With Quote
  #2 (permalink)  
Old March 2nd, 2012, 06:51 AM
Authorized User
Points: 173, Level: 3
Points: 173, Level: 3 Points: 173, Level: 3 Points: 173, Level: 3
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Dec 2004
Location: , , .
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
Reply With Quote
  #3 (permalink)  
Old September 15th, 2012, 06:53 AM
Registered User
Points: 27, Level: 1
Points: 27, Level: 1 Points: 27, Level: 1 Points: 27, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Sep 2012
Location: 1453 Gingerwood ave, Milpitas CA 95035, USA
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default re

good ans by mike..i agree
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
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 Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 11:40 AM.


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