6 | The Basics of PHP Form Handling Tutorial | 2023 | Learn PHP Full Course for Beginners

Поділитися
Вставка
  • Опубліковано 9 лют 2025
  • The basics of PHP form validation is something that is important when learning PHP, and in this tutorial I will show you what you need to get started on the basics of PHP form handling. 🙂
    HTML Form tutorial: • 28 | HOW TO CREATE & S...
    Documentation:
    www.php.net/ma...
    www.php.net/ma...
    www.php.net/ma...
    www.w3schools....
    ➤ GET ACCESS TO MY LESSON MATERIAL HERE!
    First of all, thank you for all the support you have given me!
    I am really glad to have such an awesome community on my channel. It motivates me to continue creating and uploading content! So thank you!
    I am now using Patreon and UA-cam Memberships to share improved and updated lesson material, and for a small fee you can access all the material either from my memberships or Patreon, depending on your preference. I have worked hard, and done my best to help you understand what I teach.
    I hope you will find it helpful :)
    Memberships: / @dani_krossing
    Patreon: / mmtuts

КОМЕНТАРІ • 212

  • @Dani_Krossing
    @Dani_Krossing  Рік тому +128

    A CORRECTION TO THIS VIDEO!
    In the part where I create the exit() function, you need to make sure you place it AFTER the header() function! Otherwise the script is obviously exited before it even runs the header() function. 😂 Me dum dum me see rock smash smash hehe 😂

    • @Dani_Krossing
      @Dani_Krossing  Рік тому +9

      @@mehdimerimi5067 The source code is linked in the description for members 🙂

    • @ShootYourBricks
      @ShootYourBricks Рік тому +4

      I was wondering how that worked😂

    • @Dani_Krossing
      @Dani_Krossing  Рік тому +7

      @Mehdi MERIMI Ah hehe no problem. 😊 I have trouble recognizing sarcasm, and when I also once in a while do get people who wanna "fight me about it" and are actually upset about it, I can be quick to defend my usage of memberships for my files hehe. No hard feelings. 😊

    • @cruzinsweetsntreats
      @cruzinsweetsntreats Рік тому +1

      I was getting the auto check squiggly lines under the location redirect, unlike yourself at 23:16 for the empty value check. Once I figured that out, then saw your response here. 😁 04-16-2023 0404 PT "404 ERROR CODE" 🧐😎🤣

    • @danielbuleandra3981
      @danielbuleandra3981 Рік тому

      well reading this comment would have spared me 3-5 hours of staring into the monitor....just put a pop up comment in the video so other wont burnout trying to figure out

  • @Phil-nc5mw
    @Phil-nc5mw 10 місяців тому +50

    Dude the fact you made an entire course for free is amazing. Thank you so much. I wasted so much money on expensive courses for different languages not realizing I could have just been watching your videos instead.

  • @surangkanangkiangkitiwan4200
    @surangkanangkiangkitiwan4200 10 місяців тому +3

    I just wanted to say a huge thank you for offering this fantastic free course! I've tried learning programming from different places, but your way of explaining things simply is truly amazing. I'm incredibly thankful! 🙏

  • @alynn.art.studio
    @alynn.art.studio 11 місяців тому +4

    14:06 ahhh! This is why some sites break your commas and ampersands!

  • @Helloworld95_11
    @Helloworld95_11 Рік тому +7

    This is better than most schools

  • @cloudagnostic
    @cloudagnostic Рік тому +13

    Great tutorial! I started learning PHP 5 years ago and switched to javascript (nodejs). I always found php much easier and occasionally I do small projects with the language. I might make the switch back after this series!😅

  • @DaAr-vp8cz
    @DaAr-vp8cz 9 місяців тому +2

    that is very useful! I took one PHP course before, but it never mentioned little things like this... glad I have found your course.

  • @yomegram6721
    @yomegram6721 Рік тому +4

    /* this champ should be getting way more likes for his efforts. Big up champ*/

  • @arabellacagolcol3023
    @arabellacagolcol3023 9 днів тому +1

    daaaayymm you're so right about the required att. due to my laziness, i just use it for all my inputs for my capstone 😂 but I did use validations before submitting the data to the database

  • @lucaszecat
    @lucaszecat 8 місяців тому

    Awesome. I really love how you go 360 about everything, including security rules of thumb. I love it !

  • @chrisjohnson9032
    @chrisjohnson9032 5 місяців тому +2

    What a blessing to find your course, THANKS!!!!!

  • @k.ashutoshbaitharu3964
    @k.ashutoshbaitharu3964 Рік тому +4

    I like how you explain stuff in detail.

  • @alexanderbaugher1656
    @alexanderbaugher1656 2 місяці тому +1

    You have done a great job with this course so far.

  • @nedalturas
    @nedalturas Рік тому +2

    Been looking for some PHP tutorials as I need to re learn it, your video is very detailed and I love it.

  • @kehindedeborah8901
    @kehindedeborah8901 Рік тому +2

    i am glad i come across your tutorials

  • @techmillennium6332
    @techmillennium6332 Рік тому +7

    Your way of teaching is great sir. But another thing I want to say sir, u looks like Elon Musk .

  • @mungukendejoshua3632
    @mungukendejoshua3632 Рік тому +2

    u are the man.. much love from Uganda

  • @i-jamesazubuike9208
    @i-jamesazubuike9208 2 місяці тому +1

    Great video! Interesting to know that "required" in the html input can be "manipulated" to get form submitted without a required data

  • @fissionchips223
    @fissionchips223 Рік тому +1

    Another fantastic installment, Dani! While these are getting a little more complex, simply watching a second time makes all the difference. Thanks again for your tremendously helpful tutorials - I am having the best time learning this!

  • @RaccoonEatingCacti
    @RaccoonEatingCacti 3 місяці тому +1

    Very helpful. I hesitated getting into PHP since there's so much hate directed towards it, but so far it seems to be sane. Thanks for covering the security issues.

    • @Dani_Krossing
      @Dani_Krossing  3 місяці тому +2

      Yeah the hate for PHP is mostly VERY misguided hehe. People either hate it because:
      1. It is an extremely easy language to learn, so there is a lot of "bad unsecure" code out there, written by beginners.
      2. People still think that PHP is as bad as it was back in version 5 (which it is NOT anymore).
      3. People will claim that "Python is better", when in actuality you learn PHP and Python for different reasons... I always roll my eyes when people bring up Python as "the only correct choice".
      4. PHP can appear messy, since it is such a loosely typed language. So even if "the code works", it might not be pretty code.
      5. And lastly, and most stupidly... People will say that "PHP is dying"... Just because "they heard some biased person say it was". 😅 When actually, PHP is only getting stronger.
      Honestly, only point 4 is a valid reason for people disliking PHP in my opinion. 🙂

    • @RaccoonEatingCacti
      @RaccoonEatingCacti 3 місяці тому

      @@Dani_Krossing I appreciate the breakdown, that explains a lot. Thank you for these videos! I'm enjoying working with PHP much more than my experience with Django so far.

  • @oluwatofaratiaro1841
    @oluwatofaratiaro1841 5 місяців тому +1

    funny how i understand this in my room in a few minutes than in class a whole semester
    thank you so much.

  • @remasrebas3776
    @remasrebas3776 Рік тому +1

    I'm starting to love php because of you!

  • @kibuzz3258
    @kibuzz3258 Рік тому +2

    wonderful tutorial, i found it very usefull. Thank u a lot, keep going!!!

  • @kevinerose
    @kevinerose Рік тому +2

    Great videos! I am enjoying your format of training. I haven't programmed in 20 years and surprised to see PHP is still popular. Back then we had PHP and ASP (active server pages). Although I left programming before getting too deep into all that. My boss sent me to ASP training but we never really got very far with web development where I was working although they wanted to.

  • @iverikhetagashvili8443
    @iverikhetagashvili8443 9 місяців тому +2

    Thanks for these tutorials Dani 😊😊they are super easy to understand and remember

  • @K.M.Lingaudhaya
    @K.M.Lingaudhaya 7 місяців тому +1

    This was a nice explanation on why to error handle using php. loved it

  • @pelayojhonmeltonmanio8898
    @pelayojhonmeltonmanio8898 9 місяців тому +2

    Thank you so much well explained

  • @George83636
    @George83636 Рік тому +1

    Again great material. A talent in explaining things simply!

  • @moraaoo4889
    @moraaoo4889 Рік тому +2

    Everything is simple with Dani, thanks a lot ❤

  • @sebastiantroncoso366
    @sebastiantroncoso366 7 місяців тому

    I love how he enfatizes on security manners, great course!

  • @CheppaBenkesse-z8t
    @CheppaBenkesse-z8t 3 місяці тому

    Beautiful video

  • @carloberioso2365
    @carloberioso2365 9 місяців тому +2

    Nice

  • @benjicanones1454
    @benjicanones1454 Рік тому +1

    Thank you!

  • @mohammedshawket6005
    @mohammedshawket6005 Рік тому

    i have taken many courses, but sir you are the best

  • @Paulos_Cloud
    @Paulos_Cloud 4 місяці тому

    Thanks Daniel

  • @ismiputri-5209
    @ismiputri-5209 Рік тому +1

    Nice explanation, not only tutorial but the reason why we use code in certain way. Thank you, Dani.

  • @danielolivera2618
    @danielolivera2618 Рік тому

    just found your video. thank you so much, as far as over explaining keep doing it because if you wouldn't have done it i would be lost. THANK YOU!!!

  • @jewelieanne3442
    @jewelieanne3442 3 місяці тому

    love this!! very informative!! thank you

  • @utkarshsrivastava5461
    @utkarshsrivastava5461 Рік тому +1

    Thanx Daniel

  • @sundayemmanuel4789
    @sundayemmanuel4789 Рік тому +1

    Thanks man!

  • @BasiLand-x6o
    @BasiLand-x6o 10 місяців тому +1

    Thanks bro, your tutorial is simple, straight and simple ❤

  • @akashgola2153
    @akashgola2153 11 місяців тому

    Got the points, Got the Correction. 10/10. Also subscribed.

  • @evergreenOV251
    @evergreenOV251 Рік тому +1

    Wow, that's very helpful.

  • @ryyyyy2010
    @ryyyyy2010 Рік тому +1

    Tysm bro, very useful and informative for a beginner like me.

  • @yhwhgraphicstudio1161
    @yhwhgraphicstudio1161 9 місяців тому

    Hi.
    The user can change the required option in the frontend via inspect based on your permission in the file manager.
    Using Chmod 644 for files and 755 for folders will not allow the users change the required option via inspect.
    Awesome tutorial by the way.

  • @priyadharshinimuthukumar8970

    thanks for giving such a good understandable concept when implementing php codes

  • @BeyanHaji
    @BeyanHaji 6 місяців тому

    Thanks for you

  • @abdelrahmanabdallah6308
    @abdelrahmanabdallah6308 11 місяців тому

    Thanks Dani! ❤

  • @guillerjamesmantala7311
    @guillerjamesmantala7311 5 місяців тому

    Thank you sir

  • @sirsebastian2026
    @sirsebastian2026 Рік тому

    Thank you so much!

  • @cholo2605
    @cholo2605 7 місяців тому

    Thanks for your content is amazing

  • @MonsoonKenya
    @MonsoonKenya Рік тому

    Your explanation, I bet you understand it explicitly well.
    Great video Dani.

  • @sheikharooj5762
    @sheikharooj5762 Рік тому

    Simply extraordinary.. Loved it❤

  • @Rocketskibee
    @Rocketskibee 17 днів тому +1

    Getting difficult already but i hope to understand them more as I continue to watch and learn

    • @Dani_Krossing
      @Dani_Krossing  17 днів тому

      It’s completely normal to struggle when just getting started with PHP, when it’s their first language 🙂 it’s just a matter of repetition, until it eventually sticks

  • @jesuopin1612
    @jesuopin1612 Рік тому

    Love this playlist! half an hour long videos and not very long playlist. I might have finished this playlist in less than 1 day and i can already start writting some small php scripts :D

  • @makispariva1651
    @makispariva1651 Рік тому

    Thanks so much for all the deep and at the same time easy explanations!
    PHP was frustating me so much until I found your videos =)

  • @Ithicuss
    @Ithicuss 9 місяців тому +1

    Very nice series so far. Enjoying it a lot. Perhaps a stylistic preference I would like to point out is that at the end of the if statement you have the header function, then an else block and another header pointing to the same address. It might be easier not to have an else statement and just move the header function below the if statement. If the user makes a post request the header function is evaluated after the if statement and if the user does not make a post request the if statement is skipped and the header function is executed. What do you think?

    • @Dani_Krossing
      @Dani_Krossing  9 місяців тому

      The headers are for sending the user back, with a specific message in the URL. 🙂 Either a success message, or a specific error message. So they would need to be at the end of each statement.
      But you are right, because I didn’t actually add the error messages inside the various headers, so as they were left at the end of the video, they are duplicates. So a final last step is to add the error messages. 🙂👍

  • @michaelbica9294
    @michaelbica9294 Рік тому +1

    Hi Daniel, thank you for doing this php tutorials.🍻✌

  • @_ChildofYeshua_
    @_ChildofYeshua_ Рік тому +1

    Send to same form =
    Action = "name of that same form"
    So if your form is on the index.php form then just call that form
    action="index.php" without including the super global. If you're gona use the super global then make sure to sanitize it i.e strip_tags, stripshlashes, trim, html entities etc...

    • @misstallschannel7983
      @misstallschannel7983 Рік тому

      Thank you so much for this comment, Yoh you helped me 😢, I have been here for hours, I was about to give up 🥹

  • @Toussaintiradukunda
    @Toussaintiradukunda Рік тому

    helpful video thank you so much🤩🤩🤩🤩🤩

  • @yomammo
    @yomammo 3 місяці тому

    error handling is very important. sanitizing too. we always cleared or initialized data before exits. but that was in C.

  • @IamtheActionman
    @IamtheActionman Рік тому

    Excellent

  • @kerrywsmyth
    @kerrywsmyth Рік тому

    Liked all and subscribed. Please keep them coming

  • @sonamohialdin3376
    @sonamohialdin3376 Рік тому

    This tutorial is very helpful thank you

  • @Boylagak
    @Boylagak Рік тому

    Thank you sir Dani!❤

  • @koushikshil6037
    @koushikshil6037 11 місяців тому

    Thanks, bro

  • @kavinj4455
    @kavinj4455 Рік тому

    Thank you ! this is super helpful !

  • @estudiar173
    @estudiar173 Рік тому

    thanks

  • @MaximBordyug.
    @MaximBordyug. 7 місяців тому +2

    Thank you. I never thought I would be taught how to create an HTML form by Elon Musk. I think this guy can impersonate him easily. Even his voice is similar :)

    • @Victor_with_a_C
      @Victor_with_a_C 7 місяців тому

      💯💯fr, i hadn't even realised😅

  • @dyinexyi
    @dyinexyi 22 дні тому +1

    "NEVER TRUST THE CLIENT" is one of the things that I learned in this video

    • @Dani_Krossing
      @Dani_Krossing  22 дні тому

      Never ever trust the client.
      It’s like trusting every person in the world not to commit crime, so therefore there is no police.

  • @DevinGeegh
    @DevinGeegh Рік тому

    I love your video!!! I am curious how to throw up an error message on the index page after the exit? Also you mentioned some things after the htmlspecialchars that could be added, curious on that as well. Maybe you cover this in a later video that I haven't been through yet. Anyways... Keep up the awsome work! Thanks!

  • @ramanmhedin1137
    @ramanmhedin1137 Рік тому +3

    thank you for these tutorials,will you use AJAX with PHP and MySQL in the next videos?

    • @Dani_Krossing
      @Dani_Krossing  Рік тому +2

      Later in this course we will get into MySQL yes. 🙂 AJAX I think however belong in a separate course, since it is mostly JavaScript.

  • @ryanm.122
    @ryanm.122 7 місяців тому

    @20:20 How do you send the user back with the error message or send the user to another page with the data we just collected?

  • @krishnashrestha6040
    @krishnashrestha6040 11 місяців тому

    One of the best tutorial.
    And bro looks like Elon😅

  • @RAHAT_ME
    @RAHAT_ME Рік тому

    and thanks 😀

  • @infinity_ahashara
    @infinity_ahashara Рік тому +1

    you explaining very well !

  • @Victor_with_a_C
    @Victor_with_a_C 7 місяців тому

    i love your mustache btw

  • @mandy1784
    @mandy1784 Рік тому +1

    is that security issue still true for frontend frameworks like React or Vue? Thanks for the vid!

    • @dyinexyi
      @dyinexyi 22 дні тому

      I think it does, any thing that represents the client. Just don't trust the client

  • @mohammadsulaiman2301
    @mohammadsulaiman2301 3 місяці тому

    🥰🥰

  • @phpcoderforever
    @phpcoderforever Рік тому +1

    thank you Dani.
    is htmlspecialchars function used with string inputs what about if data submitted of type integer or float or boolean should I put htmlspecialchars??

    • @Dani_Krossing
      @Dani_Krossing  Рік тому +1

      You can use htmlspecialchars() for that too yes, however we do also have more specific sanitization functions you can use for non-string data. Such as filter_var or filter_input.

  • @Behemoth3434
    @Behemoth3434 2 місяці тому

    18:19 Were the users able to see/obtain the code of our formhandler.php?

  • @Websitecorner
    @Websitecorner Рік тому

    hi, thanks for the video , I have a question , when I save the file as PHP, auto closing tags doesn't work anymore , it works fine in html files but not in php ! do you have any idea? thanks

  • @marweshemello1090
    @marweshemello1090 6 місяців тому

    hi on my site instead of echoing user inputs i get this massage "Warning: Undefined variable $_name " did you ever get that and how do you resolve it?

  • @celebrityviralofficial
    @celebrityviralofficial Рік тому

    Please make a video on how to create new project with backend and frontend that have admin control

  • @KayleighOfSuburbia
    @KayleighOfSuburbia 8 місяців тому

    could you/should you use "required" on the client-side as well as the server-side validating of the empty field? or is that unnecessary?

    • @Dani_Krossing
      @Dani_Krossing  8 місяців тому +1

      “required” is just there to give a visual indicator. 🙂 You’ll even notice that even though it is supposed to prevent the form from being submitted, if you spam the submit button fast enough, it will still occasionally submit the form… So security wise, “required” is pointless in itself.
      So if you feel that you wanna add it in, go ahead. 🙂 It is an easy and fast way to notify a user, if they forgot to fill in an input. Just know that it is ONLY a visual indicator.

  • @Old_school_odyssey
    @Old_school_odyssey 11 місяців тому

    Great video... I've gone wrong somewhere though. I only have the select option for 'Favourite pet' and no text box to type any other information in for Firstname and Lastname. Where did I go wrong?

  • @RAHAT_ME
    @RAHAT_ME Рік тому +2

    This tutorial is very helpful thank you
    but one thing plz upload it daily

  • @arnelmaghirang8426
    @arnelmaghirang8426 3 місяці тому

    Thanks sir Dani! May I ask if what is the main difference between isset and server[request_method] =="POST"?

    • @Dani_Krossing
      @Dani_Krossing  3 місяці тому

      Both do something completely different, and it is common to see people use isset() for submits like these, which is considered a "beginner habbit". 🙂 (I have made the mistake of using it too).
      So essentially... isset($_POST['submit']) checks if a HTML submit field has been passed, and server[REQUEST_METHOD] checks if the form is submitted via the POST method.
      When do you use which? 👇
      Use isset($_POST['submit']) when you want to verify if a specific form was submitted and processed (since different forms might have different submit buttons).
      Use $_SERVER['REQUEST_METHOD'] when you want to detect whether a form was submitted using a particular HTTP method (POST or GET) and it doesn’t depend on any specific form field.
      Or explained in simpler terms...
      So use $_SERVER[''] to check if a form has been properly submitted using a specific HTTP method like GET or POST, and use isset() to check if a SPECIFIC form on your website has been submitted. 🙂
      You can of course use both, to create even better form submission handling. 👍

  • @Rooworld665
    @Rooworld665 7 місяців тому

    How would you view the persons information that they type after setting the user back into the home page?

  • @amiramohammed1568
    @amiramohammed1568 Рік тому

    👏🏽👏🏽👏🏽👏🏽👏🏽👏🏽👏🏽👏🏽👏🏽👏🏽👏🏽

  • @ruudkorunka
    @ruudkorunka Рік тому

    Good afternoon, Dani. Thanks for all your tutorials.
    Question:
    I feel that I have to choose between Javascript and PHP.
    For front-end coding and eventually also for back-end coding.
    What do you say, Javascript or PHP?
    Greetings,
    Ruud (Amsterdam, Holland)

    • @Dani_Krossing
      @Dani_Krossing  Рік тому +2

      Hi. I'm a bit confused by the question.
      You say you need to learn a front-end and a back-end language? Then it makes sense to learn both, seeing JavaScript is front-end, and PHP is back-end. 🙂
      JavaScript CAN be learned as a back-end language as well, if done so through frameworks like Node.js... But PHP is still vastly more popular as a backend choice.

    • @ruudkorunka
      @ruudkorunka Рік тому +1

      Thank you.

  • @thecrypticaura
    @thecrypticaura 6 днів тому

    20:10 don't U have to have the exit()
    After you've redirected the user to the home.....?

    • @Dani_Krossing
      @Dani_Krossing  6 днів тому

      Yes :) My pinned comment explains this as well, since I accidentally told people to put it before the header()

  • @2684dennis
    @2684dennis 8 місяців тому

    hi could you please show the css sheet how you styled this form, im struggle to get every thing alignd and center, i would like to see how you did all that. thank you.

    • @Dani_Krossing
      @Dani_Krossing  8 місяців тому

      All my personal lesson files are available to members in the description 🙂

  • @emmanuelameyaw7
    @emmanuelameyaw7 Рік тому

    Hee taught HTML and PHP together

  • @desireude4068
    @desireude4068 Місяць тому

    I am watching this from 2024
    It's an amazing course
    But I ran into a bit of a problem
    This for you are creating is it in a completely new folder that isn't inside that initial xampp file we downloaded first?

  • @MohammedAlziko
    @MohammedAlziko Рік тому

    😘😘😘

  • @syedalishah7141
    @syedalishah7141 4 місяці тому +1

    MR BEAST is here😆😆

  • @fyreweaver91
    @fyreweaver91 6 місяців тому

    When i follow up to 18:35 with the header line, instead of it going back to the form it get 403 forbidden error code. can anyone help me? ive followed the code word for word and the previous videos everything has worked up until this point. the code still works until i copy Dani's code:
    header("Location: .../index.php");
    } in which Dani's video it jsut redirects him to his form, as where when i use the code i get 403 forbidden when i submit the form

    • @fyreweaver91
      @fyreweaver91 6 місяців тому

      Never i was using three dots instead of 2 for going back in the directory!

  • @KennedyAni-l4o
    @KennedyAni-l4o Рік тому

    More of security videos about PHP

  • @samaugustinejunior5679
    @samaugustinejunior5679 8 місяців тому

    Any time i try connecting the index.php to my formhandler.php i ger a no server found message