1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

$5 if you can help me with this simple JQuery Submit Form

Discussion in 'Programming' started by nickharper, Jul 23, 2009.

  1. #1
    Hi,

    I am trying to submit information from a form to a mysql database but I am having a couple of issues in the fact that it doesn't actually send it through.

    I have tested my php file by submitting directly to that and it seems to work fine.

    If you can help me get this working I will send $5 straight away.

    Here is my form:

     <form id="submit" method="post">
    		<fieldset>
    		  <legend>Enter Information</legend>
    			<label for="name">Name:</label>
                           <input id="name" class="text" name="name" size="20" type="text" />
                           <label for="email"><br />
    	      Email:</label>
                           <input id="email" class="text" name="email" size="20" type="text" />
     <input id="gamesid" name="gamesid" type="hidden" value="<?php echo $row_GameInfo['id']; ?>" />
    			<label for="url"><br />
    		    URL:</label>
                           <input id="url" class="text" name="url" size="20" type="text" />
              <label for="comment"><br />
    		    Comment:</label>
                           <textarea name="comment" cols="20" rows="5" class="text" id="comment"></textarea>
                           
     
    			<button class="button positive"> <img src="../images/icons/tick.png" alt="" /> Add Comment!!! </button>
    		</fieldset>
    	</form>
    <div class="success" style="display:none;"><p>Thanks for the comment.</p><p>This will be approved and will appear on Xbox 360 Multiplayer Games within the next couple of hours</p></div>
    Code (markup):
    Here is my Javascript File:

    $(document).ready(function(){
    	$("form#submit").submit(function() {
     	
    	var name     = $('#name').attr('value');
    	var email     = $('#email').attr('value'); 
    	var url     = $('#url').attr('value');
    	var comment     = $('#comment').attr('value'); 
    	var gamesid     = $('#gamesid').attr('value'); 
     
    		$.ajax({
    type: "POST",
    url: "addcomment.php",
    data: "name="+ name +"& email="+ email +"& url="+ url +"& comment="+ comment +"& gamesid="+ gamesid,
    success: function(){
    $('form#submit').hide();
    $('div.success').fadeIn();
    }}); 
    	return false;
    	});
    });
    Code (markup):
    Here is my PHP File:

    <?php
            // where is your config file stored?
    	include ("config.php");
     
    	// CLIENT INFORMATION
    	$name        = htmlspecialchars(trim($_POST['name']));
    	$email        = htmlspecialchars(trim($_POST['email']));
    	$url        = htmlspecialchars(trim($_POST['url']));
    	$comment        = htmlspecialchars(trim($_POST['comment']));
    	$gamesid        = htmlspecialchars(trim($_POST['gamesid']));
     
        $addClient  = "INSERT INTO comments (name,email,url,comment,gameid) VALUES ('$name','$email','$url','$comment','$gamesid')";
        mysql_query($addClient) or die(mysql_error());
     
    ?>
    PHP:
     
    nickharper, Jul 23, 2009 IP
  2. zaay

    zaay Member

    Messages:
    269
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    30
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #2
    Hello ! ;)

    You want us to change this code to work or we can send you another code which will do this right ? ;)
    Contact me with details if slot is still available !

    Thank you !
     
    zaay, Jul 23, 2009 IP
  3. zaay

    zaay Member

    Messages:
    269
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    30
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #3
    SORRY FOR DoUBLE POST :(

    Hello ! ;)

    You want us to change this code to work or we can send you another code which will do this right ? ;)
    Contact me with details if slot is still available !

    Thank you !
     
    zaay, Jul 23, 2009 IP
  4. vasildb

    vasildb Well-Known Member

    Messages:
    845
    Likes Received:
    31
    Best Answers:
    0
    Trophy Points:
    118
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #4
    I analyzed your code, and fixed it. It works now.
    Payment via PayPal or MoneyBookers.
    Thanks.
     
    vasildb, Jul 23, 2009 IP
  5. bindassdelhiite

    bindassdelhiite Active Member

    Messages:
    112
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    55
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #5
    Hi buddy,

    Can you provide a link to its Online version?

    Thanks!
     
    bindassdelhiite, Jul 24, 2009 IP