<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Quatre Bornes - Town Portal &#187; PHP &#8211; MySQL</title>
	<atom:link href="http://www.quatre-bornes.com/category/technology/php-mysql/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.quatre-bornes.com</link>
	<description>Town portal in Mauritius</description>
	<lastBuildDate>Mon, 30 Jan 2012 03:52:20 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
		<item>
		<title>Storing your website inside your database</title>
		<link>http://www.quatre-bornes.com/technology/php-mysql/storing-your-website-inside-your-database/</link>
		<comments>http://www.quatre-bornes.com/technology/php-mysql/storing-your-website-inside-your-database/#comments</comments>
		<pubDate>Thu, 04 Feb 2010 12:23:16 +0000</pubDate>
		<dc:creator>mysteryminds</dc:creator>
				<category><![CDATA[PHP - MySQL]]></category>
		<category><![CDATA[MySql]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[Website]]></category>

		<guid isPermaLink="false">http://www.quatre-bornes.com/?p=251</guid>
		<description><![CDATA[Have you ever taught its possible to store entire website pattern, even Templating your website was possible. We are here to show you how one could ever save the entire Template or even the complete infrastructure of your processing inside your own MYSQL database. Mysql getting the power to store so much of values and]]></description>
			<content:encoded><![CDATA[<p>Have you ever taught its possible to store entire website pattern, even Templating your website was possible. We are here to show you how one could ever save the entire Template or even the complete infrastructure of your processing inside your own MYSQL database.<span id="more-251"></span></p>
<p>Mysql getting the power to store so much of values and getting more powerful and big brands like  AKA SUN Micro Systems supporting it (Now Part of Oracle Group). Can you ever imagine the power of the small tiny database can store in the values so much there.<br />
So lets start the way we would go about it only from quatre-bornes.com site</p>
<p>HOW YOU CAN SIMPLY STORE YOUR CONTENT INSIDE YOUR DATABASE</p>
<p>You can hold your entire site, both coding and content, in a MySQL Database. Your PHP file then retrieves this information from the database.</p>
<p>To see how really these things which are said in here are possible we are going to build a very simple site with all the information and coding stored in the MySQL database.</p>
<p>Create the Tables</p>
<p>The first thing we need to do is create the database tables to store this information. Since we are making a very simple site we will only make two tables, one for code and one for content. Execute this code to create the database tables:</p>
<p>CREATE TABLE template (template_id INT(4) NOT NULL AUTO_INCREMENT PRIMARY KEY, Head_Open VARCHAR(60), Head_Close VARCHAR(60), Page_End VARCHAR(60), Date VARCHAR(60));</p>
<p>CREATE TABLE content (content_id INT(4) NOT NULL AUTO_INCREMENT PRIMARY KEY, title VARCHAR(60), body MEDIUMBLOB);</p>
<p>Add Some Data</p>
<p>Now we need to add data to the tables. If you were adding information on a regular basis, it might be easiest to add it from a web browser. In our case we will just add it in manually to demonstrate how to retrieve it from the database and use it. Remember if you are adding it from the web, you need to consider addslashes and magic quotes.</p>
<p>INSERT INTO content (title, body) VALUES ( &#8220;MyPage&#8221;, &#8220;This is my sample page, where I will use PHP and MySQL to template my website. &lt;p&gt; Here is a list of things I like &lt;ul&gt;&lt;li&gt;PHP Code&lt;/li&gt;&lt;li&gt;MySQL&lt;/li&gt;&lt;li&gt;</p>
<p>&lt;a href=http://www.quatre-bornes.com&gt;PHP at quatre-bornes.com&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt; That is the end of my content.&#8221;) ;</p>
<p>INSERT INTO template (Head_Open, Head_Close, Page_End, Date) VALUES ( &#8220;&lt;html&gt;&lt;head&gt;&lt;title&gt;&#8221;, &#8220;&lt;/title&gt;&lt;body&gt;&#8221;, &#8220;&lt;/body&gt;&lt;/html&gt;&#8221;, &#8220;$b = time (); print date(&#8216;m/d/y&#8217;,$b) . &#8216;&lt;br&gt;&#8217;;&#8221;);</p>
<p>We can make additional pages simply by adding additional rows to the table called content. Likewise, we could make additional templates by adding a new row to the table called template.</p>
<p>Build the Page</p>
<p>Now all we need to do is call this information from our PHP file. We can do that like this:</p>
<p>&lt;?php</p>
<p>// Connects to your Database</p>
<p>mysql_connect(&#8220;your.hostaddress.com&#8221;, &#8220;username&#8221;, &#8220;password&#8221;) or die(mysql_error());</p>
<p>mysql_select_db(&#8220;Database_Name&#8221;) or die(mysql_error());</p>
<p>//This retrieves the template and puts into an array. No where clause is used, because we only have one template in our database.</p>
<p>$coding = mysql_query(&#8220;SELECT * FROM template&#8221;) or die(mysql_error());</p>
<p>$template = mysql_fetch_array( $coding );</p>
<p>//This retrieves the content and puts into an array. Notice we are calling ID 1, this would change if we wanted to call a page stored on a different row</p>
<p>$text = mysql_query(&#8220;SELECT * FROM content WHERE content_id =1&#8243;) or die(mysql_error());</p>
<p>$content = mysql_fetch_array( $text );</p>
<p>//Actually puts the code and content on the page</p>
<p>Print $template['Head_Open'];</p>
<p>Print $content['title'];</p>
<p>Print $template['Head_Close'];</p>
<p>//When pulling PHP code we need to use EVAL</p>
<p>Eval ($template['Date']);</p>
<p>Print $content['body'];</p>
<p>Print $template['Page_End'];</p>
<p>?&gt;</p>
<p>EVAL : Eval () is used to evaluate the input string as PHP. It is like using the Echo () function in the sense that it outputs everything, except instead of outputting it as text, it outputs it as PHP code to be executed. One use of this is to store code in a database to execute later</p>
<p>This method is a very effective way of creating a template based site, or executing different PHP on the fly simply by calling different rows from MySQL.</p>
<!-- Start Sociable --><div class="sociable"><div class="sociable_tagline">Quatre Bornes Town Portal Share</div><ul class='clearfix'><li><a title="Twitter" class="option1_16" style="background-position:-144px -16px" rel="nofollow" target="_blank" href="http://twitter.com/intent/tweet?text=Storing%20your%20website%20inside%20your%20database%20%20-%20http%3A%2F%2Fwww.quatre-bornes.com%2Ftechnology%2Fphp-mysql%2Fstoring-your-website-inside-your-database%2F%20(via%20@sociablesite)"></a></li><li><a title="Facebook" class="option1_16" style="background-position:-48px 0px" rel="nofollow" target="_blank" href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.quatre-bornes.com%2Ftechnology%2Fphp-mysql%2Fstoring-your-website-inside-your-database%2F&amp;t=Storing%20your%20website%20inside%20your%20database%20"></a></li><li><a title="LinkedIn" class="option1_16" style="background-position:-144px 0px" rel="nofollow" target="_blank" href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fwww.quatre-bornes.com%2Ftechnology%2Fphp-mysql%2Fstoring-your-website-inside-your-database%2F&amp;title=Storing%20your%20website%20inside%20your%20database%20&amp;source=Quatre+Bornes+-+Town+Portal+Town+portal+in+Mauritius&amp;summary=Have%20you%20ever%20taught%20its%20possible%20to%20store%20entire%20website%20pattern%2C%20even%20Templating%20your%20website%20was%20possible.%20We%20are%20here%20to%20show%20you%20how%20one%20could%20ever%20save%20the%20entire%20Template%20or%20even%20the%20complete%20infrastructure%20of%20your%20processing%20inside%20your%20own%20M"></a></li><li><a title="StumbleUpon" class="option1_16" style="background-position:-112px -16px" rel="nofollow" target="_blank" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.quatre-bornes.com%2Ftechnology%2Fphp-mysql%2Fstoring-your-website-inside-your-database%2F&title=Storing%20your%20website%20inside%20your%20database%20"></a></li><li><a title="email" class="option1_16" style="background-position:-80px 0px" rel="nofollow" target="_blank" href="https://mail.google.com/mail/?view=cm&fs=1&to&su=Storing%20your%20website%20inside%20your%20database%20&body=http%3A%2F%2Fwww.quatre-bornes.com%2Ftechnology%2Fphp-mysql%2Fstoring-your-website-inside-your-database%2F&ui=2&tf=1&shva=1"></a></li><li><a class="option1_16" style="cursor:pointer;background-position:-64px 0px" rel="nofollow" title="Add to favorites - doesn't work in Chrome"  onClick="javascript:AddToFavorites();"></a></li><li><a title="Delicious" class="option1_16" style="background-position:-16px 0px" rel="nofollow" target="_blank" href="http://delicious.com/post?url=http%3A%2F%2Fwww.quatre-bornes.com%2Ftechnology%2Fphp-mysql%2Fstoring-your-website-inside-your-database%2F&amp;title=Storing%20your%20website%20inside%20your%20database%20&amp;notes=Have%20you%20ever%20taught%20its%20possible%20to%20store%20entire%20website%20pattern%2C%20even%20Templating%20your%20website%20was%20possible.%20We%20are%20here%20to%20show%20you%20how%20one%20could%20ever%20save%20the%20entire%20Template%20or%20even%20the%20complete%20infrastructure%20of%20your%20processing%20inside%20your%20own%20M"></a></li><li><a title="Google Reader" class="option1_16" style="background-position:-112px 0px" rel="nofollow" target="_blank" href="http://www.google.com/reader/link?url=http%3A%2F%2Fwww.quatre-bornes.com%2Ftechnology%2Fphp-mysql%2Fstoring-your-website-inside-your-database%2F&amp;title=Storing%20your%20website%20inside%20your%20database%20&amp;srcURL=http%3A%2F%2Fwww.quatre-bornes.com%2Ftechnology%2Fphp-mysql%2Fstoring-your-website-inside-your-database%2F&amp;srcTitle=Quatre+Bornes+-+Town+Portal+Town+portal+in+Mauritius"></a></li><li><a title="BlinkList" class="option1_16" style="background-position:0px 0px" rel="nofollow" target="_blank" href="http://www.blinklist.com/index.php?Action=Blink/addblink.php&amp;Url=http%3A%2F%2Fwww.quatre-bornes.com%2Ftechnology%2Fphp-mysql%2Fstoring-your-website-inside-your-database%2F&amp;Title=Storing%20your%20website%20inside%20your%20database%20"></a></li><li><a title="Digg" class="option1_16" style="background-position:-32px 0px" rel="nofollow" target="_blank" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.quatre-bornes.com%2Ftechnology%2Fphp-mysql%2Fstoring-your-website-inside-your-database%2F&amp;title=Storing%20your%20website%20inside%20your%20database%20&amp;bodytext=Have%20you%20ever%20taught%20its%20possible%20to%20store%20entire%20website%20pattern%2C%20even%20Templating%20your%20website%20was%20possible.%20We%20are%20here%20to%20show%20you%20how%20one%20could%20ever%20save%20the%20entire%20Template%20or%20even%20the%20complete%20infrastructure%20of%20your%20processing%20inside%20your%20own%20M"></a></li><li><a title="Google Bookmarks" class="option1_16" style="background-position:-96px 0px" rel="nofollow" target="_blank" href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.quatre-bornes.com%2Ftechnology%2Fphp-mysql%2Fstoring-your-website-inside-your-database%2F&amp;title=Storing%20your%20website%20inside%20your%20database%20&amp;annotation=Have%20you%20ever%20taught%20its%20possible%20to%20store%20entire%20website%20pattern%2C%20even%20Templating%20your%20website%20was%20possible.%20We%20are%20here%20to%20show%20you%20how%20one%20could%20ever%20save%20the%20entire%20Template%20or%20even%20the%20complete%20infrastructure%20of%20your%20processing%20inside%20your%20own%20M"></a></li><li><a style="cursor:pointer" rel="nofollow" onMouseOut="fixOnMouseOut(document.getElementById('sociable-post-251'), event, 'post-251')" onMouseOver="more(this,'post-251')"><img style='padding-top: 0;margin-top:-2px' src='http://www.quatre-bornes.com/wp-content/plugins/sociable/images/more.png'></a></li></ul><div onMouseout="fixOnMouseOut(this,event,'post-251')" id="sociable-post-251" style="display:none;">   

    <div style="top: auto; left: auto; display: block;" id="sociable">



		<div class="popup">

			<div class="content">

				<ul><li style="heigth:16px;width:16px"><a title="Myspace" class="option1_16" style="background-position:0px -16px" rel="nofollow" target="_blank" href="http://www.myspace.com/Modules/PostTo/Pages/?u=http%3A%2F%2Fwww.quatre-bornes.com%2Ftechnology%2Fphp-mysql%2Fstoring-your-website-inside-your-database%2F&amp;t=Storing%20your%20website%20inside%20your%20database%20"></a></li><li style="heigth:16px;width:16px"><a title="Reddit" class="option1_16" style="background-position:-64px -16px" rel="nofollow" target="_blank" href="http://reddit.com/submit?url=http%3A%2F%2Fwww.quatre-bornes.com%2Ftechnology%2Fphp-mysql%2Fstoring-your-website-inside-your-database%2F&amp;title=Storing%20your%20website%20inside%20your%20database%20"></a></li><li style="heigth:16px;width:16px"><a title="HackerNews" class="option1_16" style="background-position:-128px 0px" rel="nofollow" target="_blank" href="http://news.ycombinator.com/submitlink?u=http%3A%2F%2Fwww.quatre-bornes.com%2Ftechnology%2Fphp-mysql%2Fstoring-your-website-inside-your-database%2F&amp;t=Storing%20your%20website%20inside%20your%20database%20"></a></li><li style="heigth:16px;width:16px"><a title="MSNReporter" class="option1_16" style="background-position:-176px 0px" rel="nofollow" target="_blank" href="http://reporter.es.msn.com/?fn=contribute&amp;Title=Storing%20your%20website%20inside%20your%20database%20&amp;URL=http%3A%2F%2Fwww.quatre-bornes.com%2Ftechnology%2Fphp-mysql%2Fstoring-your-website-inside-your-database%2F&amp;cat_id=6&amp;tag_id=31&amp;Remark=Have%20you%20ever%20taught%20its%20possible%20to%20store%20entire%20website%20pattern%2C%20even%20Templating%20your%20website%20was%20possible.%20We%20are%20here%20to%20show%20you%20how%20one%20could%20ever%20save%20the%20entire%20Template%20or%20even%20the%20complete%20infrastructure%20of%20your%20processing%20inside%20your%20own%20M"></a></li><li style="heigth:16px;width:16px"><a title="Sphinn" class="option1_16" style="background-position:-96px -16px" rel="nofollow" target="_blank" href="http://sphinn.com/index.php?c=post&amp;m=submit&amp;link=http%3A%2F%2Fwww.quatre-bornes.com%2Ftechnology%2Fphp-mysql%2Fstoring-your-website-inside-your-database%2F"></a></li><li style="heigth:16px;width:16px"><a title="Posterous" class="option1_16" style="background-position:-32px -16px" rel="nofollow" target="_blank" href="http://posterous.com/share?linkto=http%3A%2F%2Fwww.quatre-bornes.com%2Ftechnology%2Fphp-mysql%2Fstoring-your-website-inside-your-database%2F&amp;title=Storing%20your%20website%20inside%20your%20database%20&amp;selection=Have%20you%20ever%20taught%20its%20possible%20to%20store%20entire%20website%20pattern%2C%20even%20Templating%20your%20website%20was%20possible.%20We%20are%20here%20to%20show%20you%20how%20one%20could%20ever%20save%20the%20entire%20Template%20or%20even%20the%20complete%20infrastructure%20of%20your%20processing%20inside%20your%20own%20M"></a></li><li style="heigth:16px;width:16px"><a title="Tumblr" class="option1_16" style="background-position:-128px -16px" rel="nofollow" target="_blank" href="http://www.tumblr.com/share?v=3&amp;u=http%3A%2F%2Fwww.quatre-bornes.com%2Ftechnology%2Fphp-mysql%2Fstoring-your-website-inside-your-database%2F&amp;t=Storing%20your%20website%20inside%20your%20database%20&amp;s=Have%20you%20ever%20taught%20its%20possible%20to%20store%20entire%20website%20pattern%2C%20even%20Templating%20your%20website%20was%20possible.%20We%20are%20here%20to%20show%20you%20how%20one%20could%20ever%20save%20the%20entire%20Template%20or%20even%20the%20complete%20infrastructure%20of%20your%20processing%20inside%20your%20own%20M"></a></li></ul>			

			</div>        

		  <a style="cursor:pointer" onclick="hide_sociable('post-251',true)" class="close">



		  <img onclick="hide_sociable('post-251',true)" title="close" src="http://www.quatre-bornes.com/wp-content/plugins/sociable/images/closelabel.png">

		  </a>

		</div>

	</div> 

  </div></div><div class='sociable' style='float:none'><ul class='clearfix'><li id="Google_p"><g:plusone annotation="bubble" href="http://www.quatre-bornes.com/technology/php-mysql/storing-your-website-inside-your-database/" size="medium"></g:plusone></li><li id="Facebook_Counter"><iframe src="//www.facebook.com/plugins/like.php?href=http://www.quatre-bornes.com/technology/php-mysql/storing-your-website-inside-your-database/&send=false&layout=button_count&show_faces=false&action=like&colorscheme=light&font" scrolling="no" frameborder="0" style="border:none; overflow:hidden;height:32px;width:100px" allowTransparency="true"></iframe></li><li id="Twitter_Counter"><a href="https://twitter.com/share" data-text="Storing your website inside your database  - http://www.quatre-bornes.com/technology/php-mysql/storing-your-website-inside-your-database/ (via #sociablesite)" data-url="http://www.quatre-bornes.com/technology/php-mysql/storing-your-website-inside-your-database/" class="twitter-share-button" data-count="horizontal">Tweet</a><script type="text/javascript" src="//platform.twitter.com/widgets.js"></script></li><li id="LinkedIn_Counter"><script src="http://platform.linkedin.com/in.js" type="text/javascript"></script><script type="IN/Share" data-url="http://www.quatre-bornes.com/technology/php-mysql/storing-your-website-inside-your-database/" data-counter="right"></script></li><li id="StumbleUpon_Counter"><script src="http://www.stumbleupon.com/hostedbadge.php?s=2&r=http://www.quatre-bornes.com/technology/php-mysql/storing-your-website-inside-your-database/"></script></li><li id="Digg_Counter"><script type='text/javascript'>(function() {var s = document.createElement('SCRIPT'), s1 = document.getElementsByTagName('SCRIPT')[0];s.type = 'text/javascript';s.async = true;s.src = 'http://widgets.digg.com/buttons.js';s1.parentNode.insertBefore(s, s1);})();</script><a href='http://digg.com/submit?url=http%3A%2F%2Fwww.quatre-bornes.com%2Ftechnology%2Fphp-mysql%2Fstoring-your-website-inside-your-database%2F&amp;title=Storing%20your%20website%20inside%20your%20database%20'  class='DiggThisButton DiggCompact'></a></li></ul></div><!-- End Sociable -->]]></content:encoded>
			<wfw:commentRss>http://www.quatre-bornes.com/technology/php-mysql/storing-your-website-inside-your-database/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Learning PHP login Script &#8211; Quatre Bornes Portal</title>
		<link>http://www.quatre-bornes.com/technology/php-mysql/learning-php-login-script-quatre-bornes-portal/</link>
		<comments>http://www.quatre-bornes.com/technology/php-mysql/learning-php-login-script-quatre-bornes-portal/#comments</comments>
		<pubDate>Thu, 04 Feb 2010 12:17:30 +0000</pubDate>
		<dc:creator>mysteryminds</dc:creator>
				<category><![CDATA[PHP - MySQL]]></category>
		<category><![CDATA[MySql]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Portal]]></category>
		<category><![CDATA[Quatre Bornes]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[Website]]></category>

		<guid isPermaLink="false">http://www.quatre-bornes.com/?p=249</guid>
		<description><![CDATA[As we all know the world of IT is changing so drastic, and in very very near future, there will be no one to buy the package solutions, but there would be mostly online &#8220;Cloud Computing&#8221;  -  Open Source Solutions which is going to dominate. So if you are interested in learning something informative which]]></description>
			<content:encoded><![CDATA[<p>As we all know the world of IT is changing so drastic, and in very very near future, there will be no one to buy the package solutions, but there would be mostly online &#8220;Cloud Computing&#8221;  -  Open Source Solutions which is going to dominate. So if you are interested in learning something informative which might help your future. Please do follow our sections where it will guide you how to start and where to start.<span id="more-249"></span></p>
<p>We are going to create a simple login system using PHP code on our pages, and a MySQL database to store our users information. We will track the users who are logged in with COOKIES.</p>
<p>Before we can create a login script, we first need to create a database to store users. For the purpose of this tutorial we will simply need the fields &#8220;username&#8221; and &#8220;password&#8221;, however you can create as many fields as you wish.</p>
<p>CREATE TABLE users (ID MEDIUMINT NOT NULL AUTO_INCREMENT PRIMARY KEY, username VARCHAR(60), password VARCHAR(60))</p>
<p>This will create a database called users with 3 fields: ID, username, and password.</p>
<p><strong>REGISTRATION PAGE</strong></p>
<p>&lt;?php</p>
<p>// Connects to your Database or Simply include your existing database connection as a include file</p>
<p>mysql_connect(&#8220;your.hostaddress.com&#8221;, &#8220;username&#8221;, &#8220;password&#8221;) or die(mysql_error());</p>
<p>mysql_select_db(&#8220;Database_Name&#8221;) or die(mysql_error());</p>
<p>//This code runs if the form has been submitted</p>
<p>if (isset($_POST['submit'])) {</p>
<p>//This makes sure they did not leave any fields blank</p>
<p>if (!$_POST['username'] | !$_POST['pass'] | !$_POST['pass2'] ) {</p>
<p>die(&#8216;You did not complete all of the required fields&#8217;);</p>
<p>}</p>
<p>// checks if the username is in use</p>
<p>if (!get_magic_quotes_gpc()) {</p>
<p>$_POST['username'] = addslashes($_POST['username']);</p>
<p>}</p>
<p>$usercheck = $_POST['username'];</p>
<p>$check = mysql_query(&#8220;SELECT username FROM users WHERE username = &#8216;$usercheck&#8217;&#8221;)</p>
<p>or die(mysql_error());</p>
<p>$check2 = mysql_num_rows($check);</p>
<p>//if the name exists it gives an error</p>
<p>if ($check2 != 0) {</p>
<p>die(&#8216;Sorry, the username &#8216;.$_POST['username'].&#8217; is already in use.&#8217;);</p>
<p>}</p>
<p>// this makes sure both passwords entered match</p>
<p>if ($_POST['pass'] != $_POST['pass2']) {</p>
<p>die(&#8216;Your passwords did not match. &#8216;);</p>
<p>}</p>
<p>// here we encrypt the password and add slashes if needed</p>
<p>$_POST['pass'] = md5($_POST['pass']);</p>
<p>if (!get_magic_quotes_gpc()) {</p>
<p>$_POST['pass'] = addslashes($_POST['pass']);</p>
<p>$_POST['username'] = addslashes($_POST['username']);</p>
<p>}</p>
<p>// now we insert it into the database</p>
<p>$insert = &#8220;INSERT INTO users (username, password)</p>
<p>VALUES (&#8216;&#8221;.$_POST['username'].&#8221;&#8216;, &#8216;&#8221;.$_POST['pass'].&#8221;&#8216;)&#8221;;</p>
<p>$add_member = mysql_query($insert);</p>
<p>?&gt;</p>
<p>&lt;h1&gt;Registered&lt;/h1&gt;</p>
<p>&lt;p&gt;Thank you, you have registered &#8211; you may now login&lt;/a&gt;.&lt;/p&gt;</p>
<p>&lt;?php</p>
<p>}</p>
<p>else</p>
<p>{</p>
<p>?&gt;</p>
<p>&lt;form action=&#8221;&lt;?php echo $_SERVER['PHP_SELF']; ?&gt;&#8221; method=&#8221;post&#8221;&gt;</p>
<p>&lt;table border=&#8221;0&#8243;&gt;</p>
<p>&lt;tr&gt;&lt;td&gt;Username:&lt;/td&gt;&lt;td&gt;</p>
<p>&lt;input type=&#8221;text&#8221; name=&#8221;username&#8221; maxlength=&#8221;60&#8243;&gt;</p>
<p>&lt;/td&gt;&lt;/tr&gt;</p>
<p>&lt;tr&gt;&lt;td&gt;Password:&lt;/td&gt;&lt;td&gt;</p>
<p>&lt;input type=&#8221;password&#8221; name=&#8221;pass&#8221; maxlength=&#8221;10&#8243;&gt;</p>
<p>&lt;/td&gt;&lt;/tr&gt;</p>
<p>&lt;tr&gt;&lt;td&gt;Confirm Password:&lt;/td&gt;&lt;td&gt;</p>
<p>&lt;input type=&#8221;password&#8221; name=&#8221;pass2&#8243; maxlength=&#8221;10&#8243;&gt;</p>
<p>&lt;/td&gt;&lt;/tr&gt;</p>
<p>&lt;tr&gt;&lt;th colspan=2&gt;&lt;input type=&#8221;submit&#8221; name=&#8221;submit&#8221; value=&#8221;Register&#8221;&gt;&lt;/th&gt;&lt;/tr&gt; &lt;/table&gt;</p>
<p>&lt;/form&gt;</p>
<p>&lt;?php</p>
<p>}</p>
<p>?&gt;</p>
<p>Basically what this does is check to see if the form has been submitted. If it has been submitted it checks to make sure that the data is all OK (passwords match, username isn&#8217;t in use) as documented in the code. If everything is OK it adds the user to the database, if not it returns the error.</p>
<p>If the form has not been submitted, they are shown the registration form, which collects the username and password.</p>
<p>&lt;?php</p>
<p>// Connects to your Database</p>
<p>mysql_connect(&#8220;your.hostaddress.com&#8221;, &#8220;username&#8221;, &#8220;password&#8221;) or die(mysql_error());</p>
<p>mysql_select_db(&#8220;Database_Name&#8221;) or die(mysql_error());</p>
<p>//Checks if there is a login cookie</p>
<p>if(isset($_COOKIE['ID_my_site']))</p>
<p>//if there is, it logs you in and directes you to the members page</p>
<p>{</p>
<p>$username = $_COOKIE['ID_my_site'];</p>
<p>$pass = $_COOKIE['Key_my_site'];</p>
<p>$check = mysql_query(&#8220;SELECT * FROM users WHERE username = &#8216;$username&#8217;&#8221;)or die(mysql_error());</p>
<p>while($info = mysql_fetch_array( $check ))</p>
<p>{</p>
<p>if ($pass != $info['password'])</p>
<p>{</p>
<p>}</p>
<p>else</p>
<p>{</p>
<p>header(&#8220;Location: members.php&#8221;);</p>
<p>//here its redirecting you to the members.php page</p>
<p>}</p>
<p>}</p>
<p>}</p>
<p>//if the login form is submitted</p>
<p>if (isset($_POST['submit'])) { // if form has been submitted</p>
<p>// makes sure they filled it in</p>
<p>if(!$_POST['username'] | !$_POST['pass']) {</p>
<p>die(&#8216;You did not fill in a required field.&#8217;);</p>
<p>}</p>
<p>// checks it against the database</p>
<p>if (!get_magic_quotes_gpc()) {</p>
<p>$_POST['email'] = addslashes($_POST['email']);</p>
<p>}</p>
<p>$check = mysql_query(&#8220;SELECT * FROM users WHERE username = &#8216;&#8221;.$_POST['username'].&#8221;&#8216;&#8221;)or die(mysql_error());</p>
<p>//Gives error if user dosen&#8217;t exist</p>
<p>$check2 = mysql_num_rows($check);</p>
<p>if ($check2 == 0) {</p>
<p>die(&#8216;That user does not exist in our database. &lt;a href=add.php&gt;Click Here to Register&lt;/a&gt;&#8217;);</p>
<p>}</p>
<p>while($info = mysql_fetch_array( $check ))</p>
<p>{</p>
<p>$_POST['pass'] = stripslashes($_POST['pass']);</p>
<p>$info['password'] = stripslashes($info['password']);</p>
<p>$_POST['pass'] = md5($_POST['pass']);</p>
<p>//gives error if the password is wrong</p>
<p>if ($_POST['pass'] != $info['password']) {</p>
<p>die(&#8216;Incorrect password, please try again.&#8217;);</p>
<p>}</p>
<p>else</p>
<p>{</p>
<p>// if login is ok then we add a cookie</p>
<p>$_POST['username'] = stripslashes($_POST['username']);</p>
<p>$hour = time() + 3600;</p>
<p>setcookie(ID_my_site, $_POST['username'], $hour);</p>
<p>setcookie(Key_my_site, $_POST['pass'], $hour);</p>
<p>//then redirect them to the members area</p>
<p>header(&#8220;Location: members.php&#8221;);</p>
<p>}</p>
<p>}</p>
<p>}</p>
<p>else</p>
<p>{</p>
<p>// if they are not logged in</p>
<p>?&gt;</p>
<p>&lt;form action=&#8221;&lt;?php echo $_SERVER['PHP_SELF']?&gt;&#8221; method=&#8221;post&#8221;&gt;</p>
<p>&lt;table border=&#8221;0&#8243;&gt;</p>
<p>&lt;tr&gt;&lt;td colspan=2&gt;&lt;h1&gt;Login&lt;/h1&gt;&lt;/td&gt;&lt;/tr&gt;</p>
<p>&lt;tr&gt;&lt;td&gt;Username:&lt;/td&gt;&lt;td&gt;</p>
<p>&lt;input type=&#8221;text&#8221; name=&#8221;username&#8221; maxlength=&#8221;40&#8243;&gt;</p>
<p>&lt;/td&gt;&lt;/tr&gt;</p>
<p>&lt;tr&gt;&lt;td&gt;Password:&lt;/td&gt;&lt;td&gt;</p>
<p>&lt;input type=&#8221;password&#8221; name=&#8221;pass&#8221; maxlength=&#8221;50&#8243;&gt;</p>
<p>&lt;/td&gt;&lt;/tr&gt;</p>
<p>&lt;tr&gt;&lt;td colspan=&#8221;2&#8243; align=&#8221;right&#8221;&gt;</p>
<p>&lt;input type=&#8221;submit&#8221; name=&#8221;submit&#8221; value=&#8221;Login&#8221;&gt;</p>
<p>&lt;/td&gt;&lt;/tr&gt;</p>
<p>&lt;/table&gt;</p>
<p>&lt;/form&gt;</p>
<p>&lt;?php</p>
<p>}</p>
<p>?&gt;</p>
<p>This script first checks to see if the login information is contained in a cookie on the users computer. If it is, it tries to log them in. If this is successful they are redirected to the members area.</p>
<p>If there is no cookie, it allows them to login. If the form has been submitted, it checks it against the database and if it was successful sets a cookie and takes them to the members area. If it has not been submitted, it shows them the login form.</p>
<p>&lt;?php</p>
<p>// Connects to your Database</p>
<p>mysql_connect(&#8220;your.hostaddress.com&#8221;, &#8220;username&#8221;, &#8220;password&#8221;) or die(mysql_error());</p>
<p>mysql_select_db(&#8220;Database_Name&#8221;) or die(mysql_error());</p>
<p>//checks cookies to make sure they are logged in</p>
<p>if(isset($_COOKIE['ID_my_site']))</p>
<p>{</p>
<p>$username = $_COOKIE['ID_my_site'];</p>
<p>$pass = $_COOKIE['Key_my_site'];</p>
<p>$check = mysql_query(&#8220;SELECT * FROM users WHERE username = &#8216;$username&#8217;&#8221;)or die(mysql_error());</p>
<p>while($info = mysql_fetch_array( $check ))</p>
<p>{</p>
<p>//if the cookie has the wrong password, they are taken to the login page</p>
<p>if ($pass != $info['password'])</p>
<p>{ header(&#8220;Location: login.php&#8221;);</p>
<p>}</p>
<p>//otherwise they are shown the admin area</p>
<p>else</p>
<p>{</p>
<p>echo &#8220;Admin Area&lt;p&gt;&#8221;;</p>
<p>echo &#8220;Your Content&lt;p&gt;&#8221;;</p>
<p>echo &#8220;&lt;a href=logout.php&gt;Logout&lt;/a&gt;&#8221;;</p>
<p>}</p>
<p>}</p>
<p>}</p>
<p>else</p>
<p>//if the cookie does not exist, they are taken to the login screen</p>
<p>{</p>
<p>header(&#8220;Location: login.php&#8221;);</p>
<p>}</p>
<p>?&gt;</p>
<p>This code checks cookies to make sure the user is logged in, the same way the login page did. If they are logged in, they are shown the members area. If they are not logged in they are redirected to the login page.</p>
<p>&lt;?php</p>
<p>$past = time() &#8211; 100;</p>
<p>//this makes the time in the past to destroy the cookie</p>
<p>setcookie(ID_my_site, gone, $past);</p>
<p>setcookie(Key_my_site, gone, $past);</p>
<p>header(&#8220;Location: login.php&#8221;);</p>
<p>?&gt;</p>
<p>All our logout page does is destroy the cookie, and then direct them back to the login page. We destroy the cookie by setting the expiration to some time in the past.</p>
<!-- Start Sociable --><div class="sociable"><div class="sociable_tagline">Quatre Bornes Town Portal Share</div><ul class='clearfix'><li><a title="Twitter" class="option1_16" style="background-position:-144px -16px" rel="nofollow" target="_blank" href="http://twitter.com/intent/tweet?text=Learning%20PHP%20login%20Script%20-%20Quatre%20Bornes%20Portal%20-%20http%3A%2F%2Fwww.quatre-bornes.com%2Ftechnology%2Fphp-mysql%2Flearning-php-login-script-quatre-bornes-portal%2F%20(via%20@sociablesite)"></a></li><li><a title="Facebook" class="option1_16" style="background-position:-48px 0px" rel="nofollow" target="_blank" href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.quatre-bornes.com%2Ftechnology%2Fphp-mysql%2Flearning-php-login-script-quatre-bornes-portal%2F&amp;t=Learning%20PHP%20login%20Script%20-%20Quatre%20Bornes%20Portal"></a></li><li><a title="LinkedIn" class="option1_16" style="background-position:-144px 0px" rel="nofollow" target="_blank" href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fwww.quatre-bornes.com%2Ftechnology%2Fphp-mysql%2Flearning-php-login-script-quatre-bornes-portal%2F&amp;title=Learning%20PHP%20login%20Script%20-%20Quatre%20Bornes%20Portal&amp;source=Quatre+Bornes+-+Town+Portal+Town+portal+in+Mauritius&amp;summary=As%20we%20all%20know%20the%20world%20of%20IT%20is%20changing%20so%20drastic%2C%20and%20in%20very%20very%20near%20future%2C%20there%20will%20be%20no%20one%20to%20buy%20the%20package%20solutions%2C%20but%20there%20would%20be%20mostly%20online%20%22Cloud%20Computing%22%20%C2%A0-%20%C2%A0Open%20Source%20Solutions%20which%20is%20going%20to%20dominate.%20So%20if%20y"></a></li><li><a title="StumbleUpon" class="option1_16" style="background-position:-112px -16px" rel="nofollow" target="_blank" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.quatre-bornes.com%2Ftechnology%2Fphp-mysql%2Flearning-php-login-script-quatre-bornes-portal%2F&title=Learning%20PHP%20login%20Script%20-%20Quatre%20Bornes%20Portal"></a></li><li><a title="email" class="option1_16" style="background-position:-80px 0px" rel="nofollow" target="_blank" href="https://mail.google.com/mail/?view=cm&fs=1&to&su=Learning%20PHP%20login%20Script%20-%20Quatre%20Bornes%20Portal&body=http%3A%2F%2Fwww.quatre-bornes.com%2Ftechnology%2Fphp-mysql%2Flearning-php-login-script-quatre-bornes-portal%2F&ui=2&tf=1&shva=1"></a></li><li><a class="option1_16" style="cursor:pointer;background-position:-64px 0px" rel="nofollow" title="Add to favorites - doesn't work in Chrome"  onClick="javascript:AddToFavorites();"></a></li><li><a title="Delicious" class="option1_16" style="background-position:-16px 0px" rel="nofollow" target="_blank" href="http://delicious.com/post?url=http%3A%2F%2Fwww.quatre-bornes.com%2Ftechnology%2Fphp-mysql%2Flearning-php-login-script-quatre-bornes-portal%2F&amp;title=Learning%20PHP%20login%20Script%20-%20Quatre%20Bornes%20Portal&amp;notes=As%20we%20all%20know%20the%20world%20of%20IT%20is%20changing%20so%20drastic%2C%20and%20in%20very%20very%20near%20future%2C%20there%20will%20be%20no%20one%20to%20buy%20the%20package%20solutions%2C%20but%20there%20would%20be%20mostly%20online%20%22Cloud%20Computing%22%20%C2%A0-%20%C2%A0Open%20Source%20Solutions%20which%20is%20going%20to%20dominate.%20So%20if%20y"></a></li><li><a title="Google Reader" class="option1_16" style="background-position:-112px 0px" rel="nofollow" target="_blank" href="http://www.google.com/reader/link?url=http%3A%2F%2Fwww.quatre-bornes.com%2Ftechnology%2Fphp-mysql%2Flearning-php-login-script-quatre-bornes-portal%2F&amp;title=Learning%20PHP%20login%20Script%20-%20Quatre%20Bornes%20Portal&amp;srcURL=http%3A%2F%2Fwww.quatre-bornes.com%2Ftechnology%2Fphp-mysql%2Flearning-php-login-script-quatre-bornes-portal%2F&amp;srcTitle=Quatre+Bornes+-+Town+Portal+Town+portal+in+Mauritius"></a></li><li><a title="BlinkList" class="option1_16" style="background-position:0px 0px" rel="nofollow" target="_blank" href="http://www.blinklist.com/index.php?Action=Blink/addblink.php&amp;Url=http%3A%2F%2Fwww.quatre-bornes.com%2Ftechnology%2Fphp-mysql%2Flearning-php-login-script-quatre-bornes-portal%2F&amp;Title=Learning%20PHP%20login%20Script%20-%20Quatre%20Bornes%20Portal"></a></li><li><a title="Digg" class="option1_16" style="background-position:-32px 0px" rel="nofollow" target="_blank" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.quatre-bornes.com%2Ftechnology%2Fphp-mysql%2Flearning-php-login-script-quatre-bornes-portal%2F&amp;title=Learning%20PHP%20login%20Script%20-%20Quatre%20Bornes%20Portal&amp;bodytext=As%20we%20all%20know%20the%20world%20of%20IT%20is%20changing%20so%20drastic%2C%20and%20in%20very%20very%20near%20future%2C%20there%20will%20be%20no%20one%20to%20buy%20the%20package%20solutions%2C%20but%20there%20would%20be%20mostly%20online%20%22Cloud%20Computing%22%20%C2%A0-%20%C2%A0Open%20Source%20Solutions%20which%20is%20going%20to%20dominate.%20So%20if%20y"></a></li><li><a title="Google Bookmarks" class="option1_16" style="background-position:-96px 0px" rel="nofollow" target="_blank" href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.quatre-bornes.com%2Ftechnology%2Fphp-mysql%2Flearning-php-login-script-quatre-bornes-portal%2F&amp;title=Learning%20PHP%20login%20Script%20-%20Quatre%20Bornes%20Portal&amp;annotation=As%20we%20all%20know%20the%20world%20of%20IT%20is%20changing%20so%20drastic%2C%20and%20in%20very%20very%20near%20future%2C%20there%20will%20be%20no%20one%20to%20buy%20the%20package%20solutions%2C%20but%20there%20would%20be%20mostly%20online%20%22Cloud%20Computing%22%20%C2%A0-%20%C2%A0Open%20Source%20Solutions%20which%20is%20going%20to%20dominate.%20So%20if%20y"></a></li><li><a style="cursor:pointer" rel="nofollow" onMouseOut="fixOnMouseOut(document.getElementById('sociable-post-249'), event, 'post-249')" onMouseOver="more(this,'post-249')"><img style='padding-top: 0;margin-top:-2px' src='http://www.quatre-bornes.com/wp-content/plugins/sociable/images/more.png'></a></li></ul><div onMouseout="fixOnMouseOut(this,event,'post-249')" id="sociable-post-249" style="display:none;">   

    <div style="top: auto; left: auto; display: block;" id="sociable">



		<div class="popup">

			<div class="content">

				<ul><li style="heigth:16px;width:16px"><a title="Myspace" class="option1_16" style="background-position:0px -16px" rel="nofollow" target="_blank" href="http://www.myspace.com/Modules/PostTo/Pages/?u=http%3A%2F%2Fwww.quatre-bornes.com%2Ftechnology%2Fphp-mysql%2Flearning-php-login-script-quatre-bornes-portal%2F&amp;t=Learning%20PHP%20login%20Script%20-%20Quatre%20Bornes%20Portal"></a></li><li style="heigth:16px;width:16px"><a title="Reddit" class="option1_16" style="background-position:-64px -16px" rel="nofollow" target="_blank" href="http://reddit.com/submit?url=http%3A%2F%2Fwww.quatre-bornes.com%2Ftechnology%2Fphp-mysql%2Flearning-php-login-script-quatre-bornes-portal%2F&amp;title=Learning%20PHP%20login%20Script%20-%20Quatre%20Bornes%20Portal"></a></li><li style="heigth:16px;width:16px"><a title="HackerNews" class="option1_16" style="background-position:-128px 0px" rel="nofollow" target="_blank" href="http://news.ycombinator.com/submitlink?u=http%3A%2F%2Fwww.quatre-bornes.com%2Ftechnology%2Fphp-mysql%2Flearning-php-login-script-quatre-bornes-portal%2F&amp;t=Learning%20PHP%20login%20Script%20-%20Quatre%20Bornes%20Portal"></a></li><li style="heigth:16px;width:16px"><a title="MSNReporter" class="option1_16" style="background-position:-176px 0px" rel="nofollow" target="_blank" href="http://reporter.es.msn.com/?fn=contribute&amp;Title=Learning%20PHP%20login%20Script%20-%20Quatre%20Bornes%20Portal&amp;URL=http%3A%2F%2Fwww.quatre-bornes.com%2Ftechnology%2Fphp-mysql%2Flearning-php-login-script-quatre-bornes-portal%2F&amp;cat_id=6&amp;tag_id=31&amp;Remark=As%20we%20all%20know%20the%20world%20of%20IT%20is%20changing%20so%20drastic%2C%20and%20in%20very%20very%20near%20future%2C%20there%20will%20be%20no%20one%20to%20buy%20the%20package%20solutions%2C%20but%20there%20would%20be%20mostly%20online%20%22Cloud%20Computing%22%20%C2%A0-%20%C2%A0Open%20Source%20Solutions%20which%20is%20going%20to%20dominate.%20So%20if%20y"></a></li><li style="heigth:16px;width:16px"><a title="Sphinn" class="option1_16" style="background-position:-96px -16px" rel="nofollow" target="_blank" href="http://sphinn.com/index.php?c=post&amp;m=submit&amp;link=http%3A%2F%2Fwww.quatre-bornes.com%2Ftechnology%2Fphp-mysql%2Flearning-php-login-script-quatre-bornes-portal%2F"></a></li><li style="heigth:16px;width:16px"><a title="Posterous" class="option1_16" style="background-position:-32px -16px" rel="nofollow" target="_blank" href="http://posterous.com/share?linkto=http%3A%2F%2Fwww.quatre-bornes.com%2Ftechnology%2Fphp-mysql%2Flearning-php-login-script-quatre-bornes-portal%2F&amp;title=Learning%20PHP%20login%20Script%20-%20Quatre%20Bornes%20Portal&amp;selection=As%20we%20all%20know%20the%20world%20of%20IT%20is%20changing%20so%20drastic%2C%20and%20in%20very%20very%20near%20future%2C%20there%20will%20be%20no%20one%20to%20buy%20the%20package%20solutions%2C%20but%20there%20would%20be%20mostly%20online%20%22Cloud%20Computing%22%20%C2%A0-%20%C2%A0Open%20Source%20Solutions%20which%20is%20going%20to%20dominate.%20So%20if%20y"></a></li><li style="heigth:16px;width:16px"><a title="Tumblr" class="option1_16" style="background-position:-128px -16px" rel="nofollow" target="_blank" href="http://www.tumblr.com/share?v=3&amp;u=http%3A%2F%2Fwww.quatre-bornes.com%2Ftechnology%2Fphp-mysql%2Flearning-php-login-script-quatre-bornes-portal%2F&amp;t=Learning%20PHP%20login%20Script%20-%20Quatre%20Bornes%20Portal&amp;s=As%20we%20all%20know%20the%20world%20of%20IT%20is%20changing%20so%20drastic%2C%20and%20in%20very%20very%20near%20future%2C%20there%20will%20be%20no%20one%20to%20buy%20the%20package%20solutions%2C%20but%20there%20would%20be%20mostly%20online%20%22Cloud%20Computing%22%20%C2%A0-%20%C2%A0Open%20Source%20Solutions%20which%20is%20going%20to%20dominate.%20So%20if%20y"></a></li></ul>			

			</div>        

		  <a style="cursor:pointer" onclick="hide_sociable('post-249',true)" class="close">



		  <img onclick="hide_sociable('post-249',true)" title="close" src="http://www.quatre-bornes.com/wp-content/plugins/sociable/images/closelabel.png">

		  </a>

		</div>

	</div> 

  </div></div><div class='sociable' style='float:none'><ul class='clearfix'><li id="Google_p"><g:plusone annotation="bubble" href="http://www.quatre-bornes.com/technology/php-mysql/learning-php-login-script-quatre-bornes-portal/" size="medium"></g:plusone></li><li id="Facebook_Counter"><iframe src="//www.facebook.com/plugins/like.php?href=http://www.quatre-bornes.com/technology/php-mysql/learning-php-login-script-quatre-bornes-portal/&send=false&layout=button_count&show_faces=false&action=like&colorscheme=light&font" scrolling="no" frameborder="0" style="border:none; overflow:hidden;height:32px;width:100px" allowTransparency="true"></iframe></li><li id="Twitter_Counter"><a href="https://twitter.com/share" data-text="Learning PHP login Script - Quatre Bornes Portal - http://www.quatre-bornes.com/technology/php-mysql/learning-php-login-script-quatre-bornes-portal/ (via #sociablesite)" data-url="http://www.quatre-bornes.com/technology/php-mysql/learning-php-login-script-quatre-bornes-portal/" class="twitter-share-button" data-count="horizontal">Tweet</a><script type="text/javascript" src="//platform.twitter.com/widgets.js"></script></li><li id="LinkedIn_Counter"><script src="http://platform.linkedin.com/in.js" type="text/javascript"></script><script type="IN/Share" data-url="http://www.quatre-bornes.com/technology/php-mysql/learning-php-login-script-quatre-bornes-portal/" data-counter="right"></script></li><li id="StumbleUpon_Counter"><script src="http://www.stumbleupon.com/hostedbadge.php?s=2&r=http://www.quatre-bornes.com/technology/php-mysql/learning-php-login-script-quatre-bornes-portal/"></script></li><li id="Digg_Counter"><script type='text/javascript'>(function() {var s = document.createElement('SCRIPT'), s1 = document.getElementsByTagName('SCRIPT')[0];s.type = 'text/javascript';s.async = true;s.src = 'http://widgets.digg.com/buttons.js';s1.parentNode.insertBefore(s, s1);})();</script><a href='http://digg.com/submit?url=http%3A%2F%2Fwww.quatre-bornes.com%2Ftechnology%2Fphp-mysql%2Flearning-php-login-script-quatre-bornes-portal%2F&amp;title=Learning%20PHP%20login%20Script%20-%20Quatre%20Bornes%20Portal'  class='DiggThisButton DiggCompact'></a></li></ul></div><!-- End Sociable -->]]></content:encoded>
			<wfw:commentRss>http://www.quatre-bornes.com/technology/php-mysql/learning-php-login-script-quatre-bornes-portal/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to save your Website from security holes</title>
		<link>http://www.quatre-bornes.com/technology/php-mysql/how-to-save-your-website-from-security-holes/</link>
		<comments>http://www.quatre-bornes.com/technology/php-mysql/how-to-save-your-website-from-security-holes/#comments</comments>
		<pubDate>Thu, 23 Jul 2009 05:20:16 +0000</pubDate>
		<dc:creator>mysteryminds</dc:creator>
				<category><![CDATA[PHP - MySQL]]></category>
		<category><![CDATA[Mauritius]]></category>
		<category><![CDATA[MySql]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Portal]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[Website]]></category>

		<guid isPermaLink="false">http://www.quatre-bornes.com/?p=669</guid>
		<description><![CDATA[Hai good Morning everyone! do you know web development, are we talking about web development or web all alone, but anything which ever makes a sense. But you need to understand web technology is something going high and web technology is something of the future. One must understand Web might be fun and web is]]></description>
			<content:encoded><![CDATA[<p>Hai good Morning everyone! do you know web development, are we talking about web development or web all alone, but anything which ever makes a sense. But you need to understand web technology is something going high and web technology is something of the future. One must understand Web might be fun and web is very deadly and dangerous for your business if you don&#8217;t have a knowledge of web solutions. We did come across some hundreds of them who pretend to know the web development without knowing a basic knowledge of plain 1990&#8242;s HTML knowledge.<span id="more-669"></span></p>
<p>All we want to tell them is just concentrate on what you would want to learn better and what you want to achieve, never try to copy the codes of other sites, or templates of other sites and make it your own, coz you are sure that your site is the one which is going to be attacked first! What are we talking about the attack! well yeah they are many ways people would attack your website just for fun, resolution or revolution or revenge. So don&#8217;t be a big fool to do the stupid things and make it a worst nightmare.</p>
<p>List of things we tell to most of them who pretend to know web knowledge is just a simple w3c standard webpage in notepad then we would talk. Be careful if you are using any of the templating system prebuilt like FrontPage, Dreamweaver, Webdev, Web Monkey or what so ever, use them as a structuring but not copy and paste the self driven code, coz they have so many loop holes.  Once your website has been hit by the first time, that literally means some bot is listening to your website (domain) and we guarantee you that they will come back again with different solution to hit you back and welcome to the game.</p>
<p>So lets talk about some of the main causes which would put your website down (Let it be Joomla, WordPress, Drupal, PHPwebsite, Pmachine or what so ever) one small hole leads to the disaster.</p>
<p>List of things to be done in drupal site once you install.</p>
<p>1. Set up the CRON JOBs where necessary and do it right – There is no second option for it, else your site is got to be doomed within few hours.</p>
<p>2. Message MSOffice/cltreq.asp &#8211; Severity warning</p>
<p>Message _vti_bin/owssvr.dll &#8211; Severity warning</p>
<p>3. Check your template with compatibility to the browser events</p>
<p>4. Check every script thoroughly</p>
<p>5. Don’t alias the links if its not necessary</p>
<p>6. Make the Ratios of script without much of Javascript</p>
<p>7. Upload the site in ASCII Mode</p>
<p>8. Don’t work on templates prebuilt or from any softwares locally – they leave way too many loop holes</p>
<p>9. Less of Image links or irregular aliasing for menu options</p>
<p>10.  Looping to be active from Cron and CGI Bin</p>
<p>11. drupal use index.php, instead of index.html, this is configured in the web server. say, inside the httpd.conf file if u are using apache httpd as your web server.  – A wrongly written .htaccess file or misconfiguration can lead to spoofing of your whole site and within minutes.</p>
<p>12. No using of Iframes of scripts which write index frames in the site</p>
<p>13. No copy paste from word to the online editior</p>
<p>14. It is possible that someone used SQL Injection to add JavaScript into the footer, the mission, a node body, etc.  Many Anti Virus programs will identify that as a malicious script in &#8220;index.php&#8221; if you do not have clean urls and use URLs like &#8220;index.php?q=&#8221;   SQL Injection in general is not particularly common in Drupal.</p>
<p>15. As you can see, XSS is the most common issue &#8211; almost covering 50%. Access Bypass, CSRF, SQL Injection, and Code Execution are the next most common making up a about a quarter of the weaknesses.</p>
<p>It&#8217;s important to note that these are only vulnerabilities for which there has been a Security Announcement. Many more exist only on an individual site with improper configuration or a custom module or theme and can never be included in an analysis like this.</p>
<!-- Start Sociable --><div class="sociable"><div class="sociable_tagline">Quatre Bornes Town Portal Share</div><ul class='clearfix'><li><a title="Twitter" class="option1_16" style="background-position:-144px -16px" rel="nofollow" target="_blank" href="http://twitter.com/intent/tweet?text=How%20to%20save%20your%20Website%20from%20security%20holes%20-%20http%3A%2F%2Fwww.quatre-bornes.com%2Ftechnology%2Fphp-mysql%2Fhow-to-save-your-website-from-security-holes%2F%20(via%20@sociablesite)"></a></li><li><a title="Facebook" class="option1_16" style="background-position:-48px 0px" rel="nofollow" target="_blank" href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.quatre-bornes.com%2Ftechnology%2Fphp-mysql%2Fhow-to-save-your-website-from-security-holes%2F&amp;t=How%20to%20save%20your%20Website%20from%20security%20holes"></a></li><li><a title="LinkedIn" class="option1_16" style="background-position:-144px 0px" rel="nofollow" target="_blank" href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fwww.quatre-bornes.com%2Ftechnology%2Fphp-mysql%2Fhow-to-save-your-website-from-security-holes%2F&amp;title=How%20to%20save%20your%20Website%20from%20security%20holes&amp;source=Quatre+Bornes+-+Town+Portal+Town+portal+in+Mauritius&amp;summary=Hai%20good%20Morning%20everyone%21%20do%20you%20know%20web%20development%2C%20are%20we%20talking%20about%20web%20development%20or%20web%20all%20alone%2C%20but%20anything%20which%20ever%20makes%20a%20sense.%20But%20you%20need%20to%20understand%20web%20technology%20is%20something%20going%20high%20and%20web%20technology%20is%20something%20of"></a></li><li><a title="StumbleUpon" class="option1_16" style="background-position:-112px -16px" rel="nofollow" target="_blank" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.quatre-bornes.com%2Ftechnology%2Fphp-mysql%2Fhow-to-save-your-website-from-security-holes%2F&title=How%20to%20save%20your%20Website%20from%20security%20holes"></a></li><li><a title="email" class="option1_16" style="background-position:-80px 0px" rel="nofollow" target="_blank" href="https://mail.google.com/mail/?view=cm&fs=1&to&su=How%20to%20save%20your%20Website%20from%20security%20holes&body=http%3A%2F%2Fwww.quatre-bornes.com%2Ftechnology%2Fphp-mysql%2Fhow-to-save-your-website-from-security-holes%2F&ui=2&tf=1&shva=1"></a></li><li><a class="option1_16" style="cursor:pointer;background-position:-64px 0px" rel="nofollow" title="Add to favorites - doesn't work in Chrome"  onClick="javascript:AddToFavorites();"></a></li><li><a title="Delicious" class="option1_16" style="background-position:-16px 0px" rel="nofollow" target="_blank" href="http://delicious.com/post?url=http%3A%2F%2Fwww.quatre-bornes.com%2Ftechnology%2Fphp-mysql%2Fhow-to-save-your-website-from-security-holes%2F&amp;title=How%20to%20save%20your%20Website%20from%20security%20holes&amp;notes=Hai%20good%20Morning%20everyone%21%20do%20you%20know%20web%20development%2C%20are%20we%20talking%20about%20web%20development%20or%20web%20all%20alone%2C%20but%20anything%20which%20ever%20makes%20a%20sense.%20But%20you%20need%20to%20understand%20web%20technology%20is%20something%20going%20high%20and%20web%20technology%20is%20something%20of"></a></li><li><a title="Google Reader" class="option1_16" style="background-position:-112px 0px" rel="nofollow" target="_blank" href="http://www.google.com/reader/link?url=http%3A%2F%2Fwww.quatre-bornes.com%2Ftechnology%2Fphp-mysql%2Fhow-to-save-your-website-from-security-holes%2F&amp;title=How%20to%20save%20your%20Website%20from%20security%20holes&amp;srcURL=http%3A%2F%2Fwww.quatre-bornes.com%2Ftechnology%2Fphp-mysql%2Fhow-to-save-your-website-from-security-holes%2F&amp;srcTitle=Quatre+Bornes+-+Town+Portal+Town+portal+in+Mauritius"></a></li><li><a title="BlinkList" class="option1_16" style="background-position:0px 0px" rel="nofollow" target="_blank" href="http://www.blinklist.com/index.php?Action=Blink/addblink.php&amp;Url=http%3A%2F%2Fwww.quatre-bornes.com%2Ftechnology%2Fphp-mysql%2Fhow-to-save-your-website-from-security-holes%2F&amp;Title=How%20to%20save%20your%20Website%20from%20security%20holes"></a></li><li><a title="Digg" class="option1_16" style="background-position:-32px 0px" rel="nofollow" target="_blank" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.quatre-bornes.com%2Ftechnology%2Fphp-mysql%2Fhow-to-save-your-website-from-security-holes%2F&amp;title=How%20to%20save%20your%20Website%20from%20security%20holes&amp;bodytext=Hai%20good%20Morning%20everyone%21%20do%20you%20know%20web%20development%2C%20are%20we%20talking%20about%20web%20development%20or%20web%20all%20alone%2C%20but%20anything%20which%20ever%20makes%20a%20sense.%20But%20you%20need%20to%20understand%20web%20technology%20is%20something%20going%20high%20and%20web%20technology%20is%20something%20of"></a></li><li><a title="Google Bookmarks" class="option1_16" style="background-position:-96px 0px" rel="nofollow" target="_blank" href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.quatre-bornes.com%2Ftechnology%2Fphp-mysql%2Fhow-to-save-your-website-from-security-holes%2F&amp;title=How%20to%20save%20your%20Website%20from%20security%20holes&amp;annotation=Hai%20good%20Morning%20everyone%21%20do%20you%20know%20web%20development%2C%20are%20we%20talking%20about%20web%20development%20or%20web%20all%20alone%2C%20but%20anything%20which%20ever%20makes%20a%20sense.%20But%20you%20need%20to%20understand%20web%20technology%20is%20something%20going%20high%20and%20web%20technology%20is%20something%20of"></a></li><li><a style="cursor:pointer" rel="nofollow" onMouseOut="fixOnMouseOut(document.getElementById('sociable-post-669'), event, 'post-669')" onMouseOver="more(this,'post-669')"><img style='padding-top: 0;margin-top:-2px' src='http://www.quatre-bornes.com/wp-content/plugins/sociable/images/more.png'></a></li></ul><div onMouseout="fixOnMouseOut(this,event,'post-669')" id="sociable-post-669" style="display:none;">   

    <div style="top: auto; left: auto; display: block;" id="sociable">



		<div class="popup">

			<div class="content">

				<ul><li style="heigth:16px;width:16px"><a title="Myspace" class="option1_16" style="background-position:0px -16px" rel="nofollow" target="_blank" href="http://www.myspace.com/Modules/PostTo/Pages/?u=http%3A%2F%2Fwww.quatre-bornes.com%2Ftechnology%2Fphp-mysql%2Fhow-to-save-your-website-from-security-holes%2F&amp;t=How%20to%20save%20your%20Website%20from%20security%20holes"></a></li><li style="heigth:16px;width:16px"><a title="Reddit" class="option1_16" style="background-position:-64px -16px" rel="nofollow" target="_blank" href="http://reddit.com/submit?url=http%3A%2F%2Fwww.quatre-bornes.com%2Ftechnology%2Fphp-mysql%2Fhow-to-save-your-website-from-security-holes%2F&amp;title=How%20to%20save%20your%20Website%20from%20security%20holes"></a></li><li style="heigth:16px;width:16px"><a title="HackerNews" class="option1_16" style="background-position:-128px 0px" rel="nofollow" target="_blank" href="http://news.ycombinator.com/submitlink?u=http%3A%2F%2Fwww.quatre-bornes.com%2Ftechnology%2Fphp-mysql%2Fhow-to-save-your-website-from-security-holes%2F&amp;t=How%20to%20save%20your%20Website%20from%20security%20holes"></a></li><li style="heigth:16px;width:16px"><a title="MSNReporter" class="option1_16" style="background-position:-176px 0px" rel="nofollow" target="_blank" href="http://reporter.es.msn.com/?fn=contribute&amp;Title=How%20to%20save%20your%20Website%20from%20security%20holes&amp;URL=http%3A%2F%2Fwww.quatre-bornes.com%2Ftechnology%2Fphp-mysql%2Fhow-to-save-your-website-from-security-holes%2F&amp;cat_id=6&amp;tag_id=31&amp;Remark=Hai%20good%20Morning%20everyone%21%20do%20you%20know%20web%20development%2C%20are%20we%20talking%20about%20web%20development%20or%20web%20all%20alone%2C%20but%20anything%20which%20ever%20makes%20a%20sense.%20But%20you%20need%20to%20understand%20web%20technology%20is%20something%20going%20high%20and%20web%20technology%20is%20something%20of"></a></li><li style="heigth:16px;width:16px"><a title="Sphinn" class="option1_16" style="background-position:-96px -16px" rel="nofollow" target="_blank" href="http://sphinn.com/index.php?c=post&amp;m=submit&amp;link=http%3A%2F%2Fwww.quatre-bornes.com%2Ftechnology%2Fphp-mysql%2Fhow-to-save-your-website-from-security-holes%2F"></a></li><li style="heigth:16px;width:16px"><a title="Posterous" class="option1_16" style="background-position:-32px -16px" rel="nofollow" target="_blank" href="http://posterous.com/share?linkto=http%3A%2F%2Fwww.quatre-bornes.com%2Ftechnology%2Fphp-mysql%2Fhow-to-save-your-website-from-security-holes%2F&amp;title=How%20to%20save%20your%20Website%20from%20security%20holes&amp;selection=Hai%20good%20Morning%20everyone%21%20do%20you%20know%20web%20development%2C%20are%20we%20talking%20about%20web%20development%20or%20web%20all%20alone%2C%20but%20anything%20which%20ever%20makes%20a%20sense.%20But%20you%20need%20to%20understand%20web%20technology%20is%20something%20going%20high%20and%20web%20technology%20is%20something%20of"></a></li><li style="heigth:16px;width:16px"><a title="Tumblr" class="option1_16" style="background-position:-128px -16px" rel="nofollow" target="_blank" href="http://www.tumblr.com/share?v=3&amp;u=http%3A%2F%2Fwww.quatre-bornes.com%2Ftechnology%2Fphp-mysql%2Fhow-to-save-your-website-from-security-holes%2F&amp;t=How%20to%20save%20your%20Website%20from%20security%20holes&amp;s=Hai%20good%20Morning%20everyone%21%20do%20you%20know%20web%20development%2C%20are%20we%20talking%20about%20web%20development%20or%20web%20all%20alone%2C%20but%20anything%20which%20ever%20makes%20a%20sense.%20But%20you%20need%20to%20understand%20web%20technology%20is%20something%20going%20high%20and%20web%20technology%20is%20something%20of"></a></li></ul>			

			</div>        

		  <a style="cursor:pointer" onclick="hide_sociable('post-669',true)" class="close">



		  <img onclick="hide_sociable('post-669',true)" title="close" src="http://www.quatre-bornes.com/wp-content/plugins/sociable/images/closelabel.png">

		  </a>

		</div>

	</div> 

  </div></div><div class='sociable' style='float:none'><ul class='clearfix'><li id="Google_p"><g:plusone annotation="bubble" href="http://www.quatre-bornes.com/technology/php-mysql/how-to-save-your-website-from-security-holes/" size="medium"></g:plusone></li><li id="Facebook_Counter"><iframe src="//www.facebook.com/plugins/like.php?href=http://www.quatre-bornes.com/technology/php-mysql/how-to-save-your-website-from-security-holes/&send=false&layout=button_count&show_faces=false&action=like&colorscheme=light&font" scrolling="no" frameborder="0" style="border:none; overflow:hidden;height:32px;width:100px" allowTransparency="true"></iframe></li><li id="Twitter_Counter"><a href="https://twitter.com/share" data-text="How to save your Website from security holes - http://www.quatre-bornes.com/technology/php-mysql/how-to-save-your-website-from-security-holes/ (via #sociablesite)" data-url="http://www.quatre-bornes.com/technology/php-mysql/how-to-save-your-website-from-security-holes/" class="twitter-share-button" data-count="horizontal">Tweet</a><script type="text/javascript" src="//platform.twitter.com/widgets.js"></script></li><li id="LinkedIn_Counter"><script src="http://platform.linkedin.com/in.js" type="text/javascript"></script><script type="IN/Share" data-url="http://www.quatre-bornes.com/technology/php-mysql/how-to-save-your-website-from-security-holes/" data-counter="right"></script></li><li id="StumbleUpon_Counter"><script src="http://www.stumbleupon.com/hostedbadge.php?s=2&r=http://www.quatre-bornes.com/technology/php-mysql/how-to-save-your-website-from-security-holes/"></script></li><li id="Digg_Counter"><script type='text/javascript'>(function() {var s = document.createElement('SCRIPT'), s1 = document.getElementsByTagName('SCRIPT')[0];s.type = 'text/javascript';s.async = true;s.src = 'http://widgets.digg.com/buttons.js';s1.parentNode.insertBefore(s, s1);})();</script><a href='http://digg.com/submit?url=http%3A%2F%2Fwww.quatre-bornes.com%2Ftechnology%2Fphp-mysql%2Fhow-to-save-your-website-from-security-holes%2F&amp;title=How%20to%20save%20your%20Website%20from%20security%20holes'  class='DiggThisButton DiggCompact'></a></li></ul></div><!-- End Sociable -->]]></content:encoded>
			<wfw:commentRss>http://www.quatre-bornes.com/technology/php-mysql/how-to-save-your-website-from-security-holes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

