Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 06-27-2009, 04:35 PM   PM User | #1
Kev0121
New Coder

 
Join Date: Mar 2009
Posts: 97
Thanks: 10
Thanked 0 Times in 0 Posts
Kev0121 is an unknown quantity at this point
Is this possible with jquery, ajax and php

What im wanting to do is use jquery and ajx for live validation, so lets say i wanted to change my current passowrd in my usercp.php and when i typed in my current password i would have on the side if it was corrent or not, so if it was corrent display "corrent" or if it was wrong do "wrong password", and id want php in the background grabbing his password from the database, and checking if it was corrent. Is this possible?

Hopefully it is, anythings possible now'a days :P

Thanks, KJD.
Kev0121 is offline   Reply With Quote
Old 06-27-2009, 06:19 PM   PM User | #2
Jack Ellis
New Coder

 
Join Date: Jun 2009
Location: West Sussex
Posts: 27
Thanks: 0
Thanked 4 Times in 4 Posts
Jack Ellis is an unknown quantity at this point
Yes.

use onkeyup
Jack Ellis is offline   Reply With Quote
Old 06-27-2009, 06:46 PM   PM User | #3
Kev0121
New Coder

 
Join Date: Mar 2009
Posts: 97
Thanks: 10
Thanked 0 Times in 0 Posts
Kev0121 is an unknown quantity at this point
Could you explain a bit more please?

Thanks

KJD.
Kev0121 is offline   Reply With Quote
Old 06-27-2009, 07:26 PM   PM User | #4
razkevin
New to the CF scene

 
Join Date: Jun 2009
Posts: 4
Thanks: 1
Thanked 0 Times in 0 Posts
razkevin is an unknown quantity at this point
Yes this is possible, using ajax...
and php/mysql connection.

http://www.roscripts.com/Ajax_form_validation-152.html
razkevin is offline   Reply With Quote
Old 06-27-2009, 07:58 PM   PM User | #5
Kev0121
New Coder

 
Join Date: Mar 2009
Posts: 97
Thanks: 10
Thanked 0 Times in 0 Posts
Kev0121 is an unknown quantity at this point
Thanks Kevin for the link, but i was looking for one when its live, so when you type it, it tells you then and there not when you click submit =p

KJD.
Kev0121 is offline   Reply With Quote
Old 06-28-2009, 12:30 PM   PM User | #6
Jack Ellis
New Coder

 
Join Date: Jun 2009
Location: West Sussex
Posts: 27
Thanks: 0
Thanked 4 Times in 4 Posts
Jack Ellis is an unknown quantity at this point
For instance (THIS IS NOT TESTED) you could have this:

Code:
<input type="text" id="username"><br>
<span id="returnMessage"></span>
Then at the botton of the page or in an external file have

Code:
$('#username')..keyup(function(event){

var username = $('#username').val();

$.post("check.php", { username: username" },
  function(data){
    $('#returnMessage').html(data);
  });

});
Then on check.php this will be my example.

PHP Code:

// NO SECURITY ON THIS CBS

if ($_POST['username'] == 'Jack'){

echo 
'This username is taken';

}else{

echo 
'This username is free';

}

?> 
Jack Ellis is offline   Reply With Quote
Old 06-28-2009, 12:56 PM   PM User | #7
Kev0121
New Coder

 
Join Date: Mar 2009
Posts: 97
Thanks: 10
Thanked 0 Times in 0 Posts
Kev0121 is an unknown quantity at this point
Thanks for your answers. Isnt there anyway i can check the database? like do an sql query and then echo weather its available or not? or is that not possible?

Thanks, KJD.

Last edited by Kev0121; 06-28-2009 at 01:00 PM.. Reason: spelling errors
Kev0121 is offline   Reply With Quote
Old 06-28-2009, 04:11 PM   PM User | #8
Jack Ellis
New Coder

 
Join Date: Jun 2009
Location: West Sussex
Posts: 27
Thanks: 0
Thanked 4 Times in 4 Posts
Jack Ellis is an unknown quantity at this point
Quote:
Originally Posted by Kev0121 View Post
Thanks for your answers. Isnt there anyway i can check the database? like do an sql query and then echo weather its available or not? or is that not possible?

Thanks, KJD.
Well yeh. In the PHP FILE

PHP Code:
<?php

// DB CONFIG UP HERE?
// NO SECURITY ON THIS CBS

$username mysql_real_escape_string($_POST['username']);

$checkUser mysql_query("SELECT * FROM `users` WHERE `username` = '$username'");

if ((
mysql_num_rows($checkUser)) == '0'){

echo 
'This name is free';

}else{

echo 
'This name is taken';

}

?>
Sorry for awful coding ;D
Jack Ellis is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 02:57 PM.


Advertisement
Log in to turn off these ads.