Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /home/content/f/e/r/ferasferas1/html/scriptslibrary/libraries/joomla/database/database.php:2) in /home/content/f/e/r/ferasferas1/html/scriptslibrary/libraries/joomla/session/session.php on line 423

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/content/f/e/r/ferasferas1/html/scriptslibrary/libraries/joomla/database/database.php:2) in /home/content/f/e/r/ferasferas1/html/scriptslibrary/libraries/joomla/session/session.php on line 423

Warning: Cannot modify header information - headers already sent by (output started at /home/content/f/e/r/ferasferas1/html/scriptslibrary/libraries/joomla/database/database.php:2) in /home/content/f/e/r/ferasferas1/html/scriptslibrary/libraries/joomla/session/session.php on line 426
PHP - The Scripts Library Community Free programming tutorial and source code for beginners and professional http://www.scriptslibrary.net/php 2010-09-06T20:28:19Z Joomla! 1.5 - Open Source Content Management Remove characters from a string except numbers and letters 2009-12-05T01:34:19Z 2009-12-05T01:34:19Z http://www.scriptslibrary.net/php/124-remove-characters-from-a-string-except-numbers-and-letters Feras ferasc@hotmail.com If you want to remove all characters and special symbols from a string in php, use the following code snippet:<br /><br /><br />{CODE brush: php;} <br />&lt;?php<br /><br />$string = "remove *unwanted !character% from my string 1212&&";<br />$clean_string= ereg_replace("[^A-Za-z0-9]", "", $string);<br />echo $clean_string<br /><br />?&gt;<br />{/CODE} If you want to remove all characters and special symbols from a string in php, use the following code snippet:<br /><br /><br />{CODE brush: php;} <br />&lt;?php<br /><br />$string = "remove *unwanted !character% from my string 1212&&";<br />$clean_string= ereg_replace("[^A-Za-z0-9]", "", $string);<br />echo $clean_string<br /><br />?&gt;<br />{/CODE} PHP Function to Prevent SQL injection 2009-11-27T03:06:22Z 2009-11-27T03:06:22Z http://www.scriptslibrary.net/php/120-php-function-to-prevent-sql-injection Feras ferasc@hotmail.com Function to clean user input string to prevent SQL injections: Function to clean user input string to prevent SQL injections: Remove Empty Members from an Array in PHP 2009-06-19T06:53:34Z 2009-06-19T06:53:34Z http://www.scriptslibrary.net/php/91-remove-empty-members-from-an-array-in-php Feras ferasc@hotmail.com A simple function to remove empty members/entries from an array in PHP: <br /> A simple function to remove empty members/entries from an array in PHP: <br /> Prevent SQL Injection with PHP and MySQL 2009-06-16T23:30:23Z 2009-06-16T23:30:23Z http://www.scriptslibrary.net/php/86-prevent-sql-injection-with-php-and-mysql Feras ferasc@hotmail.com Nowadays websites security became the first concern of websites owners. Lots of malicious hackers try to get into online databases to ruin or steal information. You have to put in mind that a website without security is likely to get attacked or hacked, oven if you think that no one is interesting to do so!<br /><br />SQL injection is a well-known way to attack used to get, insert, delete or update data from a particular database. Without security, your data is on high risk and might get lost or changed. This kind of attack is done thought the user input in the browser, POST and GET. Before you publish your website, you have to test it against SQL injection attacks to prevent any future failure.<br /> Nowadays websites security became the first concern of websites owners. Lots of malicious hackers try to get into online databases to ruin or steal information. You have to put in mind that a website without security is likely to get attacked or hacked, oven if you think that no one is interesting to do so!<br /><br />SQL injection is a well-known way to attack used to get, insert, delete or update data from a particular database. Without security, your data is on high risk and might get lost or changed. This kind of attack is done thought the user input in the browser, POST and GET. Before you publish your website, you have to test it against SQL injection attacks to prevent any future failure.<br /> Encrypting Password using md5() function 2009-06-16T22:58:52Z 2009-06-16T22:58:52Z http://www.scriptslibrary.net/php/85-encrypting-password-using-md5-function Feras ferasc@hotmail.com <br />PHP provide a variety of function to get our source secure. This simple article shows how to use the md5() function to encrypt data, especially passwords in the database. <br />The code is easy: <br /> <br />PHP provide a variety of function to get our source secure. This simple article shows how to use the md5() function to encrypt data, especially passwords in the database. <br />The code is easy: <br /> Create login page in PHP 2009-06-16T21:57:54Z 2009-06-16T21:57:54Z http://www.scriptslibrary.net/php/84-create-login-page-in-php Feras ferasc@hotmail.com <br /> In this tutorial, I will explain step by step how to create a login page in PHP. <br /><br /><strong>Create a table Users in your mySQL database. </strong><br />{CODE brush: sql;} <br /> CREATE TABLE `Users` (<br /> `id` int(4) NOT NULL auto_increment,<br /> `user_name` varchar(100) NOT NULL default '',<br /> `password` varchar(100) NOT NULL default '',<br /> PRIMARY KEY (`id`)<br /> ) TYPE=MyISAM AUTO_INCREMENT=1 ; {/CODE}<br /> For testing purpose, run the following sql query to inset a row into the database: <br />{CODE brush: sql;} INSERT INTO `Users` VALUES (1, 'feras', 'pass'); {/CODE}<br /> <br /> In this tutorial, I will explain step by step how to create a login page in PHP. <br /><br /><strong>Create a table Users in your mySQL database. </strong><br />{CODE brush: sql;} <br /> CREATE TABLE `Users` (<br /> `id` int(4) NOT NULL auto_increment,<br /> `user_name` varchar(100) NOT NULL default '',<br /> `password` varchar(100) NOT NULL default '',<br /> PRIMARY KEY (`id`)<br /> ) TYPE=MyISAM AUTO_INCREMENT=1 ; {/CODE}<br /> For testing purpose, run the following sql query to inset a row into the database: <br />{CODE brush: sql;} INSERT INTO `Users` VALUES (1, 'feras', 'pass'); {/CODE}<br /> How To Use .htaccess to Prevent Apache HTTPD Directory Listing 2008-09-28T03:43:55Z 2008-09-28T03:43:55Z http://www.scriptslibrary.net/php/63-how-to-use-htaccess-to-prevent-apache-httpd-directory-listing Feras ferasc@hotmail.com <!--[if gte mso 9]><xml> <w:WordDocument> <w:View>Normal</w:View> <w:Zoom>0</w:Zoom> <w:DoNotOptimizeForBrowser/> </w:WordDocument> </xml><![endif]--> <!-- /* Font Definitions */ @font-face {font-family:Wingdings; panose-1:5 0 0 0 0 0 0 0 0 0; mso-font-charset:2; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:0 268435456 0 0 -2147483648 0;} @font-face {font-family:"Arial Unicode MS"; panose-1:2 11 6 4 2 2 2 2 2 4; mso-font-charset:128; mso-generic-font-family:swiss; mso-font-pitch:variable; mso-font-signature:-1 -369098753 63 0 4129279 0;} @font-face {font-family:"\@Arial Unicode MS"; panose-1:2 11 6 4 2 2 2 2 2 4; mso-font-charset:128; mso-generic-font-family:swiss; mso-font-pitch:variable; mso-font-signature:-1 -369098753 63 0 4129279 0;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {mso-style-parent:""; margin:0in; margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:12.0pt; font-family:"Times New Roman"; mso-fareast-font-family:"Times New Roman";} h1 {margin-right:0in; mso-margin-top-alt:auto; mso-margin-bottom-alt:auto; margin-left:0in; mso-pagination:widow-orphan; mso-outline-level:1; font-size:24.0pt; font-family:"Arial Unicode MS"; mso-font-kerning:18.0pt; font-weight:bold;} h2 {margin-right:0in; mso-margin-top-alt:auto; mso-margin-bottom-alt:auto; margin-left:0in; mso-pagination:widow-orphan; mso-outline-level:2; font-size:18.0pt; font-family:"Arial Unicode MS"; font-weight:bold;} h3 {margin-right:0in; mso-margin-top-alt:auto; mso-margin-bottom-alt:auto; margin-left:0in; mso-pagination:widow-orphan; mso-outline-level:3; font-size:13.5pt; font-family:"Arial Unicode MS"; font-weight:bold;} a:link, span.MsoHyperlink {color:blue; text-decoration:underline; text-underline:single;} a:visited, span.MsoHyperlinkFollowed {color:purple; text-decoration:underline; text-underline:single;} p {margin-right:0in; mso-margin-top-alt:auto; mso-margin-bottom-alt:auto; margin-left:0in; mso-pagination:widow-orphan; font-size:12.0pt; font-family:"Arial Unicode MS";} code {mso-ascii-font-family:"Arial Unicode MS"; mso-fareast-font-family:"Arial Unicode MS"; mso-hansi-font-family:"Arial Unicode MS"; mso-bidi-font-family:"Arial Unicode MS";} p.content, li.content, div.content {mso-style-name:content; margin-right:0in; mso-margin-top-alt:auto; mso-margin-bottom-alt:auto; margin-left:0in; mso-pagination:widow-orphan; font-size:12.0pt; font-family:"Arial Unicode MS";} span.style1 {mso-style-name:style1;} span.content1 {mso-style-name:content1;} span.style4 {mso-style-name:style4;} span.style2 {mso-style-name:style2;} span.style6 {mso-style-name:style6;} p.style11, li.style11, div.style11 {mso-style-name:style11; margin-right:0in; mso-margin-top-alt:auto; mso-margin-bottom-alt:auto; margin-left:0in; mso-pagination:widow-orphan; font-size:12.0pt; font-family:"Arial Unicode MS";} @page Section1 {size:8.5in 11.0in; margin:1.0in 1.25in 1.0in 1.25in; mso-header-margin:.5in; mso-footer-margin:.5in; mso-paper-source:0;} div.Section1 {page:Section1;} /* List Definitions */ @list l0 {mso-list-id:237129745; mso-list-type:hybrid; mso-list-template-ids:-1461795346 -993786540 -1119815404 966323674 2127195014 -2129078430 1342835954 -185194448 1055527800 630076046;} @list l0:level1 {mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in;} @list l1 {mso-list-id:1022128970; mso-list-type:hybrid; mso-list-template-ids:1169844726 1611165046 -1245312098 278015556 1375750490 1306678488 1683104522 -1561145962 2077008240 -461103374;} @list l1:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in; mso-ansi-font-size:10.0pt; font-family:Symbol;} @list l2 {mso-list-id:1352412119; mso-list-type:hybrid; mso-list-template-ids:328347968 -685575600 -1340298630 2069241310 491785734 1409441062 -781016900 -662139416 -2086652694 1299193212;} @list l2:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in; mso-ansi-font-size:10.0pt; font-family:Symbol;} @list l3 {mso-list-id:2113088652; mso-list-type:hybrid; mso-list-template-ids:1965310702 -170096108 -1301672810 467797320 275542224 1715629782 1628749208 -466479332 -514969464 399959948;} @list l3:level1 {mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in;} ol {margin-bottom:0in;} ul {margin-bottom:0in;} --> <p>&nbsp;</p><p>Apache HTTPD servers are configured by default to display directory listing, when index files like index.htm or index.html of index.php etc. are not present in the directory. This can expose sensitive information to prying eyes and are often indexed by search engines. This can compromise your data by making it visible to unintended audience. The solution is simple. You can add a line to your .htaccess file (create the file if not present) to prevent directory listing for that directory and its sub-directories:<br /> IndexIgnore *</p> <p>The * matches all files in the directory. You can also restrict only a subset of file from being displayed. For example if you would want the directory content to be listed but not include the images in the listings then you should use this command:<br /> IndexIgnore *.png *.gif *.jpg</p> <p>This would return a list of all files not ending in .png, .jpg or .gif, but would still list .txt, .html, etc.</p> <p>On the other hand if your server is setup to prevent directory listing, but you want to list the directories by default, then add the following in your .htaccess file:<br /> Options +Indexes</p> <!--[if gte mso 9]><xml> <w:WordDocument> <w:View>Normal</w:View> <w:Zoom>0</w:Zoom> <w:DoNotOptimizeForBrowser/> </w:WordDocument> </xml><![endif]--> <!-- /* Font Definitions */ @font-face {font-family:Wingdings; panose-1:5 0 0 0 0 0 0 0 0 0; mso-font-charset:2; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:0 268435456 0 0 -2147483648 0;} @font-face {font-family:"Arial Unicode MS"; panose-1:2 11 6 4 2 2 2 2 2 4; mso-font-charset:128; mso-generic-font-family:swiss; mso-font-pitch:variable; mso-font-signature:-1 -369098753 63 0 4129279 0;} @font-face {font-family:"\@Arial Unicode MS"; panose-1:2 11 6 4 2 2 2 2 2 4; mso-font-charset:128; mso-generic-font-family:swiss; mso-font-pitch:variable; mso-font-signature:-1 -369098753 63 0 4129279 0;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {mso-style-parent:""; margin:0in; margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:12.0pt; font-family:"Times New Roman"; mso-fareast-font-family:"Times New Roman";} h1 {margin-right:0in; mso-margin-top-alt:auto; mso-margin-bottom-alt:auto; margin-left:0in; mso-pagination:widow-orphan; mso-outline-level:1; font-size:24.0pt; font-family:"Arial Unicode MS"; mso-font-kerning:18.0pt; font-weight:bold;} h2 {margin-right:0in; mso-margin-top-alt:auto; mso-margin-bottom-alt:auto; margin-left:0in; mso-pagination:widow-orphan; mso-outline-level:2; font-size:18.0pt; font-family:"Arial Unicode MS"; font-weight:bold;} h3 {margin-right:0in; mso-margin-top-alt:auto; mso-margin-bottom-alt:auto; margin-left:0in; mso-pagination:widow-orphan; mso-outline-level:3; font-size:13.5pt; font-family:"Arial Unicode MS"; font-weight:bold;} a:link, span.MsoHyperlink {color:blue; text-decoration:underline; text-underline:single;} a:visited, span.MsoHyperlinkFollowed {color:purple; text-decoration:underline; text-underline:single;} p {margin-right:0in; mso-margin-top-alt:auto; mso-margin-bottom-alt:auto; margin-left:0in; mso-pagination:widow-orphan; font-size:12.0pt; font-family:"Arial Unicode MS";} code {mso-ascii-font-family:"Arial Unicode MS"; mso-fareast-font-family:"Arial Unicode MS"; mso-hansi-font-family:"Arial Unicode MS"; mso-bidi-font-family:"Arial Unicode MS";} p.content, li.content, div.content {mso-style-name:content; margin-right:0in; mso-margin-top-alt:auto; mso-margin-bottom-alt:auto; margin-left:0in; mso-pagination:widow-orphan; font-size:12.0pt; font-family:"Arial Unicode MS";} span.style1 {mso-style-name:style1;} span.content1 {mso-style-name:content1;} span.style4 {mso-style-name:style4;} span.style2 {mso-style-name:style2;} span.style6 {mso-style-name:style6;} p.style11, li.style11, div.style11 {mso-style-name:style11; margin-right:0in; mso-margin-top-alt:auto; mso-margin-bottom-alt:auto; margin-left:0in; mso-pagination:widow-orphan; font-size:12.0pt; font-family:"Arial Unicode MS";} @page Section1 {size:8.5in 11.0in; margin:1.0in 1.25in 1.0in 1.25in; mso-header-margin:.5in; mso-footer-margin:.5in; mso-paper-source:0;} div.Section1 {page:Section1;} /* List Definitions */ @list l0 {mso-list-id:237129745; mso-list-type:hybrid; mso-list-template-ids:-1461795346 -993786540 -1119815404 966323674 2127195014 -2129078430 1342835954 -185194448 1055527800 630076046;} @list l0:level1 {mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in;} @list l1 {mso-list-id:1022128970; mso-list-type:hybrid; mso-list-template-ids:1169844726 1611165046 -1245312098 278015556 1375750490 1306678488 1683104522 -1561145962 2077008240 -461103374;} @list l1:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in; mso-ansi-font-size:10.0pt; font-family:Symbol;} @list l2 {mso-list-id:1352412119; mso-list-type:hybrid; mso-list-template-ids:328347968 -685575600 -1340298630 2069241310 491785734 1409441062 -781016900 -662139416 -2086652694 1299193212;} @list l2:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in; mso-ansi-font-size:10.0pt; font-family:Symbol;} @list l3 {mso-list-id:2113088652; mso-list-type:hybrid; mso-list-template-ids:1965310702 -170096108 -1301672810 467797320 275542224 1715629782 1628749208 -466479332 -514969464 399959948;} @list l3:level1 {mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in;} ol {margin-bottom:0in;} ul {margin-bottom:0in;} --> <p>&nbsp;</p><p>Apache HTTPD servers are configured by default to display directory listing, when index files like index.htm or index.html of index.php etc. are not present in the directory. This can expose sensitive information to prying eyes and are often indexed by search engines. This can compromise your data by making it visible to unintended audience. The solution is simple. You can add a line to your .htaccess file (create the file if not present) to prevent directory listing for that directory and its sub-directories:<br /> IndexIgnore *</p> <p>The * matches all files in the directory. You can also restrict only a subset of file from being displayed. For example if you would want the directory content to be listed but not include the images in the listings then you should use this command:<br /> IndexIgnore *.png *.gif *.jpg</p> <p>This would return a list of all files not ending in .png, .jpg or .gif, but would still list .txt, .html, etc.</p> <p>On the other hand if your server is setup to prevent directory listing, but you want to list the directories by default, then add the following in your .htaccess file:<br /> Options +Indexes</p> How to run php code embedded in html pages 2008-09-28T03:34:54Z 2008-09-28T03:34:54Z http://www.scriptslibrary.net/php/62-how-to-run-php-code-embedded-in-html-pages Administrator info@scriptslibrary.net Embedding PHP code into html is powerful rule that most programmers use. However, you should configure your server in order to get the benefits of this feature. It will only work if your Apache server has PHP enabled (<a href="php/61-how-to-test-php-support-in-apache-http-server">how to test php support in a Apache server</a>) and .htaccess enabled. In the root directory of your html files create a file named .htaccess (DOThtaccess). Embedding PHP code into html is powerful rule that most programmers use. However, you should configure your server in order to get the benefits of this feature. It will only work if your Apache server has PHP enabled (<a href="php/61-how-to-test-php-support-in-apache-http-server">how to test php support in a Apache server</a>) and .htaccess enabled. In the root directory of your html files create a file named .htaccess (DOThtaccess). How To Test PHP Support In Apache HTTP Server 2008-09-28T03:32:20Z 2008-09-28T03:32:20Z http://www.scriptslibrary.net/php/61-how-to-test-php-support-in-apache-http-server Feras ferasc@hotmail.com <br /> This is the easiest way to get and test php support in a apache web server. First, create a file in your htdocs directory (ask the location from your web hosting provider if you are not sure named test.php. Second, Open the file in your favorite text editor and add the line: <br /><br />{CODE brush: php;} <br /> &lt;? php phpinfo() ?&gt;<br />{/CODE}<br /> Finally, Save the file and open it using your browser: http://host_name/test.php<br /> That's it! Now you can see a page with php information and get all abilities that your server can handle. PHP support is required if you want to run lots of web applications like Joomla, for example. Demand PHP support from your web-hosting provider if it is not already enabled. <br /> This is the easiest way to get and test php support in a apache web server. First, create a file in your htdocs directory (ask the location from your web hosting provider if you are not sure named test.php. Second, Open the file in your favorite text editor and add the line: <br /><br />{CODE brush: php;} <br /> &lt;? php phpinfo() ?&gt;<br />{/CODE}<br /> Finally, Save the file and open it using your browser: http://host_name/test.php<br /> That's it! Now you can see a page with php information and get all abilities that your server can handle. PHP support is required if you want to run lots of web applications like Joomla, for example. Demand PHP support from your web-hosting provider if it is not already enabled. Google Safe 301 Redirect Using PHP 2008-09-28T03:29:49Z 2008-09-28T03:29:49Z http://www.scriptslibrary.net/php/60-google-safe-301-redirect-using-php Administrator info@scriptslibrary.net <br />When you want to redirect, make sure you are doing it in the right way. Google penalizes websites that being redirected to many other locations. Many webmasters tries to cheat on Google by redirecting good optimized pages or website to bad ones However, the following method a safe for Google redirection, as well as all search engines behind. Put the following code into the page you want it to redirect to another: <br /> {CODE brush: vb;} <br /> header("HTTP/1.1 301 Moved Permanently");<br />header("Location: http://www.newdomain.com/newurl.htm");<br />exit();<br />{/CODE}<br /> That's it! <br />When you want to redirect, make sure you are doing it in the right way. Google penalizes websites that being redirected to many other locations. Many webmasters tries to cheat on Google by redirecting good optimized pages or website to bad ones However, the following method a safe for Google redirection, as well as all search engines behind. Put the following code into the page you want it to redirect to another: <br /> {CODE brush: vb;} <br /> header("HTTP/1.1 301 Moved Permanently");<br />header("Location: http://www.newdomain.com/newurl.htm");<br />exit();<br />{/CODE}<br /> That's it!