<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: PHP login</title>
	<atom:link href="http://www.php-help.ro/php-tutorials/php-login/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.php-help.ro/php-tutorials/php-login/</link>
	<description>All about integrating PHP with JavaScript and Flash</description>
	<lastBuildDate>Tue, 31 Jan 2012 02:53:55 +0200</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Constantin Boiangiu</title>
		<link>http://www.php-help.ro/php-tutorials/php-login/comment-page-1/#comment-4094</link>
		<dc:creator>Constantin Boiangiu</dc:creator>
		<pubDate>Mon, 09 Aug 2010 16:01:58 +0000</pubDate>
		<guid isPermaLink="false">http://www.php-help.ro/php/php-login/#comment-4094</guid>
		<description>This is not an error, it&#039;s just a notice. you must have error_reporting set to all. No problem, one change needed, line 19 is this one:

&lt;code&gt;if($_GET[&#039;logout&#039;])&lt;/code&gt;

All you need to do is check if variable is set, so instead of the line above, put this:

&lt;code&gt;if( isset($_GET[&#039;logout&#039;]) )&lt;/code&gt;

This should do it. Let me know.</description>
		<content:encoded><![CDATA[<p>This is not an error, it&#8217;s just a notice. you must have error_reporting set to all. No problem, one change needed, line 19 is this one:</p>
<p><code>if($_GET['logout'])</code></p>
<p>All you need to do is check if variable is set, so instead of the line above, put this:</p>
<p><code>if( isset($_GET['logout']) )</code></p>
<p>This should do it. Let me know.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jamarchi</title>
		<link>http://www.php-help.ro/php-tutorials/php-login/comment-page-1/#comment-4093</link>
		<dc:creator>jamarchi</dc:creator>
		<pubDate>Mon, 09 Aug 2010 15:17:28 +0000</pubDate>
		<guid isPermaLink="false">http://www.php-help.ro/php/php-login/#comment-4093</guid>
		<description>I didn´t change anything</description>
		<content:encoded><![CDATA[<p>I didn´t change anything</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jamarchi</title>
		<link>http://www.php-help.ro/php-tutorials/php-login/comment-page-1/#comment-4092</link>
		<dc:creator>jamarchi</dc:creator>
		<pubDate>Mon, 09 Aug 2010 15:14:55 +0000</pubDate>
		<guid isPermaLink="false">http://www.php-help.ro/php/php-login/#comment-4092</guid>
		<description>Hi, I just find this blog and is great

I tested the scrip but i saw this error in the protected.php page

Notice: Undefined index: logout in C:\wamp\www\php_login\php_login\protected.php on line 19

Can you please help me?</description>
		<content:encoded><![CDATA[<p>Hi, I just find this blog and is great</p>
<p>I tested the scrip but i saw this error in the protected.php page</p>
<p>Notice: Undefined index: logout in C:\wamp\www\php_login\php_login\protected.php on line 19</p>
<p>Can you please help me?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ndowie</title>
		<link>http://www.php-help.ro/php-tutorials/php-login/comment-page-1/#comment-3348</link>
		<dc:creator>ndowie</dc:creator>
		<pubDate>Thu, 24 Sep 2009 05:07:13 +0000</pubDate>
		<guid isPermaLink="false">http://www.php-help.ro/php/php-login/#comment-3348</guid>
		<description>Gigi Duru said: &quot;As for the “problem” with $_SESSION, it’s quite simple: prevent SQL injection (you should do that anyway, i can’t imagine writing something in php without thinking of potential sql injections to that script) and no issue with $_SESSION.&quot;

I&#039;m agree with Gigi, I using $_SESSION till now, then I read this post, the better idea is combine its.</description>
		<content:encoded><![CDATA[<p>Gigi Duru said: &#8220;As for the “problem” with $_SESSION, it’s quite simple: prevent SQL injection (you should do that anyway, i can’t imagine writing something in php without thinking of potential sql injections to that script) and no issue with $_SESSION.&#8221;</p>
<p>I&#8217;m agree with Gigi, I using $_SESSION till now, then I read this post, the better idea is combine its.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Constantin Boiangiu</title>
		<link>http://www.php-help.ro/php-tutorials/php-login/comment-page-1/#comment-3240</link>
		<dc:creator>Constantin Boiangiu</dc:creator>
		<pubDate>Tue, 04 Aug 2009 21:55:43 +0000</pubDate>
		<guid isPermaLink="false">http://www.php-help.ro/php/php-login/#comment-3240</guid>
		<description>You simply enter the hash: INSERT INTO users_table SET username=&#039;username&#039;, password=MD5(&#039;password&#039;). This should do it.</description>
		<content:encoded><![CDATA[<p>You simply enter the hash: INSERT INTO users_table SET username=&#8217;username&#8217;, password=MD5(&#8216;password&#8217;). This should do it.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Liliana</title>
		<link>http://www.php-help.ro/php-tutorials/php-login/comment-page-1/#comment-3239</link>
		<dc:creator>Liliana</dc:creator>
		<pubDate>Tue, 04 Aug 2009 21:15:39 +0000</pubDate>
		<guid isPermaLink="false">http://www.php-help.ro/php/php-login/#comment-3239</guid>
		<description>hi thx for this useful example... but i dont know how u insert in ur table users a password...? lets say i want to create a new user with a defined password how can i do it? im new so forgive me if this is a stupid question</description>
		<content:encoded><![CDATA[<p>hi thx for this useful example&#8230; but i dont know how u insert in ur table users a password&#8230;? lets say i want to create a new user with a defined password how can i do it? im new so forgive me if this is a stupid question</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Constantin Boiangiu</title>
		<link>http://www.php-help.ro/php-tutorials/php-login/comment-page-1/#comment-2937</link>
		<dc:creator>Constantin Boiangiu</dc:creator>
		<pubDate>Thu, 19 Mar 2009 11:32:33 +0000</pubDate>
		<guid isPermaLink="false">http://www.php-help.ro/php/php-login/#comment-2937</guid>
		<description>I liked the one with &quot;look mom&quot; :) . At the beginning, I think all websites are 500 visitors/month and grow with time. Once a problem arise, you are forced to make changes. You can&#039;t know from the beginning (unless encountered before) what kind of problems a website might have. 
Anyway, thanks for sharing the rest of the info. I&#039;ve never worked on sites as big as the one you mentioned so many of the issues you encountered are somewhat new. At that traffic, I must agree with you about what you said earlier. Thanks again.</description>
		<content:encoded><![CDATA[<p>I liked the one with &#8220;look mom&#8221; :) . At the beginning, I think all websites are 500 visitors/month and grow with time. Once a problem arise, you are forced to make changes. You can&#8217;t know from the beginning (unless encountered before) what kind of problems a website might have.<br />
Anyway, thanks for sharing the rest of the info. I&#8217;ve never worked on sites as big as the one you mentioned so many of the issues you encountered are somewhat new. At that traffic, I must agree with you about what you said earlier. Thanks again.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Gigi Duru</title>
		<link>http://www.php-help.ro/php-tutorials/php-login/comment-page-1/#comment-2936</link>
		<dc:creator>Gigi Duru</dc:creator>
		<pubDate>Thu, 19 Mar 2009 10:52:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.php-help.ro/php/php-login/#comment-2936</guid>
		<description>Sorry about the sarcasm, I&#039;m a bit tired lately.

You wanted me to share a better solution: store the userid in $_SESSION (or 0 if guest), on all pages which require a valid user check the $_SESSION. And, of course, prevent sql injections by making sure to sanitize any input to your script, don&#039;t use register_globals, try reading about various php security tips and tricks, etc.

I&#039;ve been programming for 12 years now, in a lot of languages, not only php and I can tell you from own experience that the syndrome &quot;let&#039;s find another (maybe clever) way to do something, totally different than everybody else is doing it&quot; is very bad for business. 
I&#039;ve seen and worked with a lot of beginner developers which find on google various tutorials and examples (such as the example login you have here),  don&#039;t think for themselves and just copy+paste the code in their scripts and then are surprised that they get bad performance, bad security or plain old bad code... this is bad for the community, so if you want to HELP the community and beginners, explain WHY the proven methodology works, don&#039;t waste time finding &#039;clever ways&#039; to re-invent the wheel.

You said you&#039;ve seen live sites where you could bypass login via some sql injection.. then you&#039;ve witnessed the phenomenon i&#039;m talking about: bad programming due to bad tutorials. 
It&#039;s very common (unfortunately) in the PHP world and that&#039;s why java/c#/c++ developers sometimes look down at php developers saying they&#039;re just some script kiddies... Of course, java/c# worlds have their own &#039;script kiddies&#039; but since many of them are making enterprise/desktop apps not everybody can see the results of their work, while php is being used for a lot of sites so it&#039;s easier to discover the bad written ones.

Programming is a very difficult job and has nothing to do with the language in which you&#039;re programming.

p.s.:
http://www.sitepoint.com/blogs/2004/03/03/notes-on-php-session-security/ more info on REAL security issues with session.</description>
		<content:encoded><![CDATA[<p>Sorry about the sarcasm, I&#8217;m a bit tired lately.</p>
<p>You wanted me to share a better solution: store the userid in $_SESSION (or 0 if guest), on all pages which require a valid user check the $_SESSION. And, of course, prevent sql injections by making sure to sanitize any input to your script, don&#8217;t use register_globals, try reading about various php security tips and tricks, etc.</p>
<p>I&#8217;ve been programming for 12 years now, in a lot of languages, not only php and I can tell you from own experience that the syndrome &#8220;let&#8217;s find another (maybe clever) way to do something, totally different than everybody else is doing it&#8221; is very bad for business.<br />
I&#8217;ve seen and worked with a lot of beginner developers which find on google various tutorials and examples (such as the example login you have here),  don&#8217;t think for themselves and just copy+paste the code in their scripts and then are surprised that they get bad performance, bad security or plain old bad code&#8230; this is bad for the community, so if you want to HELP the community and beginners, explain WHY the proven methodology works, don&#8217;t waste time finding &#8216;clever ways&#8217; to re-invent the wheel.</p>
<p>You said you&#8217;ve seen live sites where you could bypass login via some sql injection.. then you&#8217;ve witnessed the phenomenon i&#8217;m talking about: bad programming due to bad tutorials.<br />
It&#8217;s very common (unfortunately) in the PHP world and that&#8217;s why java/c#/c++ developers sometimes look down at php developers saying they&#8217;re just some script kiddies&#8230; Of course, java/c# worlds have their own &#8217;script kiddies&#8217; but since many of them are making enterprise/desktop apps not everybody can see the results of their work, while php is being used for a lot of sites so it&#8217;s easier to discover the bad written ones.</p>
<p>Programming is a very difficult job and has nothing to do with the language in which you&#8217;re programming.</p>
<p>p.s.:<br />
<a href="http://www.sitepoint.com/blogs/2004/03/03/notes-on-php-session-security/" rel="nofollow">http://www.sitepoint.com/blogs/2004/03/03/notes-on-php-session-security/</a> more info on REAL security issues with session.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Gigi Duru</title>
		<link>http://www.php-help.ro/php-tutorials/php-login/comment-page-1/#comment-2935</link>
		<dc:creator>Gigi Duru</dc:creator>
		<pubDate>Thu, 19 Mar 2009 10:34:28 +0000</pubDate>
		<guid isPermaLink="false">http://www.php-help.ro/php/php-login/#comment-2935</guid>
		<description>Actually, try having a site with 6 million pageviews/day (100 req/sec) and you WILL notice how much overhead a simple  query adds to it. I&#039;m the main developer of http://www.eventshooters.com/ (austrian portal like hi5),  we get 180 mil. pageviews/month and I actually know what I&#039;m talking about. 

As for the &quot;problem&quot; with $_SESSION, it&#039;s quite simple: prevent SQL injection (you should do that anyway, i can&#039;t imagine writing something in php without thinking of potential sql injections to that script) and no issue with $_SESSION.

And, yes, sometimes you shouldn&#039;t do queries in your pages. We use memcached all-over the place.

Of course, i guess for &quot;look mom, i made a php site with 500 visitors/month&quot; php development your solution works too ... :)</description>
		<content:encoded><![CDATA[<p>Actually, try having a site with 6 million pageviews/day (100 req/sec) and you WILL notice how much overhead a simple  query adds to it. I&#8217;m the main developer of <a href="http://www.eventshooters.com/" rel="nofollow">http://www.eventshooters.com/</a> (austrian portal like hi5),  we get 180 mil. pageviews/month and I actually know what I&#8217;m talking about. </p>
<p>As for the &#8220;problem&#8221; with $_SESSION, it&#8217;s quite simple: prevent SQL injection (you should do that anyway, i can&#8217;t imagine writing something in php without thinking of potential sql injections to that script) and no issue with $_SESSION.</p>
<p>And, yes, sometimes you shouldn&#8217;t do queries in your pages. We use memcached all-over the place.</p>
<p>Of course, i guess for &#8220;look mom, i made a php site with 500 visitors/month&#8221; php development your solution works too &#8230; :)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Constantin Boiangiu</title>
		<link>http://www.php-help.ro/php-tutorials/php-login/comment-page-1/#comment-2934</link>
		<dc:creator>Constantin Boiangiu</dc:creator>
		<pubDate>Thu, 19 Mar 2009 08:40:22 +0000</pubDate>
		<guid isPermaLink="false">http://www.php-help.ro/php/php-login/#comment-2934</guid>
		<description>I don&#039;t think a simple query can kill your server. Maybe we shouldn&#039;t do any queries at all in all the pages. Go back to plain HTML so that we don&#039;t kill servers. I ran a test on 1000 users table and the query took .02. I know, if you run an explain on the sql, it doesn&#039;t look so good. That can be improved with a little imagination. What kills me is sarcasm. Instead of being smart ass, try share with us a better, safer solution. Now, that COULD help.  

About the $_SESSION[&#039;some_variable&#039;] situation, I&#039;ve seen this. It goes like this: you have a login page and the user does an sql injection with your form. User input verification is not properly done and it validates. $_SESSION[&#039;some variable&#039;] gets from false to true. All subsequent pages verify if the session variable is true and if it is grants access. So you have access to all pages even though you didn&#039;t had a user. I repeat, I&#039;ve seen  this on live websites.</description>
		<content:encoded><![CDATA[<p>I don&#8217;t think a simple query can kill your server. Maybe we shouldn&#8217;t do any queries at all in all the pages. Go back to plain HTML so that we don&#8217;t kill servers. I ran a test on 1000 users table and the query took .02. I know, if you run an explain on the sql, it doesn&#8217;t look so good. That can be improved with a little imagination. What kills me is sarcasm. Instead of being smart ass, try share with us a better, safer solution. Now, that COULD help.  </p>
<p>About the $_SESSION['some_variable'] situation, I&#8217;ve seen this. It goes like this: you have a login page and the user does an sql injection with your form. User input verification is not properly done and it validates. $_SESSION['some variable'] gets from false to true. All subsequent pages verify if the session variable is true and if it is grants access. So you have access to all pages even though you didn&#8217;t had a user. I repeat, I&#8217;ve seen  this on live websites.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

