Jump to content
Sign in to follow this  

Jquery,AJAX & PHP, form submition not working

Recommended Posts

hey guys Basically i am trying to create a validation for the form. I want it to check if it can connect to the DB and if true to proceed to another page and if false to return an error. I am inputting the wrong details to make it just display the error but somehow it always returns "TRUE" on page load... and everytime i click the submit it doesnt do anything regardless of my entry... Can anyone tell me why?

<script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script>	<script>  $(document).ready(function(){var u = $('#username');var s = $('#server');var p = $('#password'); $('#iValForm').submit($.post("connect.php", {u: u.val(),p: p.val(),s: s.val()}, function(fd){  if (fd == "true"){  alert("Is: " + fd);  return false;	  } // if1  if (fd == "false"){  alert("Is2: " + fd);  return false;	  } // if2} //post function) //Post) //submit  }) //document  </script></head>  <body> <form class="iValForm" id="iValForm" method="post" action=""><fieldset><legend id="error"> </legend><p><label for="username">Username </label><input id="username" name="username" class="required" /> </input></p><p><label for="password">Password</label>	<input id="password" name="password" class="required"/> </input></p><p><label for="server">Server</label>	<input id="server" name="server" class="required"/> </input></p><p>	 <input class="submit" id ='submit' type="submit" value="Submit"/></p></fieldset></form>


<?php$user = $_POST['u'];$password = $_POST['p'];$server = $_POST['s'];@$con = mysql_connect ($server, $user, $password); if (!$con) {$response = 'false';echo $response;} else {  $response = 'true';  echo $response;}?>

Edited by thurft

Share this post

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

  • Create New...