PHP code not being interpreted by DW and appearing as text on webpage. My Php code is below, this code is bolted into a html site(PHP file). However the code is not being executed and it is appearing as text on the webpage. Any help would be really appreciated.

<?php
include_once("includes/session.php");
confirm_logged_in();
include_once("../includes/masterinclude.php");

$preferences = getPreferences();
$email_setup = getEmailSetup();

//note this will also refresh the page after amending it

$pageTitle = "Site Administration: Confirm Members";

$pageMetaDescription = $preferences->PREF_META_DESC;

$pageMetaKeywords = $preferences->PREF_META_KEYWORDS;

$message = "";

$logincount = 1;
$new = 1;
$errors = 0;
$errors_array = array();
$scrolltobottom = "";

//initialise screen fields
$selected_member = "";
$id = "";
$username = ""; $username_original = "";
$password = ""; $password_original = "";
$password_test = "";
$title = "MR"; $first_name = ""; $last_name = ""; $company_name = "";
$address1 = ""; $address2 = ""; $town = ""; $county = ""; $country = ""; $postcode = ""; $phone = ""; $mobile = ""; $email = ""; $category = "";
$member_confirmed = "N"; $justconfirmed = 0;
$ast_first = 0; $ast_last = 0; $ast_company = 0; $ast_add1 = 0; $ast_add2 = 0; $ast_town = 0; $ast_county = 0; $ast_country = 0; $ast_post = 0; $ast_phone = 0;
$ast_mobile = 0; $ast_email = 0; $ast_category = 0;
$ast_user = 0; $ast_pass = 0; $ast_passconf = 0;
?>



<?php    
        if($_POST['JUST_CONFIRMED'] == 0){
        $rows = Delete_Member($_POST['ID'], $_POST['USERNAME']);
        $message = "";
        if ($rows == 1){
            $message = "Member successfully DELETED";
            $warning = "green";
        }
        if ($rows == 0){
            $message = "WARNING ! ! ! - RECORD NOT DELETED";
            $warning = "orange";
        }
        if ($rows > 1){
            $message = "ERROR ! ! ! - MORE THAN ONE (" . $rows . ") RECORD DELETED - PLEASE CONTACT SHOPFITTER";
            $warning = "red";
        }
        //initialise all fields
        $selected_member = "";
        $id = "";
        $username = ""; $username_original = "";
        $password = ""; $password_original = "";
        $password_test = "";
        $title = "MR"; $first_name = ""; $last_name = ""; $company_name = "";
        $address1 = ""; $address2 = ""; $town = ""; $county = ""; $country = ""; $postcode = ""; $phone = ""; $mobile = ""; $email = "";
        $member_confirmed = "N";
        $ast_first = 0; $ast_last = 0; $ast_company = 0; $ast_add1 = 0; $ast_add2 = 0; $ast_town = 0; $ast_county = 0; $ast_country = 0; $ast_post = 0; $ast_phone = 0;
        $ast_mobile = 0; $ast_email = 0;
        $ast_user = 0; $ast_pass = 0; $ast_passconf = 0;
        if($message != ""){$scrolltobottom = "onLoad=\"scrollTo(0,2000)\" ";}
        }
        else{
        // refresh input details
        $title = $_POST['TITLE'];
        $first_name = $_POST['FIRST_NAME'];
        $last_name = $_POST['LAST_NAME'];
        $company_name = $_POST['COMPANY_NAME'];
        $address1 = $_POST['ADDRESS1'];
        $address2 = $_POST['ADDRESS2'];
        $town = $_POST['TOWN'];
        $county = $_POST['COUNTY'];
        $country = $_POST['COUNTRY'];
        $postcode = $_POST['POSTCODE'];
        $phone = $_POST['PHONE'];
        $mobile = $_POST['MOBILE'];
        $email = $_POST['EMAIL'];
        $member_confirmed = $_POST['MEMBER_CONFIRMED'];
        $username = $_POST['USERNAME_ORIGINAL']; $username_original = $username;
        $id = $_POST['ID'];
        $password = ""; $password_original = $_POST['PASSWORD_ORIGINAL'];
        $login_name = isset($_SESSION['username']) ? $_SESSION['username'] : "";
        $message = "Member now confirmed - Please choose another";
        $warning = "red";
        $just_confirmed = 1;
        $scrolltobottom = "onLoad=\"scrollTo(0,2000)\" ";
    }


