Forum Moderators: coopster

Message Too Old, No Replies

Checking Session Variables within FP html

Trying to test session variables on display of FP code

         

rodan

4:08 pm on Sep 26, 2006 (gmt 0)

10+ Year Member



I have a website that was developed with FP and PHP code used for logging in user name and password. I am trying to use SESSION variables to track username on other pages.

In my login script on a successful login I set the session variable for valid user.

$valid_user = $username;
session_register("valid_user");

Then in my other pages I want to test if the session variable is set otherwise send them to the login page.

<?php
session_start();
error_reporting(E_ALL);
if (!isset($_SESSION['valid_user']) {
header("Location:members.htm");
exit;
}
?>

This is the code I'm trying to put at the top of my pages.
It works if the page I'm going to is a php extension page, but if it is an htm page it seems to ignore it.

I also tried using cookies, but haven't had much luck with them either.

Any suggestions are appreciated.

henry0

4:49 pm on Sep 26, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



For HTML to parse PHP
you need to make your HTML parsing PHP :)

Do a search here it is well covered

if you are on a shared server you might not be able to do the changes on your own (Need contacting your ISP)

rodan

7:41 pm on Sep 26, 2006 (gmt 0)

10+ Year Member



I tried adding to my .htaccess

AddHandler application/x-httpd-php .php .htm

and get this error on my php page
HTTP 405 - Resource not allowed
Internet Explorer

I have also tried adding

AddType application/x-httpd-php .php .htm

This option takes my htm file with embedded php and displays the page, but does not execute the php. I viewed the source and I see the php code, but it should have redirected me since I was accessing the page with no session variables set.

See above for code that was added to the htm page.

henry0

11:16 am on Sep 27, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Some host disallow you from modif a .htaccess

We are here speaking about modifying your HTTPD.conf file.
Do some search about it to get an idea on "How to"

BE AWARE: If you new config is somehow wrong you might (after restarting your server) Be looking at blank pages!

As such you need to contact your ISP for guidance.

rodan

2:03 pm on Sep 27, 2006 (gmt 0)

10+ Year Member



I am using oneandone for hosting and finally found on their site the code needed for executing php with an html page. I had to dig around awhile and did a check_info on the version of php and found this statement that I had to add to my .htaccess file

AddType x-mapp-php4 .html .htm

My only concern would be when and if they upgrade to another version of php I'm assuming this statement would have to change (i.e. php5)

Thanks for your patience and hope this helps someone else using oneandone and hosting server.