Object Oriented PHP #14 - Validation Class (part 3)
Вставка
- Опубліковано 19 вер 2024
- Hey gang, in this final PHP OOP tutorial we'll finish off our form validation class, test it out & then show errors / feedback to the user based on their input.
----------------------------------------
🐱💻 🐱💻 Course Links:
Course files - github.com/iam...
🐱💻 🐱💻 Other Related Courses:
+ PHP Tutorial for Beginners - • PHP Tutorial for Begin...
The best tutorial OOP php
Hey! Soo for everyone having an error in the input fields - it happens because htmlspecialchars function tries to run with $_POST data, which is null, since we havent submitted the form yet.
Here is the code that makes a little check before sanitizing inputs:
Thanks so much. I was looking for a solution to this.
Thanks man! u seved my project :D
@@jakubdura8452 You are welcome)
lifesaver
But why did Shaun not have this problem in his video? Did the function change behaviour with time?
Your lecture is so perfect that even though I am trying to learn java and understand OOP, I learn OOP concept with these PHP series by you.
I watched the entire series in less than a day and it has definitely upped my game. Thanks man.
A big, big thanks to you, Shaun. This was sooooo rich. I'm really grateful for the knowledge I've gained from you. I'm quite at beginner level, and I'm never gonna forget how much this has helped me move up. Thank you.
Thanks Oscar :)
Minute 8:00... you don't have any idea how much time I spent on the internet trying to figure out how to preserve the input data, and in just a few seconds you solved my problem. A thousand thanks my friend.
Aha, glad it helped Davide! :)
Thanks very much sir, really one of the best PHP series I've watched
from all video tutorials in UA-cam, this channel is the most easiest to understand. You deserve more views and likes.
When entering page the first time I get
"Notice: Undefined index: username in D:\...yadayada"
in name field. And the same goes for email.
Otherwise it works.
Really great series man, much appreciated!
try this mate
echo htmlspecialchars($_POST['username'] ?? '')
@@pengdiss513 Thank you. Much appreciated. This worked
How did you solve this problem?
Just Love Your Tutorials...!!! Learning Is Our Fundamental Right... And You are The "GURU"...
❤️ From India
Thank you!!! Finished your php beginner's course and just finished this one. Everything was well explained! Thank you again for all your efforts!
This is the best series on Php OOP I've found.
The best series on PHP OOP ever! Thank you very much
Thank you so much Shaun!! you keep sharing this very explanatory and detailed tutorials and making us better ninjas!
Yay i like this :).It would be great to see in your implementation an object-oriented php course for a small application, e.g. a simple eCommerce store with an administrator desktop etc. But independently it was a great series - both OOP and for beginners. PHP has a lot to offer and simplifies a lot in simpler browser applications than using e.g. javascript (with continuous reference to DOM) or angular in combination with firebase. Thanks again!
Completed the course.
Very helpful & well done.
Thank you 🙏🏼
I was watching some of the videos Today again and I realized that it would be nice if there were a couple of videos including MySQL with classes a and a little project at the end the same as ninja pizzas but this time with classes!
Thank you very much..
I love this series. Thanks for sharing your knowledge.
Miraculous, fantastic, and inspiring way of teaching in this series and others :)
THANK YOU FOR THIS SERIES AND EVERY VIDEO YOU POST HERE ON UA-cam.
Thank you The Net Ninja so much for helping me in the very first steps in php. I wish you all of the best.
Alright another tut done, php oop was best interesting. I noticed that the tut and the practical example are 2 different levels, im happy you said at 2:30 that there are many ways to do this. Im also used to monolithic and modular coding style. Soon i will start making a real time chat application with pho but i really want to do oop method doing that, definitely need to practice some more
thanks for this series for php. I read at one of comments below, that with php, you will start a series on laravel. Please before that, make a series about PDO by transform the first series of php with mysqli into pdo. After that my recomendation would be talk about autoload ( first a manual way ) and then with composer. To finalize, a video about namespace. Thanks. ;)
Man you are amazing teacher. I have learned from you so many things in past years. This php series was great also. Can you do some videos about design patterns in PHP?
Best Tutorial with an example
the best simple oop explanation on the whole web ♥️..
Amazing presentation and style and utility.
Thank you very much Sir.
Thanks for the kind words Adolf :)
Best Teacher ever
hopefully i'm a member in your channel youtube.
the most simpliest tutorial about OOP in PHP you make it easy to absorbe and to understand thank you Shaun . my best regards
excellent! watched PHP Tutorial for Beginners and this curse and i enjoyed it and learned so much. can you do a MVC structure for Beginners?
This demo is excellent. Thank you.
Thank you for this very helpful tutorial !!!
I wanted to get a better understanding for this OOP concept in PHP and your tutorial allowed me to do so in a very short time.
Cheers!
Thank you. There is a bug right at the very end. htmlspecialchars thows an error when you load the form before submitting. It fails with null values. To fix this bug use this code instead:
value=""
or htmlspecialchars($_POST['username'] ?? '')
Hi Shaun, thanks for a great tutorial.
I find that where you have passed the $_POST['username'] etc. back to the form, it is being sent back as the user typed it, should you not send it back already trim($_POST['username']), so that the user can see the data without the spaces on the front and rear of the entry?
Great
the best tutorial oop php in youtube it's amazing
Are you going to add videos to this playlist? Several topics are missing out... (abstract classes, interfaces, differences between them)
I am from $iraq->kurdistan , Thanks for sharing your knowledge
when reloading the page, mine outputs, undefined array key. The following is my code
Thaaaank you shaun! great tutorial!
??? -> Warning: Undefined array key
i'm just curious about something, why we arent using html attr for inputs like requiered and checking with javascript would be more convenient? of course checking with php more secured but for i'm talking just displaying errors
thank you shaun a lot for this series
You are perfect, sir!
Great series
Thanks Mortal!
You're among the very best.
Wish you could do something similar with database search in a web site
Best Sensei ever!
I would have liked to see an example with radio buttons and checkboxes.
Thank you very much, Mr Ninja. This was a very helpful little tutorial.
Thanks for your Awesome Tutorial Playlist!
if I don't put the NULL COALESCING operator inside the htmlspecialchar BRACKETS it gives me an error, not like in the video, in which are outside the brackets, anyone else?
Hello Shaun, do you have any plans for updating your PHP and Laravel course on UA-cam or elsewhere? And if so then please let us know the probable time frame. 😇
Very useful stuff
Do you have any videos on Object Oriented PHP dealing with databases e.g. MYSQL?
thanky you very much, and please add tutorials anout nuxt.js
Really thank you, bro!!!!!
from Nairobi Kenya ...Thenks Ninja
Thank you mate!
Great playlist! Thanks dude!
fantastic
This php series was nice .
Thanks for this series. What are your plans for future series?
I will be doing a series on Laravel in the future. Up next though is Flutter with Firebase :)
@@NetNinja Laravel is great. I hope you set it up as an API with authentication. In a later series you could connect to it using a Nuxt front end.
@@NetNinja I´m waiting for the Laravel course.
Thank you so much from Germany!!! awesome tutorial, very easy to understand from ur explanation.
i just started `Code Ninga and it's amazing!
Thanks 🙏🏼
Thank you very much for this tutorial, it is very helpful!
brother thank you very much you are doing a great job.I am a big fan of yours.
why do we add htmlspecialchars in an input tag instead of if(isset($_POST['submit'])) ?
Does htmlspecialchars function evaluate that value before it was submitted?
thanks for this
It was perfect. Thank You!
Thank you so much!!!
You're welcome! :) hope it helped
after completing this series and deeply seen the codes, I am confused is this
foreach (self::$fields as $field) {
if (!array_key_exists($field, $this->data)) {
trigger_error("$field is not present in data");
return;
}
}
is this really need? i can not find this usability. When actually this code will work?
I don't think is needed because the key is not something that the user can modify but something that is being hard coded so :/ there's always gonna be an username and email key because we said so when adding the forms
You'll appreciate it when there are a lot of fields and you don't want to hard code them so it's useful
thanks for tuts
you are awesome ninja
Where did you learn all this things and how do you learn it, you cover alot of stuff in this channel, I wanna know your screet jutsu
awesome tutorial :3
Thanks! 😄
Thanks bro❤
No probs! 😊 thanks for watching
you are amazing bro , Thank u so much
Thanks a lot. I wish you could build some pho projects without much explanations. Just build so we can code along. You don't have to explain. 🙏🏾🙏🏾🙏🏾
hi guys, I'm pretty new at PHP, I have a question, should i make a CLASS for REGISTER USER and another CLASS for VIEW USER LIST?
which tutorial should I go into after that ?
THANK YOU VERY MUCH!!! I cant thank you enough
🙏🙏🙏🙏🙏
Why don't you continue this course in advanced level such as making full site
please!
Thank you so much
Okay I rewinded the video twice to check if I made any mistake and it seems that everything is correct and I got an error at the very end when I try to echo the value of the ' email ' and ' username ' and I think I created a new error in PHP lol can I have any help please ?
genius
what if the form action was leading to a seperate page ? how would have shown the error?
You use JavaScript to prevent it, such as e.preventDefault();
echo 'Thank you so much for this awesome content ';
Sir how can will insert the date into database
I get that username is not present in data because when I var_dump the data i get (array(3) { ["username"]=>) meaning that they key is "username" and not just username. When I change the $fields to [ ' "username" ', ' "email" '] I don't get these mistakes but I don't think that's a real solution, any ideas?
thanks lot
is this series ends?
If submitted value is ok then what is process to save it into Database? Coulde show that too?
thanks shaun
i have got this error in each input:
Notice: Undefined index: username in C:\xampp\htdocs\marble\php\thenetninja\objects\formproject\index.php on line 29
please help me :)
please make series Filepond&NodeJS
Hello, will you upload more videos, will you make a project, for example a crud?
Bye.
Please make on series React native when starting?
I'm currently creating that playlist now, it should be ready in about 2-3 weeks or so.
Okk thank you sir
As soon as possible react native series upload
wow that was embarecing
Shaun, Laravel!!!!!! Pleaseeee🙏🙏🙏
Just finished recording the series :D