Re: [PHP] Re: [Q] Why does my php file gets displayed instead of executed
Could it be that php files are not executed for POST method? Michael T. Peterson wrote: Per request, here are the two other source files that get executed prior to the invocation of validate_member_login.php, index.php and init.php. But first, here's a simple restatement of the problem: (1) Direct the browser to open index.php (2) init.php is included by index.php. (3) index.php dispatches user to member_login.htm. User fills in username and password fields and then presses the submit button. (4) form action=validate_member_login.php .../ is invoked. (5) The source code of validate_member_login.php is displayed in the browser rather then being executed. However, when the invocation sequence is: (1) Direct the browser directly to member_login.htm and fill in the username and password fields. (2) Press submit. (3) validate_member_login.php is executed properly. Here's index.php. Its purpose is to check the session variables to determine whether the user is logged in. If not, the user is dispatched to member_login.php via redirct using header(). Now, here are the two php files of interest, index.php and init.php. First, index.php, ?php include_once( 'init.php' ); /** * If member is already logged in, his/her username and password values will be available to us. */ if( isset( $HTTP_SESSION_VARS['session_id'] ) isset( $HTTP_SESSION_VARS['username'] ) ) { $session_id = $HTTP_SESSION_VARS['session_id']; $username = $HTTP_SESSION_VARS['username']; $result = authenticate_session( $username, $session_id ); if( $result != SUCCESS ) { if( $result == MEMBER_NOT_REGISTERED ) { header( 'Location: '.MEMBER_REGISTRATION_PAGE ); } else if( $result == PASSWORD_MISMATCH ) { header( 'Location: '.MEMBER_LOGIN_PAGE ); } else { die( $result ); } } header( 'Location: '.MEMBER_HOME_PAGE ); } header( 'Location: '.MEMBER_LOGIN_PAGE ); ? Here is init.php, the file that index.php includes (see above). This file just sets up the exectution environment. ?php session_start(); /** * init.php * * Script that initializes the execution environment. */ // // Check whether this is running on a UNIX or a Windows operating system. // We need to know this to set the include_path separator character // character correctly. // $isWindows = false; $pathDelimiter = ':'; $operatingSystem = PHP_OS; if( strcmp( $operatingSystem, 'WINNT' ) == 0 ) { $isWindows = true; $pathDelimiter = ';'; } // Uncomment and use this symbol when publishing to the internet on ipowerweb. // Yields /home/mazamaso/public_html $WWWROOT = $_SERVER['DOCUMENT_ROOT']; // Set up the dev directory's environment variables. $PROJECT_DIR = $WWWROOT.'/northwest_steelheader'; $MEMBERS_DIR = $PROJECT_DIR.'/members'; $SCRIPTS_DIR= $PROJECT_DIR.'/scripts'; $DB_SCRIPTS_DIR = $SCRIPTS_DIR.'/db'; $UTILS_SCRIPTS_DIR = $SCRIPTS_DIR.'/utils'; $SESSION_SCRIPTS_DIR = $SCRIPTS_DIR.'/security'; $GRAPHICS_DIR= $SCRIPTS_DIR.'/jpgraphics'; $MEMBER_HOME_PAGE = $PROJECT_DIR.'/member_homepage.html'; $MEMBER_LOGIN_PAGE = $MEMBERS_DIR.'/member_login.htm'; $MEMBER_REGISTRATION_PAGE = $MEMBERS_DIR.'/member_registration_form.htm'; $MEMBER_LOGOUT_PAGE = $MEMBERS_DIR.'/member_logout.php'; $INCLUDE_PATH = '.'.$pathDelimiter.$PROJECT_DIR.$pathDelimiter.$DB_SCRIPTS_DIR.$pathDelimite r.$UTILS_SCRIPTS_DIR.$pathDelimiter.$GRAPHICS_DIR.$pathDelimiter.$SESSION_SC RIPTS_DIR; // // Establish the site's environment variables // define( 'PROJECT_DIR', $PROJECT_DIR ); define( 'MEMBERS_DIR', $MEMBERS_DIR ); define( 'SCRIPTS_DIR', $SCRIPTS_DIR ); define( 'DB_DIR', $DB_SCRIPTS_DIR ); define( 'UTILS_DIR', $UTILS_SCRIPTS_DIR ); define( 'SESSION_DIR', $SESSION_SCRIPTS_DIR ); define( 'DEBUG', true ); define( 'MEMBER_HOME_PAGE', $MEMBER_HOME_PAGE ); define( 'MEMBER_LOGIN_PAGE', $MEMBER_LOGIN_PAGE ); define( 'MEMBER_REGISTRATION_PAGE', $MEMBER_REGISTRATION_PAGE ); define( 'MEMBER_LOGOUT_PAGE', $MEMBER_LOGOUT_PAGE ); if( strcmp( $WWWROOT, 'c:/program files/apache group/apache/htdocs' ) == 0 ) { define( 'DB_NAME', '' ); define( 'DB_ADMIN', 'a' ); define( 'DB_PASSWORD', 'b' ); } else { define( 'DB_NAME', '' ); define( 'DB_ADMIN', '' ); define( 'DB_PASSWORD', '' ); } ini_set( 'include_path', $INCLUDE_PATH ); ini_set( 'session.save_path', $PROJECT_DIR.'session_stats'); // These are the base includes, i.e., that apply to every php file in the site include_once( 'print_utils.php' ); include_once( 'mz_error_handler.php' ); include_once( 'db_utils.php' ); include_once( 'passwords.php' ); include_once( 'date_utils.php' ); include_once( 'session_control_lib.php' ); set_error_handler( 'mz_error_handler' ); assert_options( ASSERT_ACTIVE, TRUE ); assert_options( ASSERT_BAIL, TRUE ); ? snip -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: [Q] Why does my php file gets displayed instead of executed
Here is some additional info: My other PHP scripts execute just fine, including the php script init.php which uses header(...) to dispatch to the member_login.htm page. Recall that the problem arises when validate_member_login.php is invoked from member_login.htm. When validate_member_login.php is invoked directly, it executes properly. I'm running the most recent production release of the Apache server on winxp. My ISP is running the same version. I've configured PHP identically with my ISP's Apache config. I use Dreamweaver MX for development and testing. I've not tested for this problem on my ISP's system, yet Once again, note that the php script, validate_member_login.php is executed properly in one case, yet is displayed in the browser in the other. Here is the code for validate_member_login.php: ?php include_once('../init.php'); /** * Variables set by member_login.htm are: * username -- contains the username of the member. * password -- contains the member's password. */ $username = trim($HTTP_POST_VARS['username']); $password = trim($HTTP_POST_VARS['password']); $result = authenticate_member_login( $username, $password ); if( $result == 0 ) { $HTTP_SESSION_VARS['session_id'] = crypt_password( $password ); $HTTP_SESSION_VARS['username'] = $username; header( 'Location: '.MEMBER_HOME_PAGE ); } else { header( 'Location: '.MEMBER_LOGIN_PAGE ); } ? 'init.php' executes session_start(), sets a bunch of constants (e.g., MEMBER_HOME_PAGE, etc.), sets an error handler, and includes a bunch of libraries. All standard stuff. Again, any help would be appreciated. Cheers, Michael Michael T. Peterson [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] When a user first comes to my site, the user's session id is checked and validated. If no session id is present or the validation fails, the user is vectored to a second page containing a login form. When the user enters the username and password and then clicks the submit button the info is forwarded to a third page, a php script, validate_member_login.php, that checks the username and password against a database. Just for completeness, note that the php script, validate_member_login.php, is invoked via login form's action parameter, i.e., form action=validate_member_login.php ... / The problem is that the php script, validate_member_login.php, is displayed in the browser rather than being executed. This is my first attempt at designing a dynamic web site so I'm sure I've missed something really basic, but I have hardly any hair left to pull out. Thanks, in advance, Michael -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: [Q] Why does my php file gets displayed instead of executed
this all seems just fine to me, aren't you sending some Header: Content-type -s? could you post that init.php script source? and is that apache server working well for other scripts that are called from the forms? AND ... just to be sure,... are you calling that html which contains the form thru server? (like http://localhost/myform.html) ... ? because, when calling it directly from dreamweaver, it could be called like direct html file (eg. file://c:/myhtmls/myform.html) and then the script will be called as file://c:/myhtmls/my_authentication_script.php instead of http://localhost/my_authentication_script.php that's all what comes to my mind, regards, m. Michael T. Peterson wrote: Here is some additional info: My other PHP scripts execute just fine, including the php script init.php which uses header(...) to dispatch to the member_login.htm page. Recall that the problem arises when validate_member_login.php is invoked from member_login.htm. When validate_member_login.php is invoked directly, it executes properly. I'm running the most recent production release of the Apache server on winxp. My ISP is running the same version. I've configured PHP identically with my ISP's Apache config. I use Dreamweaver MX for development and testing. I've not tested for this problem on my ISP's system, yet Once again, note that the php script, validate_member_login.php is executed properly in one case, yet is displayed in the browser in the other. Here is the code for validate_member_login.php: ?php include_once('../init.php'); /** * Variables set by member_login.htm are: * username -- contains the username of the member. * password -- contains the member's password. */ $username = trim($HTTP_POST_VARS['username']); $password = trim($HTTP_POST_VARS['password']); $result = authenticate_member_login( $username, $password ); if( $result == 0 ) { $HTTP_SESSION_VARS['session_id'] = crypt_password( $password ); $HTTP_SESSION_VARS['username'] = $username; header( 'Location: '.MEMBER_HOME_PAGE ); } else { header( 'Location: '.MEMBER_LOGIN_PAGE ); } ? 'init.php' executes session_start(), sets a bunch of constants (e.g., MEMBER_HOME_PAGE, etc.), sets an error handler, and includes a bunch of libraries. All standard stuff. Again, any help would be appreciated. Cheers, Michael Michael T. Peterson [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] When a user first comes to my site, the user's session id is checked and validated. If no session id is present or the validation fails, the user is vectored to a second page containing a login form. When the user enters the username and password and then clicks the submit button the info is forwarded to a third page, a php script, validate_member_login.php, that checks the username and password against a database. Just for completeness, note that the php script, validate_member_login.php, is invoked via login form's action parameter, i.e., form action=validate_member_login.php ... / The problem is that the php script, validate_member_login.php, is displayed in the browser rather than being executed. This is my first attempt at designing a dynamic web site so I'm sure I've missed something really basic, but I have hardly any hair left to pull out. Thanks, in advance, Michael -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: [Q] Why does my php file gets displayed instead of executed
Hi, Monday, July 12, 2004, 10:28:59 AM, you wrote: MTP Here is some additional info: MTP My other PHP scripts execute just fine, including the php script init.php MTP which uses header(...) to dispatch to the member_login.htm page. Recall that MTP the problem arises when validate_member_login.php is invoked from MTP member_login.htm. When validate_member_login.php is invoked directly, it MTP executes properly. MTP I'm running the most recent production release of the Apache server on MTP winxp. My ISP is running the same version. I've configured PHP identically MTP with my ISP's Apache config. I use Dreamweaver MX for development and MTP testing. I've not tested for this problem on my ISP's system, yet MTP Once again, note that the php script, MTP validate_member_login.php is executed MTP properly in one case, yet is displayed in the browser in the other. Here is MTP the code for validate_member_login.php: MTP ?php MTP include_once('../init.php'); MTP /** MTP * Variables set by member_login.htm are: MTP * username -- contains the username of the member. MTP * password -- contains the member's password. MTP */ MTP $username = trim($HTTP_POST_VARS['username']); MTP $password = trim($HTTP_POST_VARS['password']); MTP $result = authenticate_member_login( $username, $password ); MTP if( $result == 0 ) { MTP $HTTP_SESSION_VARS['session_id'] = crypt_password( $password ); MTP $HTTP_SESSION_VARS['username'] = $username; MTP header( 'Location: '.MEMBER_HOME_PAGE ); MTP } else { MTP header( 'Location: '.MEMBER_LOGIN_PAGE ); MTP } ? MTP 'init.php' executes session_start(), sets a bunch of constants (e.g., MTP MEMBER_HOME_PAGE, etc.), sets an error handler, and includes a bunch of MTP libraries. All standard stuff. MTP Again, any help would be appreciated. MTP Cheers, MTP Michael Sounds like you forgot the ?php in the include script -- regards, Tom -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: [Q] Why does my php file gets displayed instead of executed
Per request, here are the two other source files that get executed prior to the invocation of validate_member_login.php, index.php and init.php. But first, here's a simple restatement of the problem: (1) Direct the browser to open index.php (2) init.php is included by index.php. (3) index.php dispatches user to member_login.htm. User fills in username and password fields and then presses the submit button. (4) form action=validate_member_login.php .../ is invoked. (5) The source code of validate_member_login.php is displayed in the browser rather then being executed. However, when the invocation sequence is: (1) Direct the browser directly to member_login.htm and fill in the username and password fields. (2) Press submit. (3) validate_member_login.php is executed properly. Here's index.php. Its purpose is to check the session variables to determine whether the user is logged in. If not, the user is dispatched to member_login.php via redirct using header(). Now, here are the two php files of interest, index.php and init.php. First, index.php, ?php include_once( 'init.php' ); /** * If member is already logged in, his/her username and password values will be available to us. */ if( isset( $HTTP_SESSION_VARS['session_id'] ) isset( $HTTP_SESSION_VARS['username'] ) ) { $session_id = $HTTP_SESSION_VARS['session_id']; $username = $HTTP_SESSION_VARS['username']; $result = authenticate_session( $username, $session_id ); if( $result != SUCCESS ) { if( $result == MEMBER_NOT_REGISTERED ) { header( 'Location: '.MEMBER_REGISTRATION_PAGE ); } else if( $result == PASSWORD_MISMATCH ) { header( 'Location: '.MEMBER_LOGIN_PAGE ); } else { die( $result ); } } header( 'Location: '.MEMBER_HOME_PAGE ); } header( 'Location: '.MEMBER_LOGIN_PAGE ); ? Here is init.php, the file that index.php includes (see above). This file just sets up the exectution environment. ?php session_start(); /** * init.php * * Script that initializes the execution environment. */ // // Check whether this is running on a UNIX or a Windows operating system. // We need to know this to set the include_path separator character // character correctly. // $isWindows = false; $pathDelimiter = ':'; $operatingSystem = PHP_OS; if( strcmp( $operatingSystem, 'WINNT' ) == 0 ) { $isWindows = true; $pathDelimiter = ';'; } // Uncomment and use this symbol when publishing to the internet on ipowerweb. // Yields /home/mazamaso/public_html $WWWROOT = $_SERVER['DOCUMENT_ROOT']; // Set up the dev directory's environment variables. $PROJECT_DIR = $WWWROOT.'/northwest_steelheader'; $MEMBERS_DIR = $PROJECT_DIR.'/members'; $SCRIPTS_DIR= $PROJECT_DIR.'/scripts'; $DB_SCRIPTS_DIR = $SCRIPTS_DIR.'/db'; $UTILS_SCRIPTS_DIR = $SCRIPTS_DIR.'/utils'; $SESSION_SCRIPTS_DIR = $SCRIPTS_DIR.'/security'; $GRAPHICS_DIR= $SCRIPTS_DIR.'/jpgraphics'; $MEMBER_HOME_PAGE = $PROJECT_DIR.'/member_homepage.html'; $MEMBER_LOGIN_PAGE = $MEMBERS_DIR.'/member_login.htm'; $MEMBER_REGISTRATION_PAGE = $MEMBERS_DIR.'/member_registration_form.htm'; $MEMBER_LOGOUT_PAGE = $MEMBERS_DIR.'/member_logout.php'; $INCLUDE_PATH = '.'.$pathDelimiter.$PROJECT_DIR.$pathDelimiter.$DB_SCRIPTS_DIR.$pathDelimite r.$UTILS_SCRIPTS_DIR.$pathDelimiter.$GRAPHICS_DIR.$pathDelimiter.$SESSION_SC RIPTS_DIR; // // Establish the site's environment variables // define( 'PROJECT_DIR', $PROJECT_DIR ); define( 'MEMBERS_DIR', $MEMBERS_DIR ); define( 'SCRIPTS_DIR', $SCRIPTS_DIR ); define( 'DB_DIR', $DB_SCRIPTS_DIR ); define( 'UTILS_DIR', $UTILS_SCRIPTS_DIR ); define( 'SESSION_DIR', $SESSION_SCRIPTS_DIR ); define( 'DEBUG', true ); define( 'MEMBER_HOME_PAGE', $MEMBER_HOME_PAGE ); define( 'MEMBER_LOGIN_PAGE', $MEMBER_LOGIN_PAGE ); define( 'MEMBER_REGISTRATION_PAGE', $MEMBER_REGISTRATION_PAGE ); define( 'MEMBER_LOGOUT_PAGE', $MEMBER_LOGOUT_PAGE ); if( strcmp( $WWWROOT, 'c:/program files/apache group/apache/htdocs' ) == 0 ) { define( 'DB_NAME', '' ); define( 'DB_ADMIN', 'a' ); define( 'DB_PASSWORD', 'b' ); } else { define( 'DB_NAME', '' ); define( 'DB_ADMIN', '' ); define( 'DB_PASSWORD', '' ); } ini_set( 'include_path', $INCLUDE_PATH ); ini_set( 'session.save_path', $PROJECT_DIR.'session_stats'); // These are the base includes, i.e., that apply to every php file in the site include_once( 'print_utils.php' ); include_once( 'mz_error_handler.php' ); include_once( 'db_utils.php' ); include_once( 'passwords.php' ); include_once( 'date_utils.php' ); include_once( 'session_control_lib.php' ); set_error_handler( 'mz_error_handler' ); assert_options( ASSERT_ACTIVE, TRUE ); assert_options( ASSERT_BAIL, TRUE ); ? snip -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php