if (isset($_GET['searchmember'])) {
    //NEW MEMBER SELECTED from search dropdown so get member deatils for display 
    $u = Get_Member($_GET['searchmember']);
    $id = $u->MB_ID;
    $selected_member = $u->MB_USERNAME;
    $id = $u->MB_ID;
    $username = $u->MB_USERNAME; $username_original = $username;
    $password = ""; $password_original = $u->MB_PASSWORD; //encrypted
    $title = $u->MB_TITLE;
    $first_name = $u->MB_FIRSTNAME;
    $last_name = $u->MB_LASTNAME;
    $company_name = $u->MB_COMPANY;
    $address1 = $u->MB_ADDRESS1;
    $address2 = $u->MB_ADDRESS2;
    $town = $u->MB_TOWN;
    $county = $u->MB_COUNTY;
    $country = $u->MB_COUNTRY;
    $postcode = $u->MB_POSTCODE;
    $phone = $u->MB_PHONE;
    $mobile = $u->MB_MOBILE;
    $email = $u->MB_EMAIL;
    $category = $u->MB_CATEGORY;
    $member_confirmed = $u->MB_CONFIRMED;

    $_POST['SEARCH'] = "search";
    $_POST['SEARCH_DATA'] = $_GET['searchdata'];
    $_POST['SELECTED_MEMBER'] = $_GET['searchmember'];
    $just_confirmed = 0;
}


