This is a one of most common issue we have. Imagine if your site takes more than 10 seconds to load or start render the contents, actually it is a long time and really bad which will directly affect your targeted traffic. Would you wait with a cup of coffee and watching your screen until a web page finished loading ? You never and same your visitors. So let us discuss about some of interesting tips on How to make a web page optimized to load in a short time. A short loading time = A Happy visitor.
In the very step I am going to share some useful online tools where you can have ideas about your site on what are the things I should fix in my site.
1. Page Speed tool from Google labs.
This is actually a very good tool, you can find it here http://pagespeed.googlelabs.com. Just enter your site URL and it will give you a page speed score and a lot of important suggestions on where and what are the points you should improve on optimizing the site.
2. Web Page Test
This is also a very good tool and my favourite one too. Find it here http://www.webpagetest.org/. With this tool you can test your site, how it will load in different parts in the world and different browsers. This tool will give you a great report of your site optimization as well as an optimization checklist. Just give it a try.
3. Google Webmaster Tools
The Google's webmaster tools is a power tool you can use to have details of your site. If you haven't a google's webmaster account yet, I strongly suggest you to open one, enter your site there and verify. Wait for few days until Google collect information about your site. Then you can use those details to optimize and as well make SEO of your site.
The tools I mentioned above are just free. So give them a try.
Once you have understood how and where you should get your hands dirty on your site to make it optimize to gain more targeted traffic, you can start working with a clear plan.
Tuesday, May 17, 2011
Wednesday, January 12, 2011
Handling File Uploads with PHP
Lets have a look how to handle a file upload using PHP.
First we need to create a form to upload our file as below.
Allowing people to upload files to your web site is putting you in risk, unless you do not check what they are uploading. In this example we are checking the file size and the file type of the uploaded file. Below PHP is going to do the rest for you. The uploaded files are going to save in a folder "upload". Rename it with your folder name.$imgName = $_FILES["file"]["name"];
if ((($_FILES["file"]["type"] == "image/gif") || ($_FILES["file"]["type"] == "image/jpeg") || ($_FILES["file"]["type"] == "image/pjpeg")) && ($_FILES["file"]["size"] < $_POST['MAX_IMG_SIZE'])) {
if ($_FILES["file"]["error"] > 0)
{
echo "File upload Error.";
echo "Return Code: " . $_FILES["file"]["error"];
}
else
{
if (file_exists("../upload/".$imgName))
{
echo imgName . " already exists. ";
}
else
{
move_uploaded_file($_FILES["file"]["tmp_name"],"../upload/" . $imgName);
echo "File stored in: " . "upload/" . $_FILES["file"]["name"];
}
}
}
else
{
echo "Invalid file type or file size too large";
}
Thursday, November 4, 2010
Prevent Multiple Submission of the Same Form
In this post I would like to suggest a way to guard against resubmitting the same form. If you don't have an option in your code, to prevent the same form from resubmitting then you can identify that your database is just filled with the same data.
We can point variety of reasons for resubmission the same form. Double clicking the submit button, hit their browser back button to edit or recheck the form and hit the submit button again are some examples.
You can place a unique Id in your form by using PHP uniqid() function, like shown below.
We can point variety of reasons for resubmission the same form. Double clicking the submit button, hit their browser back button to edit or recheck the form and hit the submit button again are some examples.
You can place a unique Id in your form by using PHP uniqid() function, like shown below.
$unique_id = uniqid(microtime(), 1); echo ''; //place this line your form to have a hidden field.When saving the form data check whether the form is already saved in the database or not by checking the unique_id like below. If the unique_id is not exist then you save the form data in the database and the unique_id beside the form data.
$unique_id = $_POST['unique_id']; // I assumed that the form is submitted by post method.
$query = "SELECT * FROM your_table_name WHERE unique_id = '".$unique_id."'"; //in your table you need a column named unique_id.
$result = mysql_query($query);
if(mysql_num_rows($result)){
//if true, the form is already submitted. Don't save.
}else{
// save the form
}
Subscribe to:
Posts (Atom)