Jump to content

how to check email/user ID avalibilty???

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
3 replies to this topic

#1
hamayun_4u2004

hamayun_4u2004

    Newbie

  • Members
  • Pip
  • 7 posts
everybody... i hope u all ppl will be fine and enjoying.

i m new user here.. if i did any mistakes. i m sorry for that..

Dear i m making a user Registration form... in which i have added a button CHECK AVAILIBILTY
this button work is to chck in DATABASE that the user Input email address or ID is availble are not..???

i m also using php language within the javascript... but i m not getting, how to assign php variable variable value to javascript variable??? plz help me

i know the mysql query..

<?php
$query=mysql_num_rows(mysql_query("SELECT user_email FROM user_area WHERE user_email='email'"))

/*1st email will be taken from input txt field and then match with database. if $query is equal to 1 then its mean email/ID not available, if $query is equal to zero its mean not avalibl.
*/


?>

<script language='javascript'>
function EMAIL_AVALIBLE()
{
var email_chk="document.getElementById('email').value";


// plz tell me what i do here

}
<form action="register_act.php" method="POST" name="register">
E-Mail Address :
<input type='text' name='email' id="email" >
<input type='button' name='Check' onClick='EMAIL_AVALIBLE()' value='Check E-Mail Avalibility' >

</form>

Edited by Jaan, 04 April 2010 - 09:57 AM.
Please use code tags when you are posting your codes!


#2
SoN9ne

SoN9ne

    Programmer

  • Members
  • PipPipPipPip
  • 129 posts
I can hardly understand the post but if you just need to assign a PHP var to Javascript, this is a common method. Did you even use Google?
var test = '<?php echo $var; ?>';


#3
Bioshox

Bioshox

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 207 posts
You need to run a query that checks if there are any rows in the database that match the in putted user name/email, if there is a row that matches then disallow the registration, if it returns nothing then proceed with registration.


<?php

$usrsubmit = $_POST['submit'];

$reg = mysql_connect("localhost", "mysql_user", "mysql_password");
mysql_select_db("database", $reg);

$result = mysql_query("SELECT * FROM users WHERE username = '$usrsubmit'", $reg);
$num_rows = mysql_num_rows($result);

if($result = '1'){

echo "That username is already in use, please go <a href='index.php'>back</a> and try again"

}else{

//Carry out registration process

?>



#4
webcodez

webcodez

    Programmer

  • Members
  • PipPipPipPip
  • 149 posts
Yep, though would check $num_rows to be greater than 0 instead of $result ^^.

Cheers.