Hello,

I am writing a code to for a registration form in php,i am done with adding field to database the problem is "validation" there are msnu feilds in the form .I have to validate two feilds in my form username and email before submiting (in short i have to check entered value is already avialable or not if yes then continue or display error)

please help


thank you

Recommended Answers

<?php
if(!filter_var($_POST['email'], FILTER_VALIDATE_EMAIL))
  {
 //email valid
  }
else
  {
  //not valid
  }
//in username u have to make select query to see if user exist in youre database
$check = mysql_query("select username from members where username='$_POST[username]'");
if(mysql_num_rows($check)<1){
//username availble
}
else{
//username taken
}
?>

theres a …

Jump to Post

All 2 Replies

<?php
if(!filter_var($_POST['email'], FILTER_VALIDATE_EMAIL))
  {
 //email valid
  }
else
  {
  //not valid
  }
//in username u have to make select query to see if user exist in youre database
$check = mysql_query("select username from members where username='$_POST[username]'");
if(mysql_num_rows($check)<1){
//username availble
}
else{
//username taken
}
?>

theres a lot of way to validate variables. do some experiment

cheers :)

thank you for your reply

but i want ajax validation to check if the user is already exist or not

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.20 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.