Note that there are some explanatory texts on larger screens.

plurals
  1. POIs there a "right" way to use php?
    primarykey
    data
    text
    <p>I have been learning php, by just plugging away at it.</p> <p>I was hoping someone could point me in the right direction in regards to security, flow and general best practices?</p> <p>Thanks.</p> <p>edit--</p> <p>I suppose a better way to phrase what i am trying to ask is.. What is the best practice:<br> 1.) when processing forms with php, get vs post, $_REQUEST vs $_GET &amp; $_POST<br> 2.) when dynamically creating HTML files (example below)<br> 3.) logins &amp; authentication in the same file as the form creator<br> 4.) Sending e-mail with php </p> <p>From #2 above</p> <pre><code>&lt;?php echo "&lt;h1&gt; Welcome &lt;/h1&gt;"; if ($_SESSION['type'] == "admin") { //lots of html in the echo statment echo "tables and admin interface here"; } else { //lots of html in the echo statment echo "tables and user dashboard here"; } ?&gt; --VS-- &lt;h1&gt; Welcome &lt;/h1&gt; &lt;?php if ($_SESSION['type'] == "admin") { ?&gt; lots of html in the echo statment tables and admin interface here &lt;?php } else { ?&gt; lots of html in the echo statment ables and user dashboard here &lt;?php } ?&gt; --VS-- &lt;?php if($_SESSION['username']): ?&gt; &lt;p&gt;You are logged in as &lt;?=$_SESSION['username']?&gt;&lt;/p&gt; &lt;p&gt;&lt;a href="?logout=1"&gt;Logout&lt;/a&gt;&lt;/p&gt; &lt;?php endif; ?&gt; </code></pre> <p>ps: Thanks to everyone who already responded. Can I also inquire where does a framework fit? I took a class in OOP and we didn't become familiar with any frameworks.</p> <p>I read lot on the Symfony and zend frameworks but am still confused.</p> <p>thanks again.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload