Check if a Database Record Already Exists Before Inserting a New Entry

Please show some screenshots like guptast did in his post, otherwise it’s very difficult to follow properly.

1 Like

updated with screenshot please check psweb. thanks for trying to help me out

No problem, can you show me the code for your email input of your form please, I want to check the input name and ID

1 Like

please see above… thanks

It looks fine to me, what I would try is open the server connect side of this, then arrow out Input, then arrow out $_POST, then select the email input and in the field properties > validation rules, remove the Required as well as the Valid Email Address from the input itself, and just see if that is what is causing it, I have often found issues with the server side validators, so we can always add them back later, but for testing, remove them.

1 Like

sorry i did not understand what exactly you mean about arrow out?

1 Like

i did this and checked, not worked…

1 Like

here it is…

I think I see the problem, I missed it on your very first screenshot, but you need to switch your 2 steps around.


You Validate if the users email exists first, and then if its true then you insert the user, so swap your steps around. Validate above Insert

1 Like

i swapped the steps, and checked, now the inserting user with same email is not succeded which i need anyway. but the message not shown in that case such as email exist!

please show a screenshot of your code, i need to see the whole <head>...</head> section, as maybe wappler lost an include for the client side validator somewhere

1 Like

Not that, I need to see this

i’m using NodeJs and partial view for the form and inserting that into my register page.
i dnt see those lines you marked inside my partial form view.

   <!-- Wappler include head-page="register-user" appConnect="local" is="dmx-app" bootstrap4="local" fontawesome_4="cdn" jquery_slim_33="cdn" components="{dmxValidator:{}}" -->
<dmx-serverconnect id="serverconnect1" url="api/getRoles"></dmx-serverconnect>
<form is="dmx-serverconnect-form" id="serverconnectform1" method="post" action="api/insertUser" dmx-generator="bootstrap4" dmx-form-type="vertical">
    <div class="form-group">
        <label for="inp_first_name">First name</label>
        <input type="text" class="form-control" id="inp_first_name" name="first_name" aria-describedby="inp_first_name_help" placeholder="Enter First name" required="">
    </div>
    <div class="form-group">
        <label for="inp_last_name">Last name</label>
        <input type="text" class="form-control" id="inp_last_name" name="last_name" aria-describedby="inp_last_name_help" placeholder="Enter Last name" required="">
    </div>
    <div class="form-group">
        <label for="email">Email</label>
        <input type="email" class="form-control" id="email" name="email" aria-describedby="inp_email_help" placeholder="Enter Email" data-msg-required="" data-msg-email="">
    </div>
    <div class="form-group">
        <label for="inp_password">Password</label>
        <input type="password" class="form-control" id="inp_password" name="password" aria-describedby="inp_password_help" placeholder="Enter Password" data-msg-required="" required="">
    </div>
    <div class="form-group">
        <label for="inp_address">Address</label>
        <input type="text" class="form-control" id="inp_address" name="address" aria-describedby="inp_address_help" placeholder="Enter Address" required="">
    </div>
    <div class="form-group">
        <label for="inp_post_code">Post code</label>
        <input type="text" class="form-control" id="inp_post_code" name="post_code" aria-describedby="inp_post_code_help" placeholder="Enter Post code" required="">
    </div>
    <div class="form-group">
        <label for="inp_city">City</label>
        <input type="text" class="form-control" id="inp_city" name="city" aria-describedby="inp_city_help" placeholder="Enter City" required="">
    </div>
    <div class="form-group">
        <label for="inp_country">Country</label>
        <input type="text" class="form-control" id="inp_country" name="country" aria-describedby="inp_country_help" placeholder="Enter Country" required="">
    </div>
    <div class="form-group">
        <label for="role_id">Select role</label>
        <select id="role_id" class="form-control" dmx-bind:options="serverconnect1.data.queryRoles" optiontext="name" optionvalue="id" dmx-bind:value="serverconnect1.data.queryRoles[0].id" name="role_id">
        </select>
    </div>
    <div class="form-group">
        <button type="submit" class="btn btn-primary">Save</button>
    </div>

</form>

I have two layout, one for dashboard which backend-main, which used for the register user page. as i said form is partial view. inside register-user.ejs

please screenshot of the backend-main code:

Also please screenshot the code for the page register-user.ejs