0

Advance apologies for this noob question but i have to do it perfectly. I have made a website which are all html files and all are working fine. Now for the session handing i have to convert all the html files into php like

<!DOCTYPE HTML>
<html>
<head>
    <link type="text/css" rel="stylesheet" href="css/bootstrap-min.css"/>
</head>
<body>
  Body elements
</body>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="js/bootstrap.min.js"></script>
</body>
</html>

to something like

<?php
  "SESSION HANDLING PHP CODING"


  echo '<!DOCTYPE HTML>
    <html>
    <head>
        <link type="text/css" rel="stylesheet" href="css/bootstrap-min.css"/>
    </head>
    <body>
      Body elements
    </body>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
    <script src="js/bootstrap.min.js"></script>
    </body>
    </html>'
?>

Hoping for best possible solution. Thanks

2
  • 1) How it is related with phpmyadmin tag? 2) What sessions have to do with the HTML?
    – swapnesh
    Apr 12, 2013 at 6:28
  • You mean to say that you want to show the html according to the session active..?? Apr 12, 2013 at 6:33

3 Answers 3

1

You don't need to do an echo, just close the php tag with "?>":

<?php
//CODE
?>

Your Html Stuff
1

You really don't have to do that - you can mix HTML and PHP easily. Just surround the code with <?php and ?> tags:

<?php /* handle session here */ ?>
<!DOCTYPE HTML>
<html>
<head>
    <link type="text/css" rel="stylesheet" href="css/bootstrap-min.css"/>
</head>
<body>
  Body elements
  <?php echo $something_you_handled_earlier; ?>
</body>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="js/bootstrap.min.js"></script>
</body>
</html>
1
  • @PRASANTH that means that you have something wrong with your PHP code (perharps $something_you_handled_earlier doesn't exist, it was only meant to be an example). Turning on debugging in your PHP/web server settings is a good idea in development environment.
    – Ilmo Euro
    Apr 12, 2013 at 7:25
0

You actually need to refer session handling in PHP.

And then separate the logical php part from the HTML part as mentioned in other answers.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.