Add item to MySql without leaving a webpage

Links for php scripts

Moderators: macek, egami, gesf

Post Reply
User avatar
egami
php-forum GURU
php-forum GURU
Posts: 2196
Joined: Wed Oct 06, 2010 11:19 am
Location: Happy Valley, UT

Re: Add item to MySql without leaving a webpage

Post by egami » Fri May 20, 2011 5:20 am

You'll need to learn a little about AJAX and CSS.

User avatar
macek
php-forum Active User
php-forum Active User
Posts: 277
Joined: Wed Aug 25, 2010 10:42 am
Contact:

Re: Add item to MySql without leaving a webpage

Post by macek » Sun May 22, 2011 10:29 am

You must use some JavaScript ,.. I recommend to use jQuery ( jQuery POST - http://api.jquery.com/jQuery.post/ and jQuery LOAD - http://api.jquery.com/load/ )

User avatar
webinfopedia
New php-forum User
New php-forum User
Posts: 84
Joined: Sat May 21, 2011 10:26 pm
Contact:

Re: Add item to MySql without leaving a webpage

Post by webinfopedia » Thu May 26, 2011 11:24 pm

Here am posted an article called submit a form without refreshing a web page. Hope that it will help you.
Here is the article link
http://www.webinfopedia.com/registratio ... n-php.html
Am using Ajax to submit the form

Code: Select all

<script type="text/javascript">
                $(document).ready(function()
                {
                $("#register").click(function(){
                var element = $(this);
                var Id = element.attr("id");
                var loadplacecomment = $("#message");
                
                var username = $("#username").val();
                var password = $("#password").val();
                var email = $("#email").val();
                var mobile = $("#mobile").val();
                var dataString = 'username='+ username + '&password='+ password + '&email='+ email +'&mobile='+ mobile;
                //alert(dataString); 
                if(username==''|| password=='' || email=='' || mobile=='')
                {
                alert("Please Enter all the Fields");
                }
                else
                {
                $("#flash").show();
                $("#flash").fadeIn(400).html('<img src="ajax-loader.gif" align="absmiddle"> loading.....');
                
                $.ajax({
                type: "POST",
                url: "ajaxinsert.php",
                data: dataString,
                cache: false,
                success: function(html){
				loadplacecomment.html('');
                $("#message").append(html);
                $("#flash").hide();
                }
                });
                }
                return false;});});
                </script>
Thank You.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest