I am new at programming websites and have spent the last month learning jQuery and PHP. I built a website using jQuery, but now realise that i need to use php as well but mainly for the purpose of authentication. I don't want to try to redo the jQuery code in php.
I know that most people recommend separating server-side and browser-side scripts and HTML, but can I use both jQuery and php in the same file for separate purposes with out any conflicts or issues aising? The file extension will be .php and I expect the structure to be along the lines of:
<?php
//php code for authentication
?>
<html>
<head>
//header code
<sctipt>
//jquery code to control layout including hiding divs and changing the information
//shown based on conditional statements
</script>
</head>
//other html
Sorry if this is a dumb question, but I would like to know the best way forward before I get too far. I appreciate your help.
Thank you all for your quick responses, much appreciated.
The purpose of the php is so that only people who are logged in can see the page. My current understanding is that authentication can only be done by using cookies (still have to learn about sessions) and that these require a php script. Is there a better method so I don't have to mix the two languages on the one page? or is my method easier and equally valid - even though it's bad practice?