Results 1 to 4 of 4

Thread: Enctype="text/plain" - Can someone explain why?

  1. #1
    Senior Member
    Join Date
    Jan 2008
    Posts
    204
    Thanks
    5
    Thanked
    5 times in 5 posts

    Enctype="text/plain" - Can someone explain why?

    Hello,

    I have created a database and wrote some php to connect to it. I then added another page which contained a form and an input field. When you entered data in the field, it would search a field in the database for a match and then display the results. For some reason the form wasn't passing the information over the PHP page. In the end I figured out it was because of this:

    Code:
    Enctype="text/plain"
    I don't know what was causing this to happen. Can someone please explain?

    Thanks,
    Steven

  2. #2
    Comfortably Numb directhex's Avatar
    Join Date
    Jul 2003
    Location
    /dev/urandom
    Posts
    17,074
    Thanks
    228
    Thanked
    1,027 times in 678 posts
    • directhex's system
      • Motherboard:
      • Asus ROG Strix B550-I Gaming
      • CPU:
      • Ryzen 5900x
      • Memory:
      • 64GB G.Skill Trident Z RGB
      • Storage:
      • 2TB Seagate Firecuda 520
      • Graphics card(s):
      • EVGA GeForce RTX 3080 XC3 Ultra
      • PSU:
      • EVGA SuperNOVA 850W G3
      • Case:
      • NZXT H210i
      • Operating System:
      • Ubuntu 20.04, Windows 10
      • Monitor(s):
      • LG 34GN850
      • Internet:
      • FIOS

    Re: Enctype="text/plain" - Can someone explain why?

    enctype defines how the data should be formatted before sending. the two correct formats are application/x-www-form-urlencoded (which essentially sends things as key=valye&anotherkey=anothervalue, with http headers) and multipart/form-data (which splits each key up into a distinct section of data). text/plain means nothing should be done - its behaviour is essentially undefined between browsers, and was only ever used for automated email forms in the days before spam. use application/x-www-form-urlencoded for text forms (or leave this to use the default setting) and multipart/form-data for file attachment uploads

  3. #3
    Senior Member
    Join Date
    Jan 2008
    Posts
    204
    Thanks
    5
    Thanked
    5 times in 5 posts

    Re: Enctype="text/plain" - Can someone explain why?

    Thanks for your reply. What exactly was the text/plain doing to the value entered in the input field (a number) for it not to pass the data over?

  4. #4
    Comfortably Numb directhex's Avatar
    Join Date
    Jul 2003
    Location
    /dev/urandom
    Posts
    17,074
    Thanks
    228
    Thanked
    1,027 times in 678 posts
    • directhex's system
      • Motherboard:
      • Asus ROG Strix B550-I Gaming
      • CPU:
      • Ryzen 5900x
      • Memory:
      • 64GB G.Skill Trident Z RGB
      • Storage:
      • 2TB Seagate Firecuda 520
      • Graphics card(s):
      • EVGA GeForce RTX 3080 XC3 Ultra
      • PSU:
      • EVGA SuperNOVA 850W G3
      • Case:
      • NZXT H210i
      • Operating System:
      • Ubuntu 20.04, Windows 10
      • Monitor(s):
      • LG 34GN850
      • Internet:
      • FIOS

    Re: Enctype="text/plain" - Can someone explain why?

    stolen from Form Data Encoding Roundup :

    text/plain:
    Code:
    Content-Type: text/plain
    ================================================================================
    foo=bar
    baz=The first line.
    The second line.
    application/x-www-form-urlencoded:
    Code:
    Content-Type: application/x-www-form-urlencoded
    ================================================================================
    foo=bar&baz=The+first+line.%0D%0AThe+second+line.%0D%0A
    multipart/form-data:
    Code:
    Content-Type: multipart/form-data; boundary=---------------------------314911788813839
    ================================================================================
    -----------------------------314911788813839
    Content-Disposition: form-data; name="foo"
    
    bar
    -----------------------------314911788813839
    Content-Disposition: form-data; name="baz"
    
    The first line.
    The second line.
    
    -----------------------------314911788813839--
    you can see how the first one is useful for passing values UNCHECKED directly into an email program (e.g. if your form uses a mailto: address, so it uses your visitor's email program to send) but is largely useless for programmatic access to fields. only the bottom 2 examples are valid for actual form-based form data

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Can you explain the 'Order/Stock' Issues To us?
    By Blitzen in forum SCAN.care@HEXUS
    Replies: 6
    Last Post: 22-07-2007, 02:59 PM
  2. Can some one explain pixel processors
    By yan816 in forum Graphics Cards
    Replies: 4
    Last Post: 25-10-2006, 09:49 PM
  3. LCD monitors - can someone please explain...
    By chet in forum Graphics Cards
    Replies: 7
    Last Post: 15-04-2005, 02:37 AM
  4. Someone explain betting for me! Grand National
    By Tifosi in forum General Discussion
    Replies: 8
    Last Post: 09-04-2005, 03:41 PM
  5. Explain your..
    By Russ in forum General Discussion
    Replies: 20
    Last Post: 12-10-2003, 10:43 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •