Jump to content

Best way to check if data exist


lJesterl

Recommended Posts

I'm wondering the best method to use to do the following.

 


say if($whatever){

do this

}else{

do this

}

 

i want $whatever basicly to be this. I want to check to see if the input name='emailx' exist as email in table GCuser.

 

Here is the code I used

 


$checkemail=mysql_query("SELECT email FROM GCuser WHERE email='$emailx'");
$ce=mysql_fetch_array($checkemail);

if($emailx == $ce[email]){

//display error

}else{

//execute mysql query
}

 

it works however if they dont change the emailx input field then it errors for them, or if they change the emailx input field from lets say john@john.com to john1@john.com it errors because john1@john.com doesnt exist. I hope someone understand what im trying to ask lol

Link to comment
Share on other sites

Doesnt work 100%

 

If i leave it along when submiting and the email being the default value for the email say john@john.com then it errors or if i change it to anything that exist in the database, however when i change to something that doesnt exist then it works. The only problem left would be if i leave it default and i try to submit it with no change. Is there a way to ignore my error if its my own name?

 

this is my code

 


$checkemail=mysql_query("SELECT email FROM GCuser WHERE email='$emailx' LIMIT 1");

if(mysql_num_rows($checkemail) == 1){

        include("$dir[functions]/error.php");
        display_error("Email is already in use please try another email.<br>");

}else{

$query1=mysql_query("DELETE FROM playerprofile WHERE alias='$ui[alias]'");

$query=mysql_query("insert into playerprofile (alias,xboxcard,aim,yahoo,msn,icq,xfire,skype,xbox360,ps3,wii,location,connection,relationship,orientation,drink,smoker,religion,education,interests) values('$ui[alias]','$xboxcard','$aim','$yahoo','$msn','$icq','$xfire','$skype','$xbox360','$ps3','$wii','$location','$connection','$relationship','$orientation','$drink','$smoker','$religion','$education','$interests')");

$query2=mysql_query("UPDATE users SET logo='$avatar2' WHERE id='$ui[id]'");
$query5=mysql_query("UPDATE users SET email='$emailx' WHERE id='$ui[id]'");
$query4=mysql_query("UPDATE GCuser SET email='$emailx' WHERE username='$ui[alias]'");
$query4=mysql_query("UPDATE GCuser SET aim='$aim' WHERE username='$ui[alias]'");
$query4=mysql_query("UPDATE GCuser SET yahoo='$yahoo' WHERE username='$ui[alias]'");
$query4=mysql_query("UPDATE GCuser SET msn='$msn' WHERE username='$ui[alias]'");
$query4=mysql_query("UPDATE GCuser SET skype='$skype' WHERE username='$ui[alias]'");


}

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.