Monday, October 24, 2011

How do you upload files in PHP ?

We can upload files by using move_uploaded_file(). There are two parameters for the move_uploaded_file function. One is to specify uploaded file details and other is to specify new file details to be created.
The steps to follow are
    1) Include enctype="multipart/formdata" in the form tag.
    2) Using method post is recommended.
    3) We use $_FILES super global array to get the uploaded file details.
    4) By using $_FILES we can validate the file for size, file type.

Wednesday, October 19, 2011

How will you redirect to a page without header function?

By using Javascript we can redirect the page to another page. And also there are htaccess redirection techniques.

What is a common error caused with header function?

headers already sent output started at some x line is the error. This error occurs when there is an out put generated before the header function.

How do you know whether the headers are sent or not?

We have a function headers_sent(). This function is used to check whether the headers are already sent.

What is the difference between method get and method post?

The first difference is, method get is faster in performance than post. Because, by using post method the data posted is encrypted to cipher data and sent to the server. Where in get the encryption does not happens and it is faster.
    Get method can carry limited amount of data and it is less than post method.
    Post method is secure than get as the data submitted is not visible to the real world. Where as in the get method some one may see the data submitted in the URL bar.
    Using post method We can submit the data to the server only with the help of an HTML form. Where as a get method can send the data to server with a form and also with a HTML hyperlink.