0

I am running my Apache server with MAMP on my macbook pro. I am trying to run a php script in my HTML code, but neither my visual studio code or Apache server are recognizing the code.

The code in question is:

<?php // Create a login/logout link:
                            if (isset($_SESSION['CustNum'])) {
                                echo '<a href="logout.php">Logout</a>';
                            } else {
                                echo '<a href="login.php">Login</a>';
                            }
                            ?></li>

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>
        WELP
    </title>
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
    <link href="css/sticky-footer-navbar.css" rel="stylesheet">
    <link rel="stylesheet" href="styles.css">
</head>

<body>
    <nav class="navbar navbar-default navbar-fixed-top">
        <div class="container">
            <div class="navbar-header"><a class="navbar-brand" href="#">Your Website</a></div>
            <div id="navbar" class="collapse navbar-collapse">
                <ul class="nav navbar-nav">
                    <li class="active"><a href="index.php">Home</a></li>
                    <li><a href="register.php">Register</a></li>
                    <li><a href="view_users.php">View Users</a></li>
                    <li><a href="password.php">Change Password</a></li>
                    <li><a href="email.php">Contact Form</a></li>
                    <li><a href="upload_image.php"> Uploads</a></li>
                    <li><a href="images.php">Images</a></li>
                    <!-- <li><a href="login_page.inc.php">Login</a></li> -->
                    <li>
                        <?php // Create a login/logout link:
                        if (isset($_SESSION['CustNum'])) {
                            echo '<a href="logout.php">Logout</a>';
                        } else {
                            echo '<a href="login.php">Login</a>';
                        }
                        ?></li>


                </ul>
            </div>
        </div>
    </nav>
    <div class="container">
    </div>
    <footer class="footer">
        <div class="container">
            <p class="text-muted">
                <p>Copyright &copy; 2017
                </p>
            </p>
        </div>
    </footer>
</body>

</html>

Is there something i need to configure before I am able to do this?

Funk Forty Niner
  • 74,450
  • 15
  • 68
  • 141

1 Answers1

1

A quick test of your setup would be to create a new php file with the following:

<?php
echo 'Version: ' . phpversion();
?>

Save this file with a .php extension and try to access it from your browser.

Baledin
  • 43
  • 4