A question about using text fields (TextArea)

Source: Internet
Author: User
When using forms to process information, I found that the processing of text fields is incorrect. For example, in the following table:

---------------------------------------------------------------
Test.html
<Html>
<Head>
<Title> TextArea Test </title>
</Head>
<Body bgcolor = "# FFFFFF">
<Form method = "post" action = "test. php">
File name <input type = "text" name = "filename" value = "test.txt"> <br>
Content: <br>
<Textarea name = "content" cols = "80" rows = "20"> "aaa" "bbb" </textarea> <br>
<Input type = "submit" name = "Submit" value = "written">
<Input type = "reset" name = "Submit2" value = "rewrite">
</Form>
</Body>
</Html>
Test. php
<?
$ Fp = fopen ($ filename, "w ");
Fwrite ($ fp, $ content );
Fclose ($ fp );
Echo "OK ";
?>
------------------------------------------------------
The preceding example is used for testing. To complete the test, you can enter a file name and the content of the file. After confirmation, you can save the file on the server. The following describes the content of a two-file.

Test.html has a form with a text box and a text field. Text box is used to enter the file name to save, text field
Used to input the file content. The default file name is "test.txt", and the default file content is "aaa" "bbb ". The form action is "post" and the execution file is "test. php ".

Test. php is simple. Open the specified file, write the file content, close the file, and output "OK ".

Originally, I thought the file content should be "aaa" "bbb", but the result is not like this, but "aaa" "bbb "! A backslash is added before each double quotation mark (") and backslash () (in fact, there are single quotation marks and null (nul. Why? As a result, I checked the PHP Chinese manual and found magic_quotes_gpc and magic_quotes_runtime descriptions in the PHP. ini configuration. I knew it was because PHP automatically handled it. In this way, magic_quotes_gpc and magic_quotes_runtime in the PHP. ini configuration
If it is set to off, the result is correct.

But what if I cannot change the server? So I checked the string operator processing function again and found that the stripslashes () function can complete this task. In this way, first change PHP. ini to the original format, and then modify test. php as follows:
Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

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.