Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Feb 2010
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Arrow Ignoring isset??

    Ok, for the first time, i am attempting to write a basic form to email script, the problem is the darn thing seems to be completely ignoring the three isset's that I have at the top.

    Here is my code,

    PHP Code:
    <?php
    //if name, email and messgage are filled out, continue
    if(isset($_REQUEST['email'])){

    if(isset(
    $_REQUEST['name'])){

    if(isset(
    $_REQUEST['message'])){

    //gather the required information from the form and set them into variables
    $name $_REQUEST['name'] ;
    $email $_REQUEST['email'] ;
    $emailmessage $_REQUEST['message'] ;

                
    //All Fields Are filled Out, we can continue towards sending the email!
                
                //validate the given email address, to prevent nasty happenings!
                
    if(eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$"$email)) {
                
                
    //Email address is vaild and all fields are filled out, lets do this thang!
                
                
                
                //The email address to send the message to, Edit As Required
                
    $emailto 'test@test.com';
                
                
    //The subject Line of the email:
                
    $subject 'A Message From The Website';
                
                
    $message 'The following message has been sent:';
                
    $message $emailmessage ;
                
                
    //mail(to,subject,message,headers,parameters)
                
    $headers "From: $email";
                
                
    //after all that, one line to actually fire off the email!
                
    mail$emailto $subject $message $headers);
                
                
    //email has been sent, we can send a success message
                
                
    header'location: contactsuccess.html');
                    
                } 
                else { 
                
    //Email Address has come back as invalid:
                
    header('location: emailerror4.html');
                die();
                }


    }else{
    //Message Field is not filled Out
    header('location: emailerror2.html');
    die();
    }

    }else{
    //Name Is Not Filled Out    
    header('location: emailerror1.html');
    die();    
    }

    }else{
    //email not filled out
    header('location: emailerror3.html');
    die();    
    }
    ?>
    When submitting the form i will get sent to either emailerror4 or success if a correct email address was entered. No matter whether I have entered anything in the name or message fields.

  • #2
    Senior Coder Nightfire's Avatar
    Join Date
    Jun 2002
    Posts
    4,266
    Thanks
    6
    Thanked 48 Times in 48 Posts
    You need to check to see if they're empty or not. If email, message etc is in the form and you process the form, the variables are set, although empty.

    if(isset($_REQUEST['email']) && !empty($_REQUEST['email'])){

  • #3
    New to the CF scene
    Join Date
    Feb 2010
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thank You for putting up with my noobieness, worked a treat.

  • #4
    New to the CF scene
    Join Date
    Aug 2013
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks, helped me too. I was having absolutely the same problem.


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •