phppup Posted March 2, 2012 Share Posted March 2, 2012 I have a form that was written and works well as an HTML file. Now I've learned a little (tip of the iceberg, i'm sure) and want to place password protection BEFORE it. To the best of my knowledge, this will require SESSIONS and turning my form into a PHP file. (I assume LOTS of reading is ahead of me... LOL) Can I simply change the extension to a PHP, add the <? tags > and just keep the HTML in place? Or do I need to make it PHP and ECHO every line of code? Or is there another way? And while on the subject, does a PHP file require anything before publishing, the way an HTML requires the <!DOCTYPE> information? Quote Link to comment https://forums.phpfreaks.com/topic/258144-changing-file-extention-to-php/ Share on other sites More sharing options...
blacknight Posted March 2, 2012 Share Posted March 2, 2012 put <?php YOURAUTHCODEHERE ?> and html stays this waya php file will print html properly as long as it is not inclosed in code tags so your auth code can go in the top and stop the page load if the requirements are not meet Quote Link to comment https://forums.phpfreaks.com/topic/258144-changing-file-extention-to-php/#findComment-1323277 Share on other sites More sharing options...
batwimp Posted March 2, 2012 Share Posted March 2, 2012 The file needs to be on a web server that is running a PHP server, or the code won't work at all. Quote Link to comment https://forums.phpfreaks.com/topic/258144-changing-file-extention-to-php/#findComment-1323285 Share on other sites More sharing options...
scootstah Posted March 3, 2012 Share Posted March 3, 2012 You can mix PHP into HTML by either echoing HTML or putting HTML outside of the PHP tags. You can also use more than one set of PHP tags, and use PHP tags anywhere inside of HTML (including attributes and such). Quote Link to comment https://forums.phpfreaks.com/topic/258144-changing-file-extention-to-php/#findComment-1323329 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.