How to restrict directory listing using .htaccess

Posted by 4 May, 2012 (0) Comment

Add these 2 lines in your .htaccess file. Create if already not exisit in your server and put in root level.
You don’t have to restart Apache server.

IndexIgnore *
Options -Indexes
Share
Categories : .htaccess,Apache Tags :

How to Submit form through PHP CURL ?

Posted by 4 May, 2012 (0) Comment

Last week I was working with salesforce form to collect data from third party website. If you have to just submit form its easy salesforce does not restrict to use CURL in order to post data but my requirement was to post salesforce from data and store that data in my database too. This is easy and simple and has a lot of ways to do.
Now I would like to show you PHP CURL way to post form data. You can use PHP Jquery and Ajax to make it more fancy. But I want to keep it simple.
Step 1 -
I am using one sales force form as example.

<form action="form-action-curl.php" method="POST">
<input type=hidden name="oid" value="00D400000009mUU">
<input type=hidden name="retURL" value="http://thank-you.html">
<label for="first_name">First Name</label><input  id="first_name" maxlength="40" name="first_name" size="20" type="text" /><br>
<label for="last_name">Last Name</label><input  id="last_name" maxlength="80" name="last_name" size="20" type="text" /><br>
<label for="street">Address</label><textarea name="street"></textarea><br>
<label for="city">City</label><input  id="city" maxlength="40" name="city" size="20" type="text" /><br>
<label for="zip">Zip</label><input  id="zip" maxlength="20" name="zip" size="20" type="text" /><br>
<label for="email">Email</label><input  id="email" maxlength="80" name="email" size="20" type="text" /><br>
<label for="phone">Phone</label><input  id="phone" maxlength="40" name="phone" size="20" type="text" /><br>
<input type="submit" name="submit">
</form>

Step 2  -  This is standard PHP CURL script (form-action-curl.php) to post from you can use anywhere without any modification in from you can add more fields if you need.

 
//Initialize the $query_string variable for later use
$query_string = "";
 
//If there are POST variables
if ($_POST) {
 
//Initialize the $kv array for later use
$kv = array();
 
//For each POST variable as $name_of_input_field => $value_of_input_field
foreach ($_POST as $key => $value) {
 
//Set array element for each POST variable (ie. first_name=Arsham)
$kv[] = stripslashes($key)."=".stripslashes($value);
 
}
 
//Create a query string with join function separted by &
$query_string = join("&", $kv);
}
//Check to see if cURL is installed ...
if (!function_exists('curl_init')){
die('Sorry cURL is not installed!');
}
 
//The original form action URL from Step 2 :)
$url = 'https://www.salesforce.com/servlet/servlet.WebToLead?encoding=UTF-8';
 
//Open cURL connection
$ch = curl_init();
 
//Set the url, number of POST vars, POST data
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, count($kv));
curl_setopt($ch, CURLOPT_POSTFIELDS, $query_string);
 
//Set some settings that make it all work :)
curl_setopt($ch, CURLOPT_HEADER, FALSE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, FALSE);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
 
//Execute SalesForce web to lead PHP cURL
$result = curl_exec($ch);
 
//close cURL connection
curl_close($ch);
if($result=='ok')
{
//echo '&lt;script&gt;alert("Posted -- ")&lt;/script&gt;';
}
// Here you can write mysql query to insert data in table.
 
$insert_tbl_index_page= "insert into tbl_form_data(first_name,last_name,street,city,zip,phone,email)values('$first_name','$last_name','$street','$city','$zip','$phone','$email')";
Share
Categories : CURL,PHP Tags :

Boost your website performance with “Page Speed” tool.

Posted by 25 October, 2011 (0) Comment

Page Speed is a family of tools for optimizing the performance of web pages.
The Page Speed browser extensions, available for Chrome and Firefox, allow you to evaluate the performance of your web pages and to get suggestions on how to improve them.
Page Speed Tool Download

Share
Categories : Firefox Tags :

Development With HTML5

Posted by 22 September, 2011 (0) Comment

Share
Categories : HTML5 Tags :

Developer Tools for Chrome

Posted by 22 September, 2011 (0) Comment

Share
Categories : Google Chrome Tags :