Ifyouappreciatethiseducation, pleasethinkaboutgoingtoElithecomputerguydotcomandoffering a onetimeormonthlyrecurringdonation.
Welcomeback.
Asyouknow, I amElithecomputerguy, andintoday's class, I'm goingtobeshowingyouhowtosanitizeyourvariableswhenyou'resendingdatafromyourPHPscriptstoyou'remysequel.
Databasetables.
Soagain, we'regoingtobeusinganHTMLform.
ThatHTMLformisgoingtobehandingoffthevariablevaluesto a PHPscriptthatPhDscriptisgoingtothenparts.
ThevaluesturnedthemintoPHPvariables.
Plugthatinto a sequelstatementandshipthatofftothemysequeldatabaseservertoinsertinsertrecordsintothat.
MysequelDatabasesTable.
Nowit's important.
Understand, wheneveryou'redealingwithsecurityandthecomputeraroundisthatyou'regoingtohavetodealwithsecurityfrommultiplefrontstoomanytimeswhenpeoplethinkaboutsecurityagain, whenitcomestotechnology, theyhavethisideaoflikeoneproductoronesolutionsecuresyoursystem, whichisjustfoolishagainfordealingwith a computerordealingwith a server.
Youdon't justuseoneproductthesamemysterywheneveryou'redealingwiththingslikemysequeldatabaseserversagain, like a lotofpeople, hyperfocusononespecificattackinordertosecuretheirserver, andtheyignoretheotherwaysthattheirsystemscouldbeattacked.
And, ofcourse, attheendoftheday, whensomethinghappens, theyalwayssay, I didwhat I wassupposedtodo.
It's notmyproblem.
Whatanyone s 01 ofthingswedidinthelastclasses.
Wedidsomethingcalled a preparedstatement, sopreparedstatementtriestopreventwhatErcolesequelinjectionattacks.
Sotheideawith a sequelinjectionattackisthatyoutrytoescapeoutofthestatementthatPHPissendingtoyourmysequelserverandthenessentiallyaddyourownsequelstatement.
Sothere's anorthere's a statementthatsupposedtobesent.
Whereyou'redoingsomething a sequelinjectionortotrytomanipulatetheserveristhatyoucanhaveyourusersalsotryingtoinsertthings, suckastagsorsuchasothertypesofcodethatwillbetriggeredindifferentways.
Esooneofthingsthat I'm goingtoshowyoutodayisbasicallywherewe'regoingtousethesameformwe'veused, like 10 times.
Nowwhereisthename?
It's Ah, thename.
It's anegg, It's a gender, andthatgoesintothestudentstable.
Oneofthingsthat I'm goingtoshowyouhowtodoisinsteadoftypingout a normalnameslikehisBoborwhateverelsewhat I'm goingtoactuallydois I'm gonnatypein a hyperlinkwithBombasthename's typeouttheentire a reftag.
Sowhat I wouldsuggestisyoujustyoucreatesomereallynastyvariablesandthenyouyouplayandyougooutandseewhattheresultsareWhenyousendthatnastyvariablethroughthesedifferentfiltersandyoufigureoutwhatresultworksbestforyou, I willalsosayagainwhenyou'retalkingaboutdoingthingslike a sanitizingyourvariablethatthereareotherfunctionsyoucanusetosanitizevariableshowyou d'oh.
Butrealistically, anyversionof a bunchofdesktopshouldworkfineforyou.
I havethisrightin a virtualmachineandvirtualbox.
Andofcourse, thisisrunningonmyMacbookproinordertocreate a fulllampstackhere, I used a toolcalledTaskCellTa s k s E l thatinstalledthe a PakiofmysequelandPHP.
I havenotmodifiedany.
ThedefaultconfigurationsPHPdot I and I vehostallofthattypeofthing.
Ourstandardoutofthebox.
Theonlymodificationthat I havedoneas I didcreate a PHPfolderwithintheApacherootDirectory, I guess, is a placetodumptheseparticularPHPscriptsandkeepitallniceandclean.
Sowegooverhere, wetake a lookatthePHPformasitstandsnow.
Sothisistheformdothtml.
Sotheformnothtmlisthisformhere, right?
Andso, asyoucansee, it's a normalform, soformactionequalsPHPformdotPHP.
Sotheinformationthat's gatheredfromthisformwillbesenttotheph b formdotPHP.
Wehave a nameis a textnamehisname.
Ageis a textnameisage, Genderisgender.
Andthenyougeteithernothingyougetboyorgirl.
AndsothisallgetstossedovertothepH B form, notPHPfromhere.
WhathappensisyougetthepostnamerightisturnedintothePDPvariabledollarsidenamethePost A hasturnedintothePHPvariabledollarsignageandthepostgenderisturnedintothevariabledollarsigngenderagain.
Sothisname a genderhistory a freshcomesfromname A andgender.
Thereareotherwaysyoucansanitizevariables, howyousanitizeandwhatyouneedtodioreallydependsuponyourparticularsituationagainitisimportanttounderstandwheneveryou'redealingwithsomethinglike a mysequelserveristhattherearemultiplevectorsforattack.
Somewaysit's a sequelinjectionAttackwereliterallytryingtocompromisethesequelserverandgetthesequelserverDosomethinglikebackuptoanoffsitelocation.
Otherwaysisagain, youknow, youthinkaboutifyou'regoingtobebuildingsomekindoflikepublicCR M solution, Soyou'regonnabebuilding a newWordPress.
We'regonnabebuilding a newgrouporsomethinglikethat, beingabletofilterourpeople's abilitytocreatehyperlinksandthingslikethenameofboxorwhatevercouldbe a veryvaluablething.
Thiswas a bigissuethat I saw, like 10 yearsago, whenwhenforumswerereallybig, rightwhensocialmediawascompletelynew, wheneverybodywastryingtobecomethenextFacebook, yousaw a lotofpublicforumsandgetdeployed, frankly, usingsomesomeprettycrappycodetogetthingsaccomplished.
Andyoujustdidn't realizesomethinglikesomebodycouldliterallyinsertsomethinglike a Javascriptstraightintoyourmysingledatabasetableonandthenthatwillfireeverytimesomebodygoesandthatthat's actuallypulled S o.
Soanyways, uh, asalways, I enjoyeddoingthisthisclassforcingthenextApparentlythetypeofcontentyoujustsawisnotwhatSusan W.
WantsforthefutureofYouTubeThismeansthatrecommendationsbyYouTubetothischannelhavedroppedmassively, andviewsarebecoming a comicallysmall I hatetoask.
I usedtosay I wouldneverask, butifyoucouldsubscribelikecommonandmostimportantly, sharethevideosthatyouappreciate, thatmayhelpslowthedeathofthischannel.