PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old February 26th, 2013, 08:18 AM
ziggy786 ziggy786 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2013
Posts: 1 ziggy786 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 8 m 40 sec
Reputation Power: 0
Exclamation PHP-DB - How to make JQueryUI dialog login form?

loginSend.js
Code:
$('#loginButton').on('click', function(){ //the id of the submit button = #loginButton
	
	var username = $('#userfield').val();
	var password = $('#passfield').val();
	
	if (username.length == 0 || password.length == 0 || password.length < 6) { // checks if username and pass have been entered
	
		$('#fillFields').text('*Please enter a valid username/password'); //#fillfields = the div where error message should appear in JQuery UI dialog box
	} else {
		
		//$('#formLogin').text('You have successfully logged in').dialog('close'); //Closes dialog box if logged in currently not in use
		$.post('loginProcess.php', {username: username, password: password}, funtion(data){ // sends data to loginProcess.php
		
			if (data == true){ //checks if the loginProcess has returned true (if the username exists or not)
				alert('true'); // just to check if the code works, display an alert message
			}
	}
		
	});
});

loginProcess.php
Code:
<?php

require 'config.php';

//  LOGIN FORM Process

if (user_exists('super')){ //user_exists() = a user defined function in config.php
	return true;
}
?>

<?php
config.php
Code:
function sanitize($data){
	return mysql_real_escape_string(strip_tags($data));
}

function user_exists($username){

	$username = sanitize($username);
	$query = mysql_query("SELECT COUNT(`id`) FROM `users` WHERE `Username` = '$username'");
	return (mysql_result($query, 0) == 1) ? true : false;
}
?>


i don't understand what I've done wrong. I'm trying to create a JQuery UI dialog, login form. Normlly when the user types in a username i want it to check if the username exists. But nothing happens. Since i added JQuery Post it doesn't work. How do i get it to display if username exists or not. I think the problem is in $.post because before i added that, my code works, but after i added it it stopped working. It doesn't even display error messages? The whole code just doesn't work.

How do i fix this and get it to work as intended?

Thanks

Reply With Quote
  #2  
Old February 26th, 2013, 08:29 AM
ptr2void ptr2void is offline
I haz teh codez!
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Dec 2003
Posts: 2,476 ptr2void User rank is General 18th Grade (Above 100000 Reputation Level)ptr2void User rank is General 18th Grade (Above 100000 Reputation Level)ptr2void User rank is General 18th Grade (Above 100000 Reputation Level)ptr2void User rank is General 18th Grade (Above 100000 Reputation Level)ptr2void User rank is General 18th Grade (Above 100000 Reputation Level)ptr2void User rank is General 18th Grade (Above 100000 Reputation Level)ptr2void User rank is General 18th Grade (Above 100000 Reputation Level)ptr2void User rank is General 18th Grade (Above 100000 Reputation Level)ptr2void User rank is General 18th Grade (Above 100000 Reputation Level)ptr2void User rank is General 18th Grade (Above 100000 Reputation Level)ptr2void User rank is General 18th Grade (Above 100000 Reputation Level)ptr2void User rank is General 18th Grade (Above 100000 Reputation Level)ptr2void User rank is General 18th Grade (Above 100000 Reputation Level)ptr2void User rank is General 18th Grade (Above 100000 Reputation Level)ptr2void User rank is General 18th Grade (Above 100000 Reputation Level)ptr2void User rank is General 18th Grade (Above 100000 Reputation Level) 
Time spent in forums: 1 Month 2 Weeks 2 Days 6 h 23 m 5 sec
Reputation Power: 2194
__________________
I ♥ ManiacDan & requinix

This is a sig, and not necessarily a comment on the OP:
Please don't be a help vampire!

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPHP Development > PHP-DB - How to make JQueryUI dialog login form?

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap