Web Hosting Talk







View Full Version : PHP Questions


Moogabytes
06-20-2006, 05:10 AM
How do you check the MySql database to see if something has already been inputed. For example an email, Check if $email is in the database. Also I want to know how to use select on forms, I know the tags, but don't know how to configure it for what they choose. All help will be appreciated.
Thankyou,
Luke

Amina Moosa
06-20-2006, 05:46 AM
How do you check the MySql database to see if something has already


$searchfor="the email you want";

$query="select * from tablename where `email`="$searchfor;
$result=mysql_query($query,$link);
$row_num=mysql_num_rows($result); //this function give you NO of selected record

if ($row_num <> 0 ) // email is avalible on DB
echo "email is existing";

else
{ //do what you wanna }



how to configure it for what they choose


if the select name is mylist
after the user submit the form
you can use this code :

echo $mylist;
echo $_POST['mylist']; //if method=post
echo $_GET['mylist']; //if method=get