0

i don't know much SQL server, and need a script to generate the table for a form, i know how to do this in mySQL but no idea in SQL Server.

This is the data from my form:

<asp:Content ID="Content3" ContentPlaceHolderID="ContentPlaceHolder2" runat="Server">
    <form id="form" action="process.php">
        <div id="formTop" class="formTop">
            <input type="text" name="nombre" id="nombre" required /><br>
            <input type="email" name="email" id="email" required /><br>
            <input type="text" name="telefono" id="telefono" required /><br>
        </div>
        <div id="formBottom" class="formBottom">
            <textarea type="text" name="lema" id="lema" rows="7" required></textarea>
            <input type="image" id="formSend" src="img/btConcursar.png" class="image-responsive">
        </div>
    </form>
    <script>
        function IsEmail(email) {
            var regex = /^([a-zA-Z0-9_.+-])+\@(([a-zA-Z0-9-])+\.)+([a-zA-Z0-9]{2,4})+$/;
            return regex.test(email);
        }
        //$("#form").submit(function (event) {
        $("#formSend").click(function () {
            /* stop form from submitting normally */

            if ($('#nombre').val().trim() == "") {
                //alert("please enter name");
            }
            else if ($('#email').val().trim() == "") {
                //alert("please enter email");
            }
            else if (!IsEmail($('#email').val().trim())) {
                //alert("please enter valid email");
            }
            else if ($('#lema').val().trim() == "") {
                //alert("please enter message");
            }
            else if ($('#telefono').val().trim() == "") {
                //alert("please enter phone number");
            }
            else {
                var url = window.location.pathname + "/" + "InsertForm";
                var succeededAjaxFn = function (result) {
                    alert("successfully submitted");
                    $('#fbshare').show();
                    $('#formbg').hide();
                };
                var failedAjaxFn = function (result) {
                    //alert("failed to submit" + result);
                    alert("");
                };
                var paramList = '{' + '"name":' + '"' + $('#nombre').val() + '",' + '"email":' + '"' + $('#email').val() + '",' + '"message":' + '"' + $('#lema').val() + '",' + '"phoneNumber":' + '"' + $('#telefono').val() + '"}';
                $.ajax({
                    type: "POST",
                    url: url,
                    contentType: "application/json; charset=utf-8",
                    data: paramList,
                    dataType: "json",
                    success: succeededAjaxFn,
                    error: failedAjaxFn
                });
            }
        });
    </script>
</asp:Content>

So i need the table for: nombre email telefono and lema

I will really appreciate any help that you can give me with this.

2
  • 1
    Are you asking how to create a table using SQL Server that has four columns (nombre, email, telefono, and lema)? If so, you might look up something like techonthenet.com/sql_server/tables/create_table.php for the syntax. The code you provided is just markup and front-end scripting, but any detail you can provide about the server/back-end scripting would be much more useful to anyone trying to answer your question. Commented Sep 8, 2015 at 15:49
  • Hi, i think that the link that you provided me and the answer i got from ProblemSolver, is the key. Thank you. Commented Sep 8, 2015 at 15:58

1 Answer 1

1

Basically, you want to create a table like:

CREATE TABLE Users(
Nombre varchar(100) NOT NULL,
Email varchar(100) NOT NULL,
Telefono varchar(15) NOT NULL,
Lema varchar(max)
)

where NOT NULL forces an entry to have some value in those fields. From there you will probably want a primary key, which you can include in the type specification i.e. changing to

Nombre varchar(100) PRIMARY KEY

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.