Need help with AJAX code for Checking Email Regristration
Posted by StoryoftheRealms • 421 Views • 27 Replies • FacebookTwitter
Posted by StoryoftheRealms • 421 Views • 27 Replies • FacebookTwitter
<pre>
if (strlen($q) > 0)
{
$result = mysql_query("SELECT * FROM emails");
$numresults = mysql_num_rows($result);
{
if ($numresults == "0")
{
$response=" Email is Available";
}
else
{
$response=" Email is Already Registered";
}
}
}
</pre>
$q will never = $result because $result is a resource, not an actual value. if you do echo $result; you'll see what i mean
I shall test get back to you in a few mins.
Jun 28th, 2007Okay that now makes anything I type in =" Email is Already Registered"
Jun 28th, 2007$dbh=mysql_connect ("localhost", "*******", "*******") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("*********");
$q=$_REQUEST["q"];
$result="";
if (strlen($q) > 0)
{
$result = mysql_query("SELECT * FROM emails");
$numresults = mysql_num_rows($result);
{
if ($numresults == "0")
{
$response=" Email is Available";
}
else
{
$response=" Email is Already Registered";
}
}
}
echo $response;
It now looks like that. and does what I said
yes you need to refine your query:
SELECT * FROM emails WHERE email='$q'
I shall try that, reply in afew
Jun 28th, 2007Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/jerzxu/public_html/testfolder/email.php on line 15
Email is Available
I got that.
time to debug, did you make sure that the field name is indeed "email" ( i just assumed )
i know this is nutty but try this :
$sql = "SELECT email FROM emails WHERE email='$q'";
$result = mysql_query($sql);
try echo $sql; too to see if its printing out $q properly
by field I am assuming you mean the table I had to manually create to get my entry into the database. The jerzxu entry (its used as a email) is put under ID emaillist in table emails.
BTW I've only started learning this since 2 days ago. lol, so if I ask alot of questions please don't mind.
i dont mind at all :) - you're tackling a huge fish for starting 2 days ago, i took baby steps, flat text files before i even considered learning what mysql was lol
ok when you created the table, you had to create a field ( probably varchar .. ) whatever you named that, is where "email" needs to go, so if you named that field "emaillist" then replace "email" with "emaillist".
are you using phpMyAdmin by chance? if not, you should get your host to install it, or try to install it yourself. its a web-browser interface for managing your mysql databases and tables - absolutely PRICESS (www.phpmyadmin.net)
yeah phpMyAdmin indeed. Took me a few minutes to figure it out.
Jun 28th, 2007ok then, when you click on your emails table, and click 'browse', it'll give you a grid, whatever column the email is listed under is the name you want to put in your query
Jun 28th, 2007so ID emaillist
Jun 28th, 2007try it out =) worst it'll do is say error =)
$sql = "SELECT emaillist FROM emails WHERE emaillist='$q'";
no error but it didn't change anything
Jun 28th, 2007ok go to phpmyadmin, go to your table, and click the SQL link, put in the sql query, except instead of $q put in the email you're testing with, tell me if it gives back any rows.
if you want to hop in irc and talk faster i'm logged in ;)
kk be in IRC in a secondskeee
Jun 28th, 2007RESOLVED, thanks VEX!
Jun 28th, 2007whoa vex, good work on helping him. yea, learning mysql in a day is no easy talk. i love phpmyadmin too. ♥
are you sending your big brothers if he doesn't pay? :p
haha, if i had any!
He's a quick learner, it helps he's got some prior actionscripting experience so the syntax isnt completely foreign.
he's got some crazy aspirations ;) reminds me of me when i was his age! want to learn the entire internet in 1 sitting. - speaking of, i'm tapping my foot at my host to wake up so i can beg and threaten him into installing Ruby ( on rails ) for my server so i can learn it. if people aren't afraid to learn something new RoR = the best internet sex for geeks on the planet. ( www.rubyonrails.com - watch the screencasts/presentations - weblog in 15min ) ok I got to go to bed. i just re-wrote my entire links-homepage in database format cause i am a nerd :x
btw, you ever looked at cocoasql? its mac program for database managing. i lub it too.
i've checked rubyonrails before and that demo as well, i might like it but right now, i'm really focusing on PHP. yes, it can be great, but at the same time, is there any reason at all to switch or learn it when you're already developping on php and it works great?
cocoasql? database managing on Mac are beautiful words to my ear. i'll check it out!
I dont know all the particulars yet, but holy jeebus, it pretty much eliminates the need for HTML LOL.
it reads the database, text field? ok, here's your textarea, varchar? here's your input box... it auto builds it based on the field types of the table. that just.. wow. it gets me so hot. lol. oh god, im going to bed. i'll chat you up in a few hours =D - im not going to get very much sleep cause my brain is so danm hungry for information right now.
lol alright, let's start a Ruby on rail topic. i'm interested to hear about it. richholt has used it before but he wants to switch to PHP. let's ask his opinion too. g'nite!
Jun 28th, 2007k, you start it, i put a note on my host's desk to lemme know if he can install it, i'll know by the time i wake up, i'll scour the internets and post any and all tut goodies i find on Ruby, i'd love to hear why rich wants to switch, besides that its more mainstream.
omg. bf. going. to. murderize meeee.. i dont want to sleep. O.O
sounds awesome. go sleep! geebus.
Jun 28th, 2007
Okay basically I need help with some coding for the registration for my website. Anyways the code checks (using AJAX) the database to see if the email, and username are registered.
Jun 27th, 2007Now it works, but when it gets to the php portion it should say (if you type in jerzxu) Email is Already Registered. Unfortunately it says its available.
Heres a link to a page on my website that displays the codes.
CODE