I have some data posted in a php file, and to protect me / to distinguish that data from a comma Required text file. All this is fine and should be stiff and straightforward, except that when I look at the file, I think every comma has been written twice: once it should be, and after the data added , But in the form of a comma group Here's what I found:
& lt; Form action = "signup-submit.php" method = "post" & gt; & Lt; Fieldset & gt; & Lt; Legend & gt; New user signup: & lt; / Legend & gt; & Lt; Label & gt; Name: & lt; / Labels & gt; & Lt; Input type = "text" name = "name" size = "16" autofocus required /> & Lt; Br / & gt; & Lt; Label & gt; Gender: & lt; / Labels & gt; & Lt; Label & gt; & Lt; Input type = "radio" name = "gender" value = "m" /> Male & lt; / Labels & gt; & Lt; Label & gt; & Lt; Input type = "radio" name = "gender" value = "f" / checked / gt; Women & lt; / Labels & gt; & Lt; Br / & gt; & Lt; Label & gt; Age: & lt; Input type = "text" name = "age" size = "6" maxlength = "2" expected & gt; & Lt; / Label & gt; & Lt; Br / & gt; & Lt; Label & gt; Personality Type: & lt; Input type = "text" name = "PTIP" maximum length = "4" size = "6" required /> gt; & Lt; / Label & gt; & Lt; Br / & gt; & Lt; Label & gt; Favorite OS: & lt; Select Name = "OS" & gt; & Lt; Option value = "window" & gt; Windows & lt; / Option & gt; & Lt; Option value = "Mac" & gt; Mac OS X & lt; / Option & gt; & Lt; Option value = "Linux" & gt; Linux & lt; / Options & gt; & Lt; / Select & gt; & Lt; / Labels & gt; & Lt; Br / & gt; & Lt; Label & gt; Demand for age: & lt; Input name = "minimum" type = "text" size = "6" maximum length = "2" placeholder = "minimum" required /> Input name = "max" type = "text" size = "6" maximum length = "2" placeholder = "max" is required & gt; & Lt; / Labels & gt; & Lt; Br / & gt; & Lt; Input type = "submit" value = "sign up" /> & Lt; / Fieldset & gt; & Lt; / Form & gt;
^ This code posts "user data" into signup-submission.php where it is stored in the variable by the same var names.
$ name = $ _POST ["name"]; $ Age = $ _POST ["age"]; $ Gender = $ _POST ["gender"]; $ PType = $ _POST ["PT Type"]; $ OS = $ _POST ["OS"]; $ Min = $ _POST ["Minimum"]; $ Max = $ _POST ["max"]; $ C = chr (44); $ S = "$ name $ c $ age $ c $ gender $ c $ ptyype $ c $ os $ c $ min $ c $ max"; File_put_contents ("single.txt", $ s, FILE_APPEND); ? & Gt;
and the text file will be copied as a comma without any type:
Byron, 21, m, INP, windows, 18, 23, Variables are data posted from the previous page on this file only, I have tried everything under the sun to save data. In fact, if I only write straight text, then I do not find any problem. When I used the CSV function, I believe me either despite it's formatting, no commas and no data were found.
That's because some of your variables are empty at some time, and you FILE_APPEND
Just comma
To resolve this:
if (! Empty ($ name) & amp; empty ($ age) & amp; ... ... {$ S = " $ Name, $ age, $ gender, $ ptype, $ os, $ min, $ max "; File_put_contents (" single.txt ", $ s, FILE_APPEND);}
User input of values always checks twice. Standard works to clear PPC: You will need input validation with custom rules (for example, to check that a variable is within a certain limit, but This is a different question).
Comments
Post a Comment