www.webdeveloper.com
Results 1 to 2 of 2

Thread: Jquery how to read posted data i na form

  1. #1
    Join Date
    Jun 2013
    Posts
    20

    Jquery how to read posted data i na form

    hi!

    now my problem is how to read the data inputted by a user, i have tried to do some simple form and php file only to verify if i have understand, but i obviously havn't! -.-

    here are the form, the php file and the javascript:


    Code:
    			<form action="login.php" method="post" id="form_homepage_login">
    				
    				<label for="username" id="label_username">Username: </label>
    				<input type="text" name="username" id="input_username" maxlenght="30" size="20" autofocus  />
    				
    				<label for="password" id="label_password">Password: </label>
    				<input type="password" name="password" id="input_password" maxlenght="30" size="20"  />
    
    				<input type="submit" id="submit_login" value="Log In" />
    			</form>
    
    
    
    
    
    <?php
    
    	$username = $_POST['username'];
    	$password = $_POST['password'];
    	
    	if($username=="svidotto" and $password=="123456789")
    		{
    		print "Logged in!";
    		{
    	else
    		{
    		print "Error!";
    		}
    ?>
    
    
    
    
    
    
    	$("#submit_login").click(function(){
    	  $.post("login.php",
    	 {
    		var username = $('#input_username').val();
    		var password = data.find('#input_password').val();
    	  },
    	  login_succesfull(data,status,xhr){
    		
    		if (status == "SUCCESS")
    		{
    			window.location.href = "/login";
    		}
    		
    		else
    		{
    			alert(data);
    		}
    		
    	  }, "text");
    	});
    
    
    	
    
    	});

    do i have to define the action and the method in the form or not?
    where are my mistakes?

    THX!

  2. #2
    Join Date
    May 2006
    Location
    Somewhere behind your screen
    Posts
    1,671
    Last edited by Padonak; 06-27-2013 at 01:46 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles