PDA

View Full Version : Check if email exists in MySQL DB


Ralla
10-26-2005, 12:48 PM
Hi, I have a form with some fields called name, email and zipcode. These data are saved in a mysql database via some php scripts. It's for a competition, so people should only be able to sign up once with their email adress. But I can't figure out how this should be checked in the database.

Here is the validation:

if (navn == null) {
gotoAndPlay(1);
navn = "Skriv dit navn";
} else if (zip == null) {
gotoAndPlay(1);
zip = "Skriv dit postnummer";
} else if (email == null) {
gotoAndPlay(1);
email = "Skriv din email";
} else {
gotoAndPlay("post");
};

And here is the post action:

loadVariablesNum("post.php", 0, "GET");

I tried working with LoadVars.sendAndLoad, but couldn't make it work... any help will be great!

peptobismol
10-28-2005, 05:03 AM
you should check if a record exist in the php page...not flash

Ralla
10-28-2005, 09:44 AM
I have made the php script tjecking if the email exist. Now, if it does, I would like to go to a specific frame.... how is that done?

Here's my php:

$navn = addslashes($_GET['navn']);
$zip = addslashes($_GET['zip']);
$email = addslashes($_GET['email']);
$svar1 = addslashes($_GET['svar1']);
$kontaktes = addslashes($_GET['kontaktes']);
$dagsdato = date("d-m-y");

$result = mysql_query("SELECT email FROM shouts WHERE email = '$email'")

or die (mysql_error());

$number = mysql_num_rows($result);

if ($number > 0) {

print = "HAT";

} else {

$query = "INSERT INTO shouts (navn, zip, email, svar1, dato, kontaktes)
VALUES ('$navn', '$zip', '$email', '$svar1', '$dagsdato', '$kontaktes')";

mysql_query($query) or die(mysql_error());

Cota
10-29-2005, 03:25 AM
In the PHP file, have a variable set to either "yes" or "no". If the email exists, then the variable will be yes, if not, then no. Pass that one variable back to flash, in flash you'll say if variable equal to yes, then play this frame, else play another frame...follow me?

Ralla
10-31-2005, 07:54 AM
Yup got that part.

Solved it myself though :)