if (isset($_POST['UPDATE']) or isset($_POST['CONFIRM'])) {
    if($_POST['JUST_CONFIRMED'] == 0){
        if(isset($_POST['CREATE'])){$new = 1;}else{$new = 0;}
        if ($_POST['FIRST_NAME'] == ""){
            $errors_array[] = "Please enter a first name";
            $warning = "red";
            $ast_first = 1;
            $errors = 1;
        }
        if ($_POST['LAST_NAME'] == ""){
            $errors_array[] = "Please enter a last name";
            $warning = "red";
            $ast_last = 1;
            $errors = 1;
        }
        if ($_POST['ADDRESS1'] == ""){
            $errors_array[] = "Please enter an address";
            $warning = "red";
            $ast_add1 = 1;
            $errors = 1;
        }
        if ($_POST['TOWN'] == ""){
            $errors_array[] = "Please enter a Town";
            $warning = "red";
            $ast_town = 1;
            $errors = 1;;
        }
        if ($_POST['COUNTRY'] == ""){
            $errors_array[] = "Please enter a Country";
            $warning = "red";
            $ast_country = 1;
            $errors = 1;
        }
        if ($_POST['POSTCODE'] == ""){
            $errors_array[] = "Please enter a Postcode";
            $warning = "red";
            $ast_post = 1;
            $errors = 1;
        }
        if ($_POST['EMAIL'] == ""){
            $errors_array[] = "Please enter a valid email address";
            $warning = "red";
            $ast_email = 1;
            $errors = 1;
        }
        if ($_POST['CATEGORY'] == ""){
            $errors_array[] = "Please enter a valid  Price Category Code";
            $warning = "red";
            $ast_email = 1;
            $errors = 1;
        }
        if ($_POST['USERNAME'] == ""){
            $errors_array[] = "Please enter a User Name";
            $warning = "red";
            $ast_user = 1;
            $errors = 1;
        }else{
            $m = Confirm_Member($_POST['USERNAME'],"");
            if ($_POST['USERNAME'] !== $_POST['USERNAME_ORIGINAL']){
                $errors_array[] = "Cannot amend User Name";
                $warning = "red";
                $errors = 1;
                $ast_user = 1;
            }
        }   
        if (isset($_POST['CONFIRM']) and $_POST['PASSWORD'] == ""){
            $errors_array[] = "Please enter a Password";
            $warning = "red";
            $ast_pass = 1;
            $errors = 1;
        }
        if (isset($_POST['CONFIRM']) and $_POST['PASSWORD'] != $_POST['PASSWORD_TEST']){
            $errors_array[] = "Password and confirmation do not match";
            $warning = "red";
            $errors = 1;
            $ast_pass = 1; $ast_passconf = 1;
        }

        if($errors == 0){
            //create / amend  table member
            if($new == 1){$hashed_password = sha1($_POST['PASSWORD']);}
            if($new == 0){
                if($_POST['PASSWORD'] != $_POST['PASSWORD_ORIGINAL']){
                    //password has been changed
                    $hashed_password = sha1($_POST['PASSWORD']);
                }else{
                    //password is unchanged so it's already in encrypted format
                    $hashed_password = $_POST['PASSWORD'];
                }
            }

            if (isset($_POST['UPDATE'])){
                $fields = array("id"=>$_POST['ID'], "username"=>$_POST['USERNAME'], "password"=>sha1($_POST['PASSWORD']), "datecreated"=>date("d F l, Y, h:i:s"),
                "lastlogin"=>date("l F d, Y, h:i:s"), "logincount"=>$logincount, "category"=>$_POST['CATEGORY'], "title"=>$_POST['TITLE'], "firstname"=>$_POST['FIRST_NAME'], "lastname"=>$_POST['LAST_NAME'],                                                                                          
                "company"=>$_POST['COMPANY_NAME'], "address1"=>$_POST['ADDRESS1'], "address2"=>$_POST['ADDRESS2'], "town"=>$_POST['TOWN'], "county"=>$_POST['COUNTY'],
                "country"=>$_POST['COUNTRY'], "postcode"=>$_POST['POSTCODE'], "phone"=>$_POST['PHONE'], "mobile"=>$_POST['MOBILE'],
                "email"=>$_POST['EMAIL'], "confirmed"=>$member_confirmed);
                $rows = Rewrite_Member($fields);
            }else{
                $fields = array("id"=>$_POST['ID'], "category"=>$_POST['CATEGORY'], "username"=>$_POST['USERNAME'], "password"=>sha1($_POST['PASSWORD']), "confirmed"=>"Y");
                $rows = Accept_Member($fields);
            }
            $message = "";  
            if ($rows == 1){
                if (isset($_POST['UPDATE'])){
                    $message = "Member successfully UPDATED";
                }else{
                    //send confirmational email
                    $email_it_to = $_POST['EMAIL'];
                    $email_it_to_cc = $email_setup->EM_CONF_CC;
                    $email_it_to_bcc = $email_setup->EM_CONF_BCC;
                    $email_it_from = $preferences->PREF_EMAIL;
                    $email_subject = $email_setup->EM_CONF_SUBJECT;
                    $email_confirmation = $email_setup->EM_CONF_HEADER;
                    $email_confirmation .= $email_setup->EM_CONF_CONTENT;
                    $email_confirmation .= "Name: " . $_POST['USERNAME'] . "    Password: " . $_POST['PASSWORD'] . "\r\n\r\n";
                    $email_confirmation .= $email_setup->EM_CONF_FOOTER;
                    $failure_page = "confirm_members.php?email=fail";

                    include_once("../mailer/_process_from_cms.php");
                    $message = "User " . $_POST['USERNAME'] . " now CONFIRMED as a member";
                }
                $warning = "green";
            }
            if ($rows == 0){
                $message = "WARNING ! ! ! - NO RECORDS UPDATED";
                $warning = "orange";
            }
            if ($rows > 1){
                $message = "ERROR ! ! ! - MORE THAN ONE (" . $rows . ") RECORDS UPDATED - PLEASE CONTACT SHOPFITTER";
                $warning = "red";
            }
            $error = null;
            $error = mysql_error();
            if ($error != null) { 
                $message .= " - ERRORS FOUND ! ! ! - " . mysql_error() . " ";
            }
            if(isset($_POST['UPDATE'])){
                //refresh details
                $username = $_POST['USERNAME']; $username_original = $username;
                $id = $_POST['ID'];
                $password = $_POST['PASSWORD']; $password_original = $password;
                $u = Get_Member($username);
                $category = $u->MB_CATEGORY;
                $title = $u->MB_TITLE;
                $first_name = $u->MB_FIRSTNAME;
                $last_name = $u->MB_LASTNAME;
                $company_name = $u->MB_COMPANY;
                $address1 = $u->MB_ADDRESS1;
                $address2 = $u->MB_ADDRESS2;
                $town = $u->MB_TOWN;
                $county = $u->MB_COUNTY;
                $country = $u->MB_COUNTRY;
                $postcode = $u->MB_POSTCODE;
                $phone = $u->MB_PHONE;
                $mobile = $u->MB_MOBILE;
                $email = $u->MB_EMAIL;
                $member_confirmed = $u->MB_CONFIRMED;
                $login_name = $username;
                $login_password = $password;
                if($message != ""){$scrolltobottom = "onLoad=\"scrollTo(0,2000)\" ";}
            }else{
                // refresh input details
                $category = $_POST['CATEGORY'];
                $title = $_POST['TITLE'];
                $first_name = $_POST['FIRST_NAME'];
                $last_name = $_POST['LAST_NAME'];
                $company_name = $_POST['COMPANY_NAME'];
                $address1 = $_POST['ADDRESS1'];
                $address2 = $_POST['ADDRESS2'];
                $town = $_POST['TOWN'];
                $county = $_POST['COUNTY'];
                $country = $_POST['COUNTRY'];
                $postcode = $_POST['POSTCODE'];
                $phone = $_POST['PHONE'];
                $mobile = $_POST['MOBILE'];
                $email = $_POST['EMAIL'];
                $member_confirmed = $_POST['MEMBER_CONFIRMED'];
                $username = $_POST['USERNAME_ORIGINAL']; $username_original = $username;
                $id = $_POST['ID'];
                $password = ""; $password_original = $_POST['PASSWORD_ORIGINAL'];
                $login_name = isset($_SESSION['username']) ? $_SESSION['username'] : "";
                if($message != ""){$scrolltobottom = "onLoad=\"scrollTo(0,2000)\" ";}
                $just_confirmed = 1;
            }
        }else{
            // refresh input details
            $category = $_POST['CATEGORY'];
            $title = $_POST['TITLE'];
            $first_name = $_POST['FIRST_NAME'];
            $last_name = $_POST['LAST_NAME'];
            $company_name = $_POST['COMPANY_NAME'];
            $address1 = $_POST['ADDRESS1'];
            $address2 = $_POST['ADDRESS2'];
            $town = $_POST['TOWN'];
            $county = $_POST['COUNTY'];
            $country = $_POST['COUNTRY'];
            $postcode = $_POST['POSTCODE'];
            $phone = $_POST['PHONE'];
            $mobile = $_POST['MOBILE'];
            $email = $_POST['EMAIL'];
            $member_confirmed = $_POST['MEMBER_CONFIRMED'];
            $username = $_POST['USERNAME_ORIGINAL']; $username_original = $username;
            $id = $_POST['ID'];
            $password = ""; $password_original = $_POST['PASSWORD_ORIGINAL'];
            $login_name = isset($_SESSION['username']) ? $_SESSION['username'] : "";

            /*
            $message = "";
            foreach($errors_array as $e){
                $message .= $e . "<br/>";    
            }
            $warning = "red";
            */
        }
    }else{
        $message = "Member now confirmed - Please choose another";
        $warning = "red";
        $scrolltobottom = "onLoad=\"scrollTo(0,2000)\" ";
        // refresh input details
        $category = $_POST['CATEGORY'];
        $title = $_POST['TITLE'];
        $first_name = $_POST['FIRST_NAME'];
        $last_name = $_POST['LAST_NAME'];
        $company_name = $_POST['COMPANY_NAME'];
        $address1 = $_POST['ADDRESS1'];
        $address2 = $_POST['ADDRESS2'];
        $town = $_POST['TOWN'];
        $county = $_POST['COUNTY'];
        $country = $_POST['COUNTRY'];
        $postcode = $_POST['POSTCODE'];
        $phone = $_POST['PHONE'];
        $mobile = $_POST['MOBILE'];
        $email = $_POST['EMAIL'];
        $member_confirmed = $_POST['MEMBER_CONFIRMED'];
        $username = $_POST['USERNAME_ORIGINAL']; $username_original = $username;
        $id = $_POST['ID'];
        $password = ""; $password_original = $_POST['PASSWORD_ORIGINAL'];
        $login_name = isset($_SESSION['username']) ? $_SESSION['username'] : "";
        $just_confirmed = 1;
    }
}
?>

