Hello everyone am having trouble with a system am creating, i am work on a registration system but i ran into a little bit of a problem. I searched the forum but cant seem to find any threads related to the problem..
OK the problem is that i want users to have their unique email address, i realized when i signed up with the same email twice i don't get an error message saying email address is already in use.
1: How do i query MYSQL and trigger a pop up message saying email is already in use.
2: I will like to have it embedded right in the form where the email input are, similar to how hotmail and yahoo has it, instant email check on the register page
will i need to use java script there?
Thank You,
Kendall
User unique email address
Started by MrBenjamin, Aug 22 2009 04:13 PM
5 replies to this topic
#1
Posted 22 August 2009 - 04:13 PM
|
|
|
#2
Posted 22 August 2009 - 04:36 PM
yes you will need javascript because you will use AJAX
you will need to send (request) the email address in the input field to the server-side when the user changes (or types) the value of the input box
and the server-side will run a query to check if the email already exists , and sends back the result as a response to the client AJAX request
you will need to send (request) the email address in the input field to the server-side when the user changes (or types) the value of the input box
and the server-side will run a query to check if the email already exists , and sends back the result as a response to the client AJAX request
yo homie i heard you like one-line codes so i put a one line code that evals a decrypted one line code that prints "i love one line codes"
eval(base64_decode("cHJpbnQgJ2kgbG92ZSBvbmUtbGluZSBjb2Rlcyc7"));
www.amrosama.com | the unholy methods of javascript
#3
Posted 22 August 2009 - 05:01 PM
Basically start with a php file that gets one GET input, check if that email is in the database, and make the file print a 0 or a 1 depending.
Use AJAX like Mr. Amr said and use that to check if its a 0 or 1
Use AJAX like Mr. Amr said and use that to check if its a 0 or 1
#4
Posted 22 August 2009 - 05:47 PM
So therefore i will be inserting
1: Some email checker code into my registration form?
Like this?
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$('input#process').click(function(){
var requested_email = $('input#email').val();
$.get("email_checker.php", {email: requested_email},
function(data){
if(data){
$('form#my_form').submit();
}
else{
$('span#error_msg').text('Email '+requested_email+' have been used');
return false;
}
},
"json"
);
});
});
</script>
</head>
<body>
<form name="my_form" id="my_form" method="post" action="process_email.php">
<input type="text" name="email" id="email" /><span id="error_msg"></span>
<input type="button" value="Check Availability" id="process" />
</form>
NOT SURE IF THIS IS THE RIGHT CODE!
2: An email checker page to connect and query mysql and check if the email exist already?
3: Then the response to if the email exist echo it along side email input?
Please let me know
Thank you,
Kendall
1: Some email checker code into my registration form?
Like this?
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$('input#process').click(function(){
var requested_email = $('input#email').val();
$.get("email_checker.php", {email: requested_email},
function(data){
if(data){
$('form#my_form').submit();
}
else{
$('span#error_msg').text('Email '+requested_email+' have been used');
return false;
}
},
"json"
);
});
});
</script>
</head>
<body>
<form name="my_form" id="my_form" method="post" action="process_email.php">
<input type="text" name="email" id="email" /><span id="error_msg"></span>
<input type="button" value="Check Availability" id="process" />
</form>
NOT SURE IF THIS IS THE RIGHT CODE!
2: An email checker page to connect and query mysql and check if the email exist already?
3: Then the response to if the email exist echo it along side email input?
Please let me know
Thank you,
Kendall
#5
Posted 23 August 2009 - 07:43 AM
what if user disabled the javascript?
your form will works without javascript enabled browsers?
if yes, don't forgot to check the email address from PHP too (when everything is fine and you want to insert the new user to the database).
your form will works without javascript enabled browsers?
if yes, don't forgot to check the email address from PHP too (when everything is fine and you want to insert the new user to the database).
$check_mail = mysql_query("SELECT email FROM table_name WHERE email='".$_POST['mail']."'");
if(mysql_num_rows($check_mail)<1)
{
mysql_query("INSERT TO.....");
}
#6
Posted 23 August 2009 - 07:43 AM
what if user disabled the javascript?
your form will works without javascript enabled browsers?
if yes, don't forgot to check the email address from PHP too (when everything is fine and you want to insert the new user to the database).
your form will works without javascript enabled browsers?
if yes, don't forgot to check the email address from PHP too (when everything is fine and you want to insert the new user to the database).
$check_mail = mysql_query("SELECT email FROM table_name WHERE email='".$_POST['mail']."'");
if(mysql_num_rows($check_mail)<1)
{
mysql_query("INSERT TO.....");
}


Sign In
Create Account


Back to top










