Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

php contact forms and post variable

  • 02-05-2011 04:45PM
    #1
    Closed Accounts Posts: 19,080 ✭✭✭✭


    so i have www.test.com/file.php

    in this file.php i have some variables which are name, address and email.

    i call this file.php from an application which uses the server to send an email with various details.

    i would like to prevent this file sending a blank email when i goto www.test.com/file.php without putting any variables in.

    i have tried checking empty, "", etc on the post variables but i'm having no success.

    can you recommend a way to check if a post variable is set or empty so that i can add in an if/else?

    thanks


Comments

  • Closed Accounts Posts: 4,001 ✭✭✭Mr. Loverman


    !isset
    ""
    null

    Maybe show us your code so we can see if you are doing something funny.


  • Registered Users, Registered Users 2 Posts: 437 ✭✭t1mm


    if (isset($_POST['email']) && isset($_POST['name']) && isset($_POST['address'])){
         //send email
    }
    else {
          echo("One or more inputs were not supplied.");
    }
    

    Replace POST with GET depending on how the data is being sent.


Advertisement