Archive

Archive for the ‘Web Development’ Category

Parse .html as PHP in XAMPP

July 30th, 2009

How can I configure Apache to treat .html files as PHP?

This is very common issue faced by almost every developer at some point, recently I had it on my XAMPP setup (version 1.7.1). Other concerning details are:

###### ApacheFriends XAMPP (Basispaket) version 1.7.1 ######

+ Apache 2.2.11
+ MySQL 5.1.33 (Community Server)
+ PHP 5.2.9 + PEAR (Support for PHP 4 has been discontinued)

Solution:

I simply changed following line:

<FilesMatch “\.php$|\.php5$|\.php4$|\.php3$|\.phtml$|\.phpt$”>

to

<FilesMatch “\.php$|\.php5$|\.php4$|\.php3$|\.phtml$|\.phpt$|\.html$“>

in httpd-xampp.conf

OR

change line 21

From
<FilesMatch “\.php$”>

To
<FilesMatch “\.php$|\.html$”>

and it worked great.

Post to Twitter Post to Plurk Plurk This Post Post to Yahoo Buzz Buzz This Post Post to Delicious Delicious Post to Digg Digg This Post Post to Ping.fm Ping This Post Post to Reddit Reddit This Post Post to StumbleUpon Stumble This Post

PHP , , , ,

Using curl with PHP Tutorial

February 3rd, 2009

Recently while developing a database backed php website, the client demanded to have all forms on one site say www.client-forms-website.com, and all the data to be submitted and stored on www.client-database-website.com.

Curl was the ultimate solution. curl is the client URL function library. PHP supports it through libcurl. To enable support for libcurl when installing PHP add –with-curl=[location of curl libraries] to the configure statement before compiling. The curl package must be installed prior to installing PHP. Most major functions required when connecting to remote web servers are included in curl, including POST and GET form posting, SSL support, HTTP authentication, session and cookie handling.

Leaving out all the fancy stuff, this is what I implemented:

On www.client-forms-website.com:

Created a file “receive-form-data.php” with following code.

<?php

// Move posted data into variables.

$firstName= @$_POST[firstName];
$surName= @$_POST[surName];
$email= @$_POST[email];

//The $curlPost variable is being used to store the POST data curl will use. When forming the $curlPost variable which will be used by curl_setopt later be sure to urlencode your data prior to passing it to curl_setopt.

$curlPost = “firstname=”.urlencode($firstName).”&surname=”. urlencode($surName).”&email=”. urlencode($email).”&submitted=true”;
$ch = curl_init();
//set the handle of the curl session to $ch
curl_setopt($ch, CURLOPT_URL, ‘http:// www.client-database-website.com/process-posted-data.php’); //set the URL of the page to pass data.
curl_setopt($ch, CURLOPT_HEADER, 0); //sets whether or not the server response header should be returned, 0 means no header.
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); //by default curl will display the response straight to the browser as the script is executed. To counter this we enabled the CURLOPT_RETURNTRANSFER option.
curl_setopt($ch, CURLOPT_POST, 1); //tell curl to send the form response via the POST method.
curl_setopt($ch, CURLOPT_POSTFIELDS, $curlPost); //option used to store the POST data.
$data = curl_exec($ch); // $data stores data returned from the remote server.
curl_close($ch);

if ($data==1) header(“location: http:// www.client-forms-website.com /thankyou.html“);

else if ($data==0) header(“location: http:// www.client-forms-website.com /error.html“);

?>

On www.client- database -website.com:

Created a file “process-posted-data.php’” with following code.

<?php

$firstName= @$_POST[firstName]; $surName= @$_POST[surName]; $email= @$_POST[email];

/* Function/lines of code to Store Data go here.*/

If (success) echo 1;

else echo 0;

?>

This is working great. Have fun.

Post to Twitter Post to Plurk Plurk This Post Post to Yahoo Buzz Buzz This Post Post to Delicious Delicious Post to Digg Digg This Post Post to Ping.fm Ping This Post Post to Reddit Reddit This Post Post to StumbleUpon Stumble This Post

PHP , ,

My Favorite FireFox Add-ons

January 29th, 2009

I am a web developer and SEO professional, and use a variety of desktop and online tools to get the job done including Mozilla Firefox. It’s the premium web browser used by most of web professional, but very few comprehend that by installing some of the many free extensions/add-ons, they can get rid of most of the other applications they currently use. Below are my 9 favorite extensions for web:

FireFTP – is a free, secure, cross-platform FTP client for Mozilla Firefox that provides easy and intuitive access to FTP servers. You don’t need a separate program for FTP, very handy.

Professor X – lets you view web page’s header information without having to view source code. It displays the contents of the page’s header, including Meta, Script and Style content.

WHOIS Lookup 1.1 – View the WHOIS information for any page easily and quickly by clicking the button on the top-right of the browser.

IE View – If you frequently use Internet Explorer to test how your website renders on that browser,tThis add-on allows you to view the way any page would look if it were opened in IE, without the hassle of opening another browser.

WebDeveloper toolbar – This all-in-one toolbar provides you swift control over things like JavaScript display, form and CSS elements, screen resizing (so you know what your website looks like in smaller resolutions), HTML validation, and much more.

AdSense Preview – preview the Google AdSense ads that would appear on that page. This is incredibly useful if you are considering putting AdSense on a page and don’t want to go through the hassle of signing up for an account and putting the ads up just to see what type of ads will show.

Screen grab – It takes a screen shot of what you can see in the window, the entire page, just a selection, a particular frame and saves it as an image file. This saves a ton of time compared to the method I used to use – take a screenshot and open Adobe Photoshop to crop the image.

MeasureIt – You can use this to draw out a ruler to get the pixel width and height of any elements you see on a webpage. It’s very simple to use, and of course very helpful at times.

Gspace – This turns your Gmail Space (4.1 GB and growing) into an online drive, so you can use it to upload files from your hard drive and access them from every Internet enabled computer.

What are your favorite add-ons for web developing? Leave us a comment below.

Post to Twitter Post to Plurk Plurk This Post Post to Yahoo Buzz Buzz This Post Post to Delicious Delicious Post to Digg Digg This Post Post to Ping.fm Ping This Post Post to Reddit Reddit This Post Post to StumbleUpon Stumble This Post

Web Development , , ,

Twitter links powered by Tweet This v1.6.1, a WordPress plugin for Twitter.