Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Venkatesh Swarna 6 posts 76 karma points
    Jan 23, 2018 @ 18:08
    Venkatesh Swarna
    0

    Form values are not getting stored in Database

    We are new to the Umbraco tool and created a registration form using Html and script. Once registration form submitted email getting sent but data is not stored in the database. Firstly which database table we should verify for the form submitted data. secondly do we need to make any settings to store the submitted data. Any help will be appreciated.

  • Alex Skrypnyk 6150 posts 24110 karma points MVP 8x admin c-trib
    Jan 24, 2018 @ 12:26
    Alex Skrypnyk
    0

    Hi Swarna

    Can you show the code of form?

    Thanks,

    Alex

  • Venkatesh Swarna 6 posts 76 karma points
    Jan 29, 2018 @ 12:37
    Venkatesh Swarna
    0

    Under the templates ->create a new template(Registration) and wrote the HTML markup to create the page, also the business logic. Please find attached the code. Can you please let me if any settings/code need to be added, so that it saves the data to the table.`@inherits Umbraco.Web.Mvc.UmbracoTemplatePage @using System.Collections.Generic; @using System.Text; @using System.Net.Mail; @{ Layout = "Master.cshtml"; var content = CurrentPage; var offices = content.Children("OfficeLocation").Where("Visible");// content.GetChildren

    HttpContext context = HttpContext.Current;
    string errorMsg = "";
    string emailTo = "";
    try
    {
        if (context.Request.Form.Count > 0)
        {
            if(context.Session["captchaString"].ToString().ToLowerInvariant() != context.Request.Form["captchainput"].ToString().ToLowerInvariant())
            {
                errorMsg = "<p>Please enter the characters in the image below to verify your submission</p>";
            }
            StringBuilder sb = new StringBuilder();
            contactType = context.Request.Form["contacttype"];
            string firstName = context.Request.Form["firstname"];
            string lastName = context.Request.Form["lastname"];
            string title = context.Request.Form["title"];
            string emailFrom = context.Request.Form["email"];
            string phone = context.Request.Form["phone"];
            string location = context.Request.Form["location"];
            string company = context.Request.Form["company"];
            string username = context.Request.Form["username"];
            string password = context.Request.Form["password"];
            string message = context.Request.Form["message"];
                //send an email logic   
                    // Redirect to thank you page
    
    }
    catch (Exception ex)
    {
        errorMsg = "<p>" + ex.Message + "</p>";
    }
    

    } @section bodyEndAfterScripts {

    <script type="text/javascript" src="/scripts/jquery.validate.js"></script>

            var form = $("#contactForm");
            form.validate({
                rules: {
                    @*contacttype: {required: true},*@
                    firstname: {placeholder: true},
                    lastname: {placeholder: true},
                    phone: {placeholder: true},
                    email: {email: true, placeholder: true},
                    title: {placeholder: isPartnerInquiry},
                    title: {required: true},
                    location: {placeholder: true},
                    company: {placeholder: isPartnerInquiry},
                    company: {required: true},
                    password: {required: true},
                    message: {placeholder: false}                   
                },
            });
            $('#submit-form').on('click', function(e) {
                e.preventDefault();
                if(form.valid()){
                    form.submit();
    form.reset();
                }
    
            });
    
    
        });
    </script>
    

    }


    @if (content.HeaderImage != null && content.HeaderImage > 0) { }

    @content.ContentTitle

    @content.SubTitle

    @Html.Raw(content.TopContent)
    @Html.Raw(errorMsg)
    @if (dd.Count > 0) {
    @@
    }

    @
    @
    @
    @
    " class="form-control" />
    @
    *@
    Captcha

    </div>
    

    `

  • Alex Skrypnyk 6150 posts 24110 karma points MVP 8x admin c-trib
    Jan 29, 2018 @ 22:15
    Alex Skrypnyk
    0

    Hi Swarna

    Please, fix the code

Please Sign in or register to post replies

Write your reply to:

Draft