Skip to main content

Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

  • This topic is empty.
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #33619
    deadlow
    Member

    Ok, so I am learning PHP and having trouble with some basic code. I have a text box with a submit button to enter an email address for a mailing list. I want the the code to check to see if anything has been filled out and if so enter it into the database, at the same time check to see if that email address has already been submitted. The code I have written just keeps adding new email addresses even if the field is blank, what am I doing wrong? I have supplied the code below:

    mysql_query(“INSERT INTO users (email)
    VALUES (‘$email’)”);
    echo “Success!”;
    } else {
    echo “Please enter a valid email address.”;
    }

    ?>

    #83876
    deadlow
    Member

    *This part of the code provided is supposed to check if the field is blank

    #83877
    stevendeeds
    Member
    #83878
    Billy
    Participant

    to check if it’s blank, just do:

    
    $email = mysql_real_escape_string($_POST);

    if ($email) {
    *Rest of code*
    } else {
    echo 'Please fill all fields';
    }
    ?>
    #83882
    deadlow
    Member

    That worked cyneWATCH, thanks for that. Why would taking the isset out make it work? I kinda figured that adding an isset would test wether is was there or not like a boolean?

    stevendeeds, thanks for that link I am def. gonna go through that one…

Viewing 5 posts - 1 through 5 (of 5 total)
  • The forum ‘Back End’ is closed to new topics and replies.