Board index   FAQ   Search  
Register  Login
Board index PHP PHP Scripts

Add item to MySql without leaving a webpage

Links for php scripts

Moderators: macek, egami, gesf

Add item to MySql without leaving a webpage

Postby feraswheel » Fri May 20, 2011 1:24 am

Hey guys. I got a few things i need help with please.

1 ) I want to add items to a database (comments) while not leaving the same page.

2 ) I want comments (max 20 comments per page) to be visible. With Next and Previous (+numbers) inbetween them, But once clicked, i dont want it to refresh/go to a new page. I want it to just update the current fields.

If you can help me it would be MUCH appreciated!
Thank you so much.
feraswheel
New php-forum User
New php-forum User
 
Posts: 2
Joined: Fri May 20, 2011 1:20 am

Re: Add item to MySql without leaving a webpage

Postby egami » Fri May 20, 2011 5:20 am

You'll need to learn a little about AJAX and CSS.
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

Postby 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
macek
php-forum Active User
php-forum Active User
 
Posts: 277
Joined: Wed Aug 25, 2010 10:42 am

Re: Add item to MySql without leaving a webpage

Postby 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/registration-form-in-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.
User avatar
webinfopedia
New php-forum User
New php-forum User
 
Posts: 84
Joined: Sat May 21, 2011 10:26 pm

Re: Add item to MySql without leaving a webpage

Postby isaiahiroko » Tue Jul 19, 2011 3:19 am

From what i've heard, learning AJAX is your best option. I think it can perform many magics.
isaiahiroko
New php-forum User
New php-forum User
 
Posts: 2
Joined: Tue Jul 19, 2011 2:39 am


Return to PHP Scripts

Who is online

Users browsing this forum: Bing [Bot] and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.