Getting Started with PHP-form processing issues Summary _php Tutorial

Source: Internet
Author: User
Tags echo name getting started with php

Getting Started with PHP-Summary of form processing issues


These days of learning down. There are too many similarities between PHP and C + +. So the simple entry now seems to be no problem. But because the selection is a quick-start book, it is inevitable that some of the knowledge points are rough. For example, the following two questions let me eat a bit of a loss.

1. The file label for the form cannot be retrieved to the filename.

Learned in books, forms

<title></title>

Please enter your personal information

Name:
School Number:
Mailbox:
Password:
Confirm Password:
Avatar:

Through the collection of information, found that many students also encountered the same problem. Maybe it's the same book that I read. But finally after some effort to find the reason, originally because the HTML only support text/ File transfer in HTML format. The form requires multiple formatting support. So the solution is. Add the attribute Enctype=multipart/form-data in the form. Ok problem solved.

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 the character interface, so the avatar part of my handwriting in.

The output interface is as follows. You can see that the file is informative. where name represents the file name on the client, type represents the file type. tmp_name indicates a temporary file name on the server side

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

The problem was also met at the university, when it was settled. But the blink of an eye for so many years has passed. But the luck number, tried a few times and then remembered the solution.

The path I specified originally was my other directory. So the picture can not be displayed, and then I put the image in the root directory of the Apache work, that is, the/var/www/html directory, it can be displayed normally. Think about it too, if 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 the HTML page, the coding problem is specified by means of the META tag http-equiv. But after jumping to the PHP page, the tag fails. PHP has been 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 header (Content-type=text/html;charset=utf-8) at the beginning of the PHP file;

Ok. This is some of the problems that have been encountered in learning PHP these days. Summing up, especially the first question, it took a long time to find a reasonable explanation. I will continue to deepen my understanding for the next few days and try to write a small thing this week.

http://www.bkjia.com/PHPjc/970255.html www.bkjia.com true http://www.bkjia.com/PHPjc/970255.html techarticle Getting Started with PHP-form processing issues Summary these days of learning down. There are too many similarities between PHP and C + +. So the simple entry now seems to be no problem. But because the choice is a book ...

  • 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.