Help Me In If statement in Database

Discussion in 'Databases' started by actress143, May 11, 2010.

  1. #1
    i am using email adding program... for my company
    so in that
    1. email should not be same for that i used

    if(mysql_num_rows(mysql_query("SELECT name FROM appsubmitn WHERE email = '$email'"))){
    $msg=$msg."E-Mail already exists. Please try another one<BR>";
    $status= "NOTOK";}


    working


    2. email should not be empty..

    for this what i have to do please help me, dont say..

    if(mysql_num_rows(mysql_query("SELECT email FROM appsubmitn WHERE email = ''"))){
    $msg1=$msg1."You must enter email address<BR>";
    $status1= "NOTOK";}


    Why because it was allowing one time empty email into database

    from second time it will showing the error message.. so what i have to do
     
    actress143, May 11, 2010 IP
  2. 50plus

    50plus Guest

    Messages:
    234
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #2
    I am an ASP coder so I cannot write the correct syntax for the language you use but I would format it this way :

    ("SELECT email FROM appsubmitn")
    if [formfield email]=""
    $msg1=$msg1."You must enter email address<BR>";
    $status1= "NOTOK";}

    First see if the email address is in the db, then reply accordingly.

    ("SELECT email FROM appsubmitn WHERE email = ''") the query cannot select email if the formfield is empty unless you have another parameter that you can add on what row to search.
     
    50plus, May 12, 2010 IP