---------------------------------------------------------------------------------- In this video, we build a real-world Applicant Profile Settings Page in our Job Portal Application using Next.js and MySQL.
Users may: • Fill profile for the first time • Update their existing profile later
Instead of creating two separate forms (Create + Update), we implement a powerful UPSERT logic.
You’ll learn:
What is UPSERT in MySQL
How to use INSERT ... ON DUPLICATE KEY UPDATE
How to detect whether to insert or update
How to toggle button text (Save Profile / Update Profile)
How to use isDirty and isSubmitting from React Hook Form
When to disable the submit button
Writing clean backend logic for real production apps
This is a must-watch if you want to become a serious full-stack developer. ------------------------------------------------------------------------------------ 🔗 Useful Playlists
⌛TIMELINE⏳ 0:00 Adding Update Function to Applicant Profile 1:20 What is UPSERT in MySQL? 1:52 Support the Channel ❤️ 2:10 Creating the UPSERT Backend Function 3:35 Important Concepts Before Writing UPSERT 5:10 UPSERT Code Explained Step by Step 6:30 How to Check Insert vs Update in Database 9:05 Changing Button Text (Save / Update Profile) 11:20 isDirty & isSubmitting in React Hook Form 12:35 When to Disable Submit Button 13:30 Dynamic Button Text Logic
AI Generated·May contain errors
Hello what's up guys
Welcome everyone to our next guest
and my sequel presentation
job portal application
today is day 84
and today I'm going to show
you how to implement the update
functionality in our profile form
— yes guys in this form you can see
Grab it now because
today's video might
be one of the last ones we ever post
Where you've already seen plenty of things
After that upload your resume
In the saved section Show up in the applied sectio
and a little of those things will be done and it will be settled alright
so here it will happen that
the user has filled in the data
our data which is
It has already been inserted into the database
So tell me what are we doing here We're showing it right here
right Just look
if I refresh this
The data has been displayed here
here is where it is
located you can see it the data is right here
it's also visible to you
So much has already happened
and after a while if the
userPropertyChanged I mean the
applicant feels this
way dude right here
something's wrong with the car
I need to fix it not testing the data
this is my world
you know like
writing this much
If you want
to update it just check this out — the update happens
automatically Profile updated successfully If I keep running
here then this data that was being tested —
look this is my
world getting updated here
alright mind's at ease everything else stays
as is
except that one feeling it's updating too
I can't seem
to add an
extra row here okay so
how can we do this And
believe me
to do this
absurd it's a new term
I
mean if it's true then long before sip saith
you heard it for the first time where
if the condition is correct
then update it
If not so
You're understanding it
this is just its core
meaning a single function
you can update it as well
insert new data too
and else
if you recall
Our employers
' table was in
the employers'
form where were
separately inserting
and updating using
the ease of edit mode
We were playing
right That's true so update
it Otherwise we did
something different but here it's
going to be completely
different so
ow come you're
starting the delayed
video before
checking out the rest of
the videos that
are still pending please go ahead and check them
out now
ext target is 8 lakh
subscribers — if
you haven't yet guys please
subscribe because your
subscriptionreally
motivates me to
create more
videos like this
main upload
I can keep going
it's so you
have seen
here the concept
is very basic
it's simple
and that is
that now just one function
for
helpif
the user 's data
already exists
then update it
otherwise insert it
okay
now carefully look
this is basically
Which form is this Speaking
of which this is our
main applicant
basicallywe'
retalking
about this part
here right now
I'm here
okay here when wereinserting
the data
I
mea [-]
Wheneversomeone
wassubmitting
a
form to insert
data that 's exactly
what
happens on
form
submission—handle
submit we have this on submit me
you could
see the data
alreadywere
gettingit
through the react
hook form and this
is just
one line here
I had
written somethingelse
earlier
create
and if youclick
on it
it's thesame
thingmeaningit
'
sthesamefunction
the same one
you know when
we created
it were
just using[-]
[-]
[-]
[-]
[-]
a bit both
modified is now
he
re
[-]
[-]
[-]
[-]
[-]
[-]
[-]
[-]
[-]
[-]
[-]
[-]
[-]
[-]
[-]
[-]
I was
writing codehere
earlier but now I'mcreating
it in
this place instead
Here
Icame
I want
you to see for
yourself here how
absurd it is to keepdoing
thisGauhar
just once let me
tell you what I'mabout
to say
to Gauhar
Listenfrom
herejust
likethis
what you 're seeingnow
is it
the table of
your usersright And if you
remember[-]
[-]
[-]
[-]
[-]
[-]
Thetable
hadalready
beeninserted
for users but
it wasn't
showing upproperly
e
was also an
applicant earlierbut
when he
registered the data
alreadyexisted
as a user
so it's why this is
such a part of the
process[-]
[-]
[-]
[-]
[-]
[-]
[-]
[-]
[-]
[-]
[-]
[-]
[-]
wherethe
mainupdate
wasbeing
carriedout
earlieron
alreadyempty
our
thisdata
isapplicant
relatedright
and
onethat
appearsresume
[-]
[-]
[-]
[-]
[-]
[-]
Only
荠
thisfield
basically the ham
transaction should use
kar re the
ki ha
bhai all threeshould be
equal so I've alreadybeen
updatingthe
users'table
beforehand and the
applica[-]
[-]
[-]
[-]
[-]
[-]
[-]
[-]
[-]
and
my
resumetable
iswhere
I
wasinserting
datanow
alsoneed
toapply
somelogic
hereand
thatthe
rightthing
[-]
[-]
[-]
[-]
[-]
[-]
eitheran
update or an
inser[-]
[-]
The bus
Hume AB Kisi Tarik
Se Ye
Pata LaganaHai
Applicant Ka Jo
Table And Then ResumeIsko
MujheUpdate
Wala Bhi Rakhna
[-]
[-]
[-]
[-]
[-]
[-]
[-]
[-]
[-]
[-]
[-]
It will be
updated automatically if the
data is already there
and the user
makes any change otherwise insert it
simply— now how
will it work
I'll explain
it to you
right here [-]
[-]
[-]
[-]
[-]
[-]
[-]
[-]
[-]
[-]
[-]
[-]
[-]
comeherenowI 'll
show you I'vealready
shownyou
you know like
authorize it is
notcurrent
user to ge
[-]
[-]
[-]
[-]
[-]
[-]
[-]
[-]
[-]
thenafter
drinkingwe
dowhat
basicallyvalidate
the
datayou
knowlike
a
jobvalidation
comeon
ifeverything
is
correctno
[-]
[-]
[-]
[-]
somethingelse
is wrong then
this errormessage appears and we
destructure it right
here[-]
[-]
[-]
[-]
[-]
[-]
as for
the data I've got
everything I know
that this dataneeds
to be
updated inthe
userstable
foreach
applicant[-]
[-]
[-]
[-]
[-]
[-]
[-]
[-]
I need
to insert into the
table and in theresume
table I had to insertwhat
was my previousscene
which is nowthree
and I need
toupdate
it with
something [-]
[-]
[-]
It's not
just that it's updated
by defaultit's
exactlywhat'
sbeingreferred
to when two
are involved
If you
wantto update do the
update if not don'tinsert
Insteadcarefully
check the up search thenperform
the
updatesearch
insert or
else just
do the
insert carefully[-]
[-]
[-]
[-]
[-]
[-]
The users
' table
which was previously in use for
transactions
remains unchanged by default and there
is no tension
at all as
bothimos [-]
[-]
[-]
[-]
[-]
[-]
[-]
[-]
[-]
[-]
[-]
[-]
[-]
[-]
[-]
[-]
[-]
easilyupdate
hojaata
transactionyaha
ab
jo
maintha
kihume
patakaise
chalegaapplicant
ketable
meinkarna
haiinsert
and[-]
[-]
[-]
[-]
[-]
at is simply
the user ID
to whichit
belongsnotmine
—
lookselectfrom
yourapplicant
where the matterends
in the
applicant
's
table the one with
that ID
and this [-]
[-]
[-]
[-]
[-]
[-]
[-]
what'
sgoingon
withthe
userand
wherehave
we
leftthe
user[-]
The
user ID alreadyexists
in the applicant
table so the data can't be
addedagain
—I mean
this applicanthas alreadysubmitted
theirinformation
so it's just
a matterof
confirming that right
[-]
[-]
[-]
[-]
[-]
[-]
[-]
bro you' realizing
how easy it
is I
figuredit
out — the
data is present
and now if
the data is
present and an
existingapplicant
exists[-]
[-]
[-]
[-]
[-]
[-]
[-]
[-]
Look at that agar
and see
how we are
f
the lengthis morethan
zerothat
meansit'
salreadypresent
so update
it if
it'
snotpresentinsertit
—problem
solvedmy
friend[-]
[-]
[-]
[-]
[-]
[-]
[-]
[-]
I
mean Humelaga hogabhai
kaisehoga
Kyahoga
lekindekho
kitnaeasy
thaupdate
data
present hai ki nahisimple
e[-]
[-]
[-]
we checked
the select statementID
match and it's notanything
unusual so
you might be
overthinking[-]
[-]
[-]
[-]
[-]
[-]
[-]
[-]
[-]
[-]
[-]
[-]
[-]
[-]
[-]
Look the applicant datawe've
enteredbasically
is this
and insertingit
here it justfeels
like it belongs righthere
[-]
[-]
[-]
[-]
[-]
[-]
[-]
[-]
[-]
[-]
[-]
[-]
[-]
writingso
betterwhy
notwe
makeone
comeobject
andjust
madeby
[-]
[-]
[-]
e
way you normallydestructure
theapplicant
'
stransactiondata
user ID
and all values
as is and
here 's how we
did [-]
[-]
[-]
[-]
[-]
[-]
[-]
[-]
[-]
[-]
[-]
[-]
[-]
[-]
[-]
How will we
knowwhether
thecandidate
's
resume is alreadypresent in the table
or not
after thisupdate
[-]
[-]
[-]
[-]
[-]
[-]
[-]
[-]
[-]
[-]
[-]
[-]
wahiaa
fromresume
dotapplicant
again we made the same
object so that both
places would not require me to
repeatedlywrite
this four -propertyline
at length one
to [-]
[-]
[-]
[-]
[-]
[-]
[-]
I mean
just zeroset it to
update
or
elseinsert
this—it's just a normal
updateand
insertquery
and
basicallyafter
updatingyou
need to checkonce
[-]
[-]
[-]
[-]
That'
sitthen
updateand
thisis
yourabsurd
data
and
yes just revalidatethe
path so yourupdate
takeseffect
immediately on the spot
nothing else was
needed now here
it is this
one [-]
[-]
[-]
[-]
[-]
[-]
[-]
[-]
Alright the update has been made but
now there' s
one more thing—
specifically that button
We need to
show that if someone clicks
the button for
the first time
[-]
[-]
[-]
[-]
[-]
[-]
[-]
[-]
[-]
[-]
[-]
[-]
[-]
aayahai
tousko
saveprofile
karkedikhana
andalready
kisine
aaupdate
I mean
kar
chukaab
wokarne
jaaraha
hai[-]
[-]
[-]
[-]
[-]
umehim
bydefault
thistime
updateshow
andfor
thevery
firstif
wego
aheadthen
shouldcompletely
disablebutto
[-]
[-]
[-]
[-]
[-]
[-]
[-]
and no changes
to save you
but we've been showing
it to you
so now we'll
implementthis functionality[-]
[-]
[-]
[-]
[-]
[-]
[-]
f
the initialdata
hasa
locationvalue
then it means
update if the
location value is
presentit
means we
need to updatenot
inserthence
below[-]
[-]
[-]
[-]
[-]
[-]
[-]
[-]
[-]
[-]
e
update that appearsautomatically which will show you
now or update
your profile
won't appear if
the location
value is missing
[-]
[-]
[-]
[-]
[-]
[-]
[-]
[-]
[-]
[-]
[-]
[-]
[-]
[-]
to show
you yoursaved profile
doublenot
operatordouble
exclamationmark
aapkodikhai
dera
so
basicallykya
maibata
toisko
humkehte
haiboolean
cohesioniska
kaam
[-]
[-]
aijabaapsirfye
likhtehotoaapko
lagrahogaphilal
ya to
truefalse
booleandata
degabutin
realityaisa
whenyouwrite
onlythisit
willappearas
eitherorbegiven
realityit'sno
o it's
not true that if youonly
enterthe
initialdata
dot location it will
either give you
true or false but
it could
also be null
[-]
[-]
[-]
Do we
knowthe
initialdata
but not the
location'
svalueCould
anything else be possible If so
whatshould
we do
brother Thisboolean cohesion—
[-]
[-]
[-]
[-]
[-]
doubleexclamation
markbasically
converts any value
into a strict booleanmeaning
it'sessentially
checkingwhether
a value
is truthy
or falsy
[-]
[-]
[-]
[-]
[-]
[-]
[-]
[-]
[-]
[-]
[-]
browhatever
it is I
just need the
data in booleanform
—onlythat
and if it
ends up being null
or undefinedor
defaults to false
then that 's fine[-]
[-]
[-]
[-]
[-]
[-]
will be false for
you and
data will be
true集聚 if it isproperly
validthen
it will be
true for you either
youwill
have this as
true or you willhave
this as true
[-]
[-]
o
reacthook
formjo
haina
ye
aapkokuch
aiseproperty
detijiski
chalteaapki
lifeeasy
hojayegi
forexample
we
havethis
statehumare
[-]
[-]
formka
jobhi
statelikha
aahai
wo
yecheck
kariske
paasrahita
uskakha
thekwe
haveerrors
isdirty
andthen
is
[-]
[-]
[-]
[-]
[-]
[-]
submittingto
submitting
[-]
At that
very millisecond if your
form is being submitted
it becomes
active—basically
it's true [-]
[-]
[-]
[-]
[-]
[-]
[-]
[-]
[-]
[-]
[-]
[-]
[-]
[-]
[-]
[-]
[-]
[-]
isdirty
meaningwhat
itmeans
thatthere
areso
manyfields
herethis
a
fieldright
alsopay
attentionnow
[-]
[-]
[-]
[-]
[-]
[-]
[-]
[-]
[-]
[-]
e
moment I saw agar
s
submitand
thenis
dirtyye
donoka
aapkopata
chalgya
kyahai
to
abhum
ekdam
nichete
humareaa
bottompethat
'
syourbutton[-]
[-]
Work hard and see
the results
Okayit
lookslike
here
takea
lookright
herethis
isyour
buttonso
goharwill
checkit
fromthere
Thisis
your[-]
[-]
buttontheke
is
ye
philaaljo
aapkabutton
haitheke
usko
disablekarna
yanahi
wokis
pedepend
aapke is = PropertyChangedand
then[-]
[-]
[-]
[-]
[-]
[-]
[-]
youris
dirtyby
or
tosubmitting
itsvalue
iftrue
remainsnow
thiswhen
youform
fillout
andbutton
clickyou
[-]
[-]
[-]
[-]
[-]
[-]
[-]
for a few
milliseconds truly[-]
[-]
[-]
wo
heyyour
thisdirty
ofabove
valueif
trueis
nothere
lookwe
havea
operatormeaning
justlike
mainanything
change[-]
[-]
[-]
[-]
[-]
[-]
[-]
cardhoon
fillmein
woaapka
kyaho
jatahai
truelekin
mainagar
kuchbhi
changenah
karuby
defaultfalse
ke[-]
[-]
[-]
[-]
[-]
baitha sothat' swhy agar
wedidn
'
tmakeanychanges
to the user
but if the
userjust
clickedthe
buttonright
now you can
disableit
at that
moment [-]
[-]
[-]
[-]
[-]
[-]
[-]
[-]
That'
sthereasonwe'
rebasicallygetting
a
disable buttonhere from now on the
disablebutton
has been
activated and now
you can see
it right
here[-]
[-]
[-]
[-]
[-]
[-]
[-]
[-]
[-]
[-]
[-]
strengthis
inhim
yeah look insidethe
buttonwhenyou
'reclicking
thesubmit
button if you
'
reinthe
process
ofsubmitting
then the loader which
is
a [-][-]
[-]
[-]
[-]
[-]
[-]
[-]
[-]
animationhota
naro
jo
gol
ghumrahe
uss
samayke
dekhado
matlabkuch
millisecond ke liye
aapnebutton
peclick
haitrrr
khatam
Just look at him
for a mere millisecond
—
that's all it takes
to see he's right
buttonhere
isthe
endof
this
lineyour
textthat
beingshown
inwhereUI 's[-]
[-]
[-]
[-]
[-]
[-]
[-]
[-]
[-]
[-]
you see what's
beingdefined
here is the valuebeing
submitted—if
it's true
then yes and if
updating is also true then
submittingmeans
[-]
[-]
[-]
[-]
[-]
[-]
[-]
[-]
[-]
[-]
apapp
formon
clickto
behere
simply us
particular same ke
liye kuch millisecond
ke
liye [-] [-]
[-]
[-]
f it'
s true
that the hot condition
is met
then we check
a
condition and even
if this updating
is true
the updatingbeing trueoccurs
when the user
has
already filled in
the data
[-]
[-]
[-]
[-]
I'vealready
submitted it and
if this
is also true
then I'm submittingthe sameupdate
[-]
[-]
[-]
[-]
[-]
[-]
[-]
[-]
[-]
[-]
[-]
[-]
[-]
update
if
conqueringthen
showingat
thatspecific
timefor
elseform
if
submittedis
happeningmeaning
thisnot
trueuser
insertinghappening
[-]
[-]
[-]
[-]
[-]
so to
show saving now
if
theuserhasn
'tclicked
onthe
formsubmit
buttonthen
clickinghappened
meaningit
hasbecome
false[-]
[-]
[-]
[-]
[-]
[-]
[-]
en he
will comededuction thisspecific
[-]
and if
the
updatevalue
isfalse
it
meansthe
user 's ID thatwasn'
t
found atthe locationwon't
be found either
so the
save profilewill returnfalse there[-]
showingyou
this is your magicand
that's why I'm updatingyour
profilehere
for
you [-] [-]
[-]
[-]
[-]
[-]
[-]
[-]
[-]
[-]
[-]
[-]
[-]
philalabhi
yehwala
datadikhai
deraha
kyunkyun
kiform
komain
submittoh
kar =兴 =
nahi [-]
[-]
[-]
[-]
guyscancel
hihogiya
hai
na ab
merepaas
bachabas
itnapart
yeh ek part
bachamere
paas yaha pe yehwala
is me
bhi is updating[-]
[-]
[-]
[-]
philalabhi
truehaithat
'
swhymujheupdate
profiledikhai
diyaagar
nahihota
tohsave
yehdekho
is
dirty[-]
[-]
[-]
f the
value is nottrue thenno
changeswill
be saved
and in case
we type
somethingwhatever
you have will be
carried over here
[-]
[-]
[-]
[-]
[-]
[-]
[-]
[-]
[-]
[-]
[-]
see the condition
isn'tworking
as a
toggle—either
show it or don
't
showit simpleand
disable I don't
need to
be
told [-] [-]
[-]
[-]
[-]
Yeahlook
it's just
that I 'm now
doingthis
jo
conditionbecause
thissubmitting
thenwhen
formon
clickI'
llonlyhappen
elsewhy
wasfully
dependentthat
wentaway
now to you
[-]
[-]
[-]
[-]
[-]
updateab
yahape
aaramse
karsakti
hodekha
so
yaguys
thisis
itaaj
jishvideo
keitna
hiaasa
tohpasand
[-]
[-]
aaogaa
jahape
finallyhome
page
usme
bhiaapka
jo
agarjob
hotatoh
uskadynamic
hotchuka
haisetting
ab[-]
[-]
[-]
[-]
We'
redonewiththat
nowwe'll go back to
findingjobs
whenevera
userclicks
on a
card and then clicks
apply it will showas
applied[-]
[-]
[-]
[-]
If the application
was meant for
someone then
whateverwas
supposed to be
appliedwould
have been applied
to
them [-] [-]
I hope
you
reallyenjoyed
thevideo
I know
it was quitelong
but it doesn
'
tmatter[-]
[-]
[-]
[-]
[-]
[-]
[-]
yeahsoit
'
sgoodheyguys
ifyou
likedthe
videoplease
likeit share it with
friendsand
don 't forget
tofollow
Sir for more
Don'
tdoubtjustcomment
make sure to share
and our next
target is 8 lakh subscribers—ab
till then guys
thank you
so much
take care
[-]
[-]
[-]
[-]
[-]
[-]
[-]