Dani AI

Generated

Thanks to for the pointer that resolved the immediate issue and to and for the server-related checks. The problem you ran into is a classic symptom of the PHP interpreter not being involved in the HTTP response. Below is a compact troubleshooting checklist and two tiny tests to run so the root cause is clear the next time this happens.

First, two quick verification files to drop into the server document root and access through your configured testing server:

<?php
phpinfo();
?>
<?php
echo 'PHP running';
?>

If those show PHP output, the server is parsing PHP correctly. If they do not, verify the local webserver/PHP process is running and that the files are inside the server document root (not just opened from disk). Also check the server error log for startup or module-load errors.

If the tests run but your page still shows literal PHP tags, view the browser’s raw source. If the PHP tags are HTML-encoded (for example &lt;?php), something upstream is escaping the code (a templating step, editor/export setting, or a file saved with entities). If the tags appear as raw <?php in source then the server never parsed them — re-check that the URL used to load the page goes through your testing server (Dreamweaver’s testing-server settings must map local root to the server and use the PHP server model), and that the file extension is .php and not being served as plain text.

Extra checks: confirm your server configuration actually loads the PHP module/handler, inspect response headers (Content-Type), and check file permissions. These steps cover the common causes beyond the “open file directly” case and make it easier to spot the exact failure mode in future.

Recommended Answers

All 6 Replies

You mean as text on the page in DW design view and/or live view, or just in the browser on your local machine? You will need to have a server environment on your local machine installed in order to execute PHP files. Look into WAMP for Windows or MAMP for Mac.

I am already running WAMP and have already set it up in dreamweaver, would you have any other suggestions?

No sorry... it's been ages for me since I have used DW and perhaps this thread is better off in the PHP forum.

Member Avatar for Member #120589

You have Apache running? Check to see. Often happens if webserver not running.

Ahh thankyou pzuurveen, problem solved. Thanks for the help guys

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.