Soitisimportanttounderstandthatwhatwe'regoingtobedoingtodayiswe'resimplygoingtobevalidatingvariablesso I did a classbeforetalkingaboutsanitizingvariable.
SothatwaswhereLet's sayyouwanttostrings.
Youwant a nameoryouoneemailaddresssomethinglikethat.
Sanitizing a variableiswhereyouusethefilterunderscoreofourfunctioninordertogothroughandcleanoutanythingthatisnot a normalstring.
Soitcleansouttags.
Itcleansoutanykindofescape.
Itcleansoutanyofthosetypesofthings.
Soifsomebodyistryingtosubmit a hyperlinkusingthenamefieldusingfilterunderscorebar, anysanitizingvariablewillcleanoutallofthosetax.
Sowiththat, let's gooverthecomputerand I canshowyouhowthisworks.
Sohereweare, backatmylabenvironmentagain.
I'm running a bunchofdesktop 18.4 Lt s N e u bahntodesktopthatyou'rerunningshouldshouldworkforthisparticularprojectthatwe'redoing I amrunningthiswithin a virtualmachineandvirtualbox.
I havethisrunningonmyMacbookproinordertogetthefull A lampstackonthisyouwanttodesktop?
I didusesomethingcalledtasks.
Lt s K s C.
L.
It's a toolwith a bun, too.
Withthat, I wasabletoinstall a packet, mysequelandPHPthere.
I havenotmodifyinganyofthedefaultconfigurations.
PHPnot I andIvyhostsanythinglikethatliterally.
Theonlythingthat I havedoneotherthanthedefaultconfigurationtosimplydumpedin a p A P folderwithintheApacherootdirectoryguest.
So, basicallyallwe'redoingherewiththeformvalidationiswe'reusingfilterunderscoreofourThisisthefunctionwe'refeedingitthevalueofwhatevervariablewerethengivingitthefiltersotheemailFiltertheend.
Filterthefloatfilterthedomainnamefilterthe I P address.
Andthat's wherewhenyou'retypinginto a field, you'llnoticelikethetextwillbereaduntilitlookshowanemailaddressorsomethingissupposedtolookandthenitwillturnblack.
Andit's notthewaythat I woulddoforinvalidationin a productionenvironment.
So I wasactuallycreatingsomekindofemailsignupformthatwasgonnaputouttotherealworld.
I wouldcomeupwithsomethingthatlooks a hellof a lotbetterthanthis, but I justwantedtogiveyou a basicexampleofhowthisworksandsimply, youknow, printingoutbad, badageorbad.
Emailisaneasywaytodothat.
Oneofthingsthatyoucoulddohereisbasicallywhatyoudoisyoucouldreprintthefourlike, really, ifyou'redoingthisin a productionenvironment, evenifyou'reusingPHP, that's whatyoudo, isyou.
It's verynasty, butitgivesyou a demonstrationofbasicallygivingyouanideaofhowthisworks.
Soasalways, I enjoydoingthisclassand I lookforwardtoseeingthenextone.
Apparently, thetypeofcontentyoujustsawisnotwhatSusan W.
WantsforthefutureofYouTube.
ThismeansthatrecommendationsbyYouTubetothischannelhavedroppedmassively, andviewsarebecoming a comicallysmall I hatetoask.
I usedtosay I wouldneverask, butifyoucouldsubscribelikecommonandmostimportantly, sharethevideosthatyouappreciate, thatmayhelpslowthedeathofthischannel.