Getting Started with PHP-summary table handling issues

Source: Internet
Author: User
Tags getting started with php

A few days to learn to come down. PHP and C + + have too many stages to tie. So, a simple entry now seems to have no problem. However, since the selected entry is a high-speed book, there is inevitably some rough knowledge. For example, the following two questions let me eat some losses.

1. File name cannot be obtained in the form of label.

Learned in the book, the form <form> has three attributes, method, Action,name. Then the name of the form is labeled, and method indicates which method is used to submit the expression, optional get/ post.action specifies the action to handle the form. You can specify a PHP page or simply work on the current page. This is really wonderful and convenient. Because the form only has to specify PHP pages, variables or anything are shared with PHP.

The following optional label for the form has input select option TextArea, where option is a sub-label of SELECT.

and input can be expanded into a very multi-category label, specified by the type attribute of input. The main I touch now is the text password file submit reset image. From left to right, is text, password, file, commit, reset, picture. The meaning of the picture here is not to show, but to replace the use of submit. The file property provides a channel for users to upload files. The example I gave in the book, I knocked a bit, and tried to get the file information, but always failed, The return is always empty. There is no explanation whatsoever in the book. Source code such as the following:

Through the collection of information, it is found that a lot of classmates have also encountered the same problem. Maybe it's the same book that I read. It was only after some effort that I found the reason, originally because by default, HTML only supports text/ File transfer in HTML format. The form needs to be supported in multiple formats. So the solution is. Add the attribute enctype= "Multipart/form-data" to the form. Ok problem solved.

The contents of my regist.php are as follows:

<?phpheader ("Content-type:text/html;charset=utf-8"); echo "User info is as follow: <br>", echo "name is". $_post [Username]. " <br> "; echo" number is ". $_post[id]." <br> "; echo" Mail is ". $_post[mail]." <br> "; echo" Password is ". $_post[password]." <br> ";p rint_r ($_files);? >
Upload a file and test it:

Input interface such as the following, I write some information, because it is a character interface, so the avatar part of my handwriting in.

The output interface is as follows. The ability to see the file is informative. In the name of the client, type represents the file type. tmp_name represents the temporary file name on the server side

2. The image label of the form does not display the image.

The problem was met at the university, when it was conquered. But in a blink of an eye so many years passed. Where do you remember? Just luck, try to think of a solution.

The path I specified originally was my other folder. So the picture can not be displayed, and then I put the picture in the root folder of Apache work, that is, the/var/www/html folder, it will be able to display the normal. Think about it too, assuming that the files everywhere can be displayed, Apache Why we have to configure the work root_directory it.

3. PHP garbled problem

We know that in an HTML page, the coding problem is specified by a meta tag that specifies HTTP-EQUIV. But after jumping to the PHP page, the tag fails. PHP has become garbled. What to do, presumably there must be a ready-made function can be used. So I looked it up on the Internet, and sure enough.

Add the header at the beginning of the PHP file ("content-type=" Text/html;charset=utf-8 ");


Ok. This is some of the problems that have been encountered in learning PHP these days. To sum up, especially the first question, it took a long time to find a reasonable explanation. The next few days I will continue to deepen the understanding that this week can write something.


Copyright notice: This article Bo Master original article. Blog, not reproduced without consent.

Getting Started with PHP-summary table handling issues

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.