Skip to main content
Fix markup
Source Link
kaiser
  • 50.8k
  • 27
  • 150
  • 244

Hi Friends Please try this code for updating the records in database in wordpress. For this firstly create a file.phpfile.php inside your selected wordpress folder and then use this file as a template. And this code will work perfectly and if anybody knows the right regular expression for validating the name please suggest me. Thank you all.

.error{color: #FF0000;}
<?php /* Template Name: your template name */ ?>
<style>
.error {color: #FF0000;}
</style>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6/jquery.min.js" type="text/javascript"></script>
    <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"
        type="text/javascript"></script>
    <link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css"
        rel="Stylesheet" type="text/css" />
<script type="text/javascript">
    $(document).ready(function() {
            //this calculates values automatically 
            $("#name").keypress(function() {
            validate();
            });
            });
function validate() {
                
            /*=============== Validate The Name ======================*/
                var fname =document.forms["abc"]["name"].value; 
                var name_regex = /^[a-z A-Z]+$/;
            if(fname == 0||fname==null )
            {
                    document.getElementById('nameErr').innerHTML = "* Please fill your name";
                    return false;
            }
            else
            {
                    if (!fname.match(name_regex)) {
                    document.getElementById('nameErr').innerHTML = "* Name should be alphabet";
                    return false;
                    }
                    else{
                                document.getElementById('nameErr').innerHTML = "";
                    }
            }
}

        <?php get_header(); ?>
        <?php
        if (!empty($_POST)) {
        global $wpdb;
            $table = wp_tablename;
            $data = array(
                'firstname' => $_POST['yourname']
            );
            $format = array(
                '%s'
            );
            $success=$wpdb->insert( $table, $data, $format );
            if($success){
            echo 'Thanks for submitting your information soon we will contact to you'; 
        }
        }
        else   {
        ?>
        <div class="container">
            <div class="row">
                <form method="post" class="form-horizontal" id="abc" onsubmit="return validate(this)">
                <div class="col-md-3">Full name: </div><div class="col-md-8"> <input type="text" name="yourname" class="form-control" id="name"><span class="error" id="nameErr"></span></div>
                
                <div class="col-md-6"><input type="reset" name="reset" class="btn btn-danger"></div><div class="col-md-6"><input type="submit" value="Register" class="btn btn-success"></div>
                </form>
            </div>
        </div>
        <?php }  ?>

<?php get_footer(); ?>
$(document).ready(function(){//this calculates values automatically$("#name").keypress(function(){validate();});});function validate(){/*=============== Validate The Name ======================*/var fname =document.forms["abc"]["name"].value;var name_regex =/^[a-z A-Z]+$/;if(fname == 0||fname==null){document.getElementById('nameErr').innerHTML = "* Please fill your name";return false;}else{if(!fname.match(name_regex)){document.getElementById('nameErr').innerHTML = "* Name should be alphabet";return false;}else{document.getElementById('nameErr').innerHTML = "";}}}$_POST['yourname']);$format = array('%s');$success=$wpdb->insert( $table, $data, $format);if($success){echo 'Thanks for submitting your information soon we will contact to you';}}else{?>Full name:

Hi Friends Please try this code for updating the records in database in wordpress. For this firstly create a file.php inside your selected wordpress folder and then use this file as a template. And this code will work perfectly and if anybody knows the right regular expression for validating the name please suggest me. Thank you all.

.error{color: #FF0000;}
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"
    type="text/javascript"></script>
<link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css"
    rel="Stylesheet" type="text/css" />
$(document).ready(function(){//this calculates values automatically$("#name").keypress(function(){validate();});});function validate(){/*=============== Validate The Name ======================*/var fname =document.forms["abc"]["name"].value;var name_regex =/^[a-z A-Z]+$/;if(fname == 0||fname==null){document.getElementById('nameErr').innerHTML = "* Please fill your name";return false;}else{if(!fname.match(name_regex)){document.getElementById('nameErr').innerHTML = "* Name should be alphabet";return false;}else{document.getElementById('nameErr').innerHTML = "";}}}$_POST['yourname']);$format = array('%s');$success=$wpdb->insert( $table, $data, $format);if($success){echo 'Thanks for submitting your information soon we will contact to you';}}else{?>Full name:

Please try this code for updating the records in database in wordpress. For this firstly create a file.php inside your selected wordpress folder and then use this file as a template. And this code will work perfectly and if anybody knows the right regular expression for validating the name please suggest me. Thank you all.

<?php /* Template Name: your template name */ ?>
<style>
.error {color: #FF0000;}
</style>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6/jquery.min.js" type="text/javascript"></script>
    <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"
        type="text/javascript"></script>
    <link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css"
        rel="Stylesheet" type="text/css" />
<script type="text/javascript">
    $(document).ready(function() {
            //this calculates values automatically 
            $("#name").keypress(function() {
            validate();
            });
            });
function validate() {
                
            /*=============== Validate The Name ======================*/
                var fname =document.forms["abc"]["name"].value; 
                var name_regex = /^[a-z A-Z]+$/;
            if(fname == 0||fname==null )
            {
                    document.getElementById('nameErr').innerHTML = "* Please fill your name";
                    return false;
            }
            else
            {
                    if (!fname.match(name_regex)) {
                    document.getElementById('nameErr').innerHTML = "* Name should be alphabet";
                    return false;
                    }
                    else{
                                document.getElementById('nameErr').innerHTML = "";
                    }
            }
}

        <?php get_header(); ?>
        <?php
        if (!empty($_POST)) {
        global $wpdb;
            $table = wp_tablename;
            $data = array(
                'firstname' => $_POST['yourname']
            );
            $format = array(
                '%s'
            );
            $success=$wpdb->insert( $table, $data, $format );
            if($success){
            echo 'Thanks for submitting your information soon we will contact to you'; 
        }
        }
        else   {
        ?>
        <div class="container">
            <div class="row">
                <form method="post" class="form-horizontal" id="abc" onsubmit="return validate(this)">
                <div class="col-md-3">Full name: </div><div class="col-md-8"> <input type="text" name="yourname" class="form-control" id="name"><span class="error" id="nameErr"></span></div>
                
                <div class="col-md-6"><input type="reset" name="reset" class="btn btn-danger"></div><div class="col-md-6"><input type="submit" value="Register" class="btn btn-success"></div>
                </form>
            </div>
        </div>
        <?php }  ?>

<?php get_footer(); ?>
Post Undeleted by ABHISHEK GUPTA
Post Deleted by ABHISHEK GUPTA
Source Link

Hi Friends Please try this code for updating the records in database in wordpress. For this firstly create a file.php inside your selected wordpress folder and then use this file as a template. And this code will work perfectly and if anybody knows the right regular expression for validating the name please suggest me. Thank you all.

.error {color: #FF0000;}
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"
    type="text/javascript"></script>
<link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css"
    rel="Stylesheet" type="text/css" />
$(document).ready(function() { //this calculates values automatically $("#name").keypress(function() { validate(); }); }); function validate() { /*=============== Validate The Name ======================*/ var fname =document.forms["abc"]["name"].value; var name_regex = /^[a-z A-Z]+$/; if(fname == 0||fname==null ) { document.getElementById('nameErr').innerHTML = "* Please fill your name"; return false; } else { if (!fname.match(name_regex)) { document.getElementById('nameErr').innerHTML = "* Name should be alphabet"; return false; } else{ document.getElementById('nameErr').innerHTML = ""; } } } $_POST['yourname'] ); $format = array( '%s' ); $success=$wpdb->insert( $table, $data, $format ); if($success){ echo 'Thanks for submitting your information soon we will contact to you'; } } else { ?> Full name: