PHP entry-form processing problem summary _ PHP Tutorial

Source: Internet
Author: User
Tags echo name
PHP entry-Summary of form processing issues. PHP entry-Summary of form processing problems learned over the past few days. PHP and CC ++ have many similarities. so it seems that there is no problem with getting started. however, we chose a PHP entry-form processing problem summary.

I have learned this over the past few days. PHP and C/C ++ have many similarities. so it seems that there is no problem with getting started. however, because I chose a quick start book, it is inevitable that some knowledge points are rough. for example, the following two questions make me suffer a loss.

1. the file tag of the form cannot get the file name.

I learned from books that forms

Enter your personal information name:
Student ID:
Email:
Password:
Confirm password:
Avatar:

By collecting information, we found that many of you encountered the same problem. it may be the same as what I read. however, after some efforts, I found the cause. it turns out that html only supports text/html file transmission by default. the form must be supported in multiple formats. so the solution is. add the attribute enctype = multipart/form-data in form. OK to solve the problem.

The contents of my regist. php are as follows:

 ;echo name is .$_POST[username].;echo number is .$_POST[id].;echo mail is .$_POST[mail].;echo password is .$_POST[password].;print_r($_FILES);?>
Upload a file and test it:

The input interface is as follows. I write some information. because it is a character interface, I wrote the Avatar part.

The output interface is as follows. the file is informative. name indicates the file name on the client, and type indicates the file type. tmp_name indicates the temporary file name on the server.

2. the image tag of the form does not display the image.

This problem was also encountered during college and was resolved at that time. but after so many years. where can I remember. however, after trying a few times, I think of a solution.

At first, the path I specified was my other directory. therefore, the image cannot be displayed. I put the image in the root directory of apache, that is, under the/var/www/html directory. think too. if any file can be displayed, why does apache need to configure ROOT_DIRECTORY.

3. php garbled

We know that on the html page, encoding is specified by specifying http-equiv through meta tags. however, after the php page is redirected, the tag becomes invalid. php becomes garbled again. what should I do? there must be ready-made functions available for use. so I checked it online.

Add the header (Content-Type = text/html; charset = utf-8) at the beginning of the PHP file. solve the problem.

OK. this is some of the problems encountered in learning PHP over the past few days. to sum up, especially the first question, I found a reasonable explanation after a long time. in the next few days, I will continue to deepen my understanding and strive to write a small thing this week.

I learned from these days. PHP and C/C ++ have many similarities. so it seems that there is no problem with getting started. but because I chose a copy...

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.