hi i need help with a registration script that tells you instantly if the email is used , and if they didnt fill in a required thing. so here is the script that i have so far that tells you if the username is taken , i want to switch it to email , so how do i do that? i don't want them to have a username , i just want them to have first name , last name , age , zip , phone , email , password , and city. here is my script , I've tried all i can to change it to the desired thing i need but i cant , here is my codes! PLEASE HELP!
HERE IS signup.php
PHP Code:
<?php // signup.php
include_once 'header.php';
echo <<<_END <script> function checkUser(user) { if (user.value == '') { document.getElementById('info').innerHTML = '' return }
$query = "SELECT * FROM members WHERE user='$Email'";
if (mysql_num_rows(queryMysql($query))) { $error = "That Email already exists in our database!"; } else { $query = "INSERT INTO members VALUES('$user','$pass','$Email')"; queryMysql($query); die("<h4>Before you can login , check your email for a confermation email!"); }
Well the first problem is, your database table doesn't seem to be setup to accept all the fields you want to include.
From what I can deduce, your table has only three columns (one for each - user name, password and email).
In your main page you have these two queries:
PHP Code:
$query = "SELECT * FROM members WHERE user='$user'"; $query = "SELECT * FROM members WHERE user='$Email'";
The first query is correct because it's checking the user name against the values in the user column.
The second query is incorrect because the email address is not stored in the user column.
So it should be checking the email address against the values in the email column.
And to make your checkEmail(email) function work, you just need to make a copy of checkuser.php and rename it to checkemail.php
And then change it to something like this:
You have to make sure your column names are correct in the queries.
Sense I don't know the exact names you use, I can only put in names that would make sense to me.
So edit your queries as needed to match what's in your members table.
And don't worry so much, take a break and try again.
I sucked when I was learning, but I kept at it and I finally learned.
Your not going to be perfect in just a couple of days or even a couple months.
I have been doing this for about 4 years.
Just keep trying, you'll get it.
Hint: Get your checkuser.php and checkemail.php programs working by themselves, so they produce the desired output.
That output is what will be returned to AJAX.
$query = "SELECT * FROM members WHERE user='$Email'";
if (mysql_num_rows(queryMysql($query))) { $error = "That Email already exists in our database!"; } else { $query = "INSERT INTO members VALUES('$user','$pass','$Email')"; queryMysql($query); die("<h4>Before you can login , check your email for a confermation email!"); }