hfcnew Posted November 2, 2017 Share Posted November 2, 2017 I SWEAR I entered the code for lines 14-17 exactly as in the book: $title = $_POST['title']; $name = $_POST['name']; $response = $_POST['response']; $comments = $_POST['comments']; But the page I got was: Notice: Undefined index: title in C:\xampp\htdocs\tutorialspoint\handle_form.php on line 14Notice: Undefined index: name in C:\xampp\htdocs\tutorialspoint\handle_form.php on line 15Notice: Undefined index: response in C:\xampp\htdocs\tutorialspoint\handle_form.php on line 16Notice: Undefined index: comments in C:\xampp\htdocs\tutorialspoint\handle_form.php on line 17Thank you, , for your comments. You stated that you found this example to be '' and added: So I tried a suggestion I found online and altered the code like so: $title = isset($_POST['title']) ?$_POST['title'] : 0 ; $name = isset($_POST['name']) ? $_POST['name'] : '' ; $response = isset($_POST['response']) ? $_POST['response'] : '' ; $comments = isset($_POST['comments']) ? $_POST['comments'] : '' ; The page I got was the following: Thank you, 0 , for your comments. You stated that you found this example to be '' and added: Why isn't it working? P.S. Is there a way to attach files to posts as with emails? I've got screenshots of what I did. Link to comment Share on other sites More sharing options...
Quinn Posted November 4, 2017 Share Posted November 4, 2017 (edited) Hi, I had the same errors. After much searching and testing different things this is what ended up working. In your feedback.html page add this: <form enctype="form-data/multipart" method="POST" action="handle_form.php"> After updating and saving the feedback.html page the handle_form.php page now works. Remember to refresh the feedback.html page and start again before using it. Edited November 4, 2017 by Quinn Link to comment Share on other sites More sharing options...
Larry Posted November 7, 2017 Share Posted November 7, 2017 Hmm...thanks for sharing what worked for you, although it'd surprise me if that made a difference, but your mileage may vary. The most important question is whether the form is being submitted with data or not. If there's no data, then it should print those errors (as written at that point in the book). Link to comment Share on other sites More sharing options...
hfcnew Posted November 8, 2017 Author Share Posted November 8, 2017 Hi, I had the same errors. After much searching and testing different things this is what ended up working. In your feedback.html page add this: <form enctype="form-data/multipart" method="POST" action="handle_form.php"> After updating and saving the feedback.html page the handle_form.php page now works. Remember to refresh the feedback.html page and start again before using it. Thanks! That worked! Hmm...thanks for sharing what worked for you, although it'd surprise me if that made a difference, but your mileage may vary. The most important question is whether the form is being submitted with data or not. If there's no data, then it should print those errors (as written at that point in the book). I admit I didn't know that I actually had to add "http://" to the URL first. I thought it was already there even if I didn't literally see it in the address bar. BUT even after I did add "http://" it still didn't work. Only after I tried Quinn's suggestion did it work. Is there a reason why I and Quinn have to do something like this but others don't? Are we using versions of certain software that's too old or something? Link to comment Share on other sites More sharing options...
Larry Posted November 11, 2017 Share Posted November 11, 2017 It's great that it's working that way for you but this is really surprising to me. That enctype is only required when a form also submits file data. What browser are you seeing this in? Link to comment Share on other sites More sharing options...
Quinn Posted November 11, 2017 Share Posted November 11, 2017 It's great that it's working that way for you but this is really surprising to me. That enctype is only required when a form also submits file data. What browser are you seeing this in? I'm running all this on Ubuntu Linux 16.04, and used all 3 browsers I have: Google Chrome, Firefox and Ubuntu's browser. I ran the pages many times trying different things, and even with the error checking it didn't help much at all, it just didn't work. After looking around the web and trying stuff (all of which did not work) I thought I'd try enctype="form-data/multipart" after seeing it. I did not expect it to work, but it did, in all 3 browsers. By the way I have to use http:// when I'm working with the Ubuntu browser, it won't work without it. Link to comment Share on other sites More sharing options...
lromao Posted November 15, 2017 Share Posted November 15, 2017 Same thing happened to me. If I use $_REQUEST instead of $_POST everything works just fine, though. Adding enctype="form-data/multipart"> makes it work as well. I'm using Safari (on MacOS High Sierra) Link to comment Share on other sites More sharing options...
hfcnew Posted November 16, 2017 Author Share Posted November 16, 2017 It's great that it's working that way for you but this is really surprising to me. That enctype is only required when a form also submits file data. What browser are you seeing this in? I used Chrome. Link to comment Share on other sites More sharing options...
Larry Posted November 17, 2017 Share Posted November 17, 2017 Sorry I don't have a better answer for y'all, but this has really surprised me. I'd not seen it before. Although to be clear again, it should matter whether form data is being submitted or not (i.e., you shouldn't need the enctype if you're submitting the form). Also, over time you'll learn how to only refer to form values if they have values, which is what really matters. Thanks for sharing the feedback! Link to comment Share on other sites More sharing options...
Vblanco Posted June 12, 2020 Share Posted June 12, 2020 Exactly the same for me!! It's been driving me mad until I found this thread and tried the solution mentioned by Quinn and now it works Link to comment Share on other sites More sharing options...
Recommended Posts