submit button sending all the info

Discussion in 'PHP' started by onizuka, Feb 11, 2009.

  1. #1
    Hey, I'm trying to make a submit button that sends a mail to me where the info of the mail will be the url it was sent from, or title. I have this so far, but it sends a blank mail:
    <?php
    if($_POST['submit'] == 'go!'){
        //form was submitted
    $to = "mail@example.com";
    $subject = "hehey";
    $email = "mail2@example.com";
    $message = the_title();
    $headers = "From: mail2@example.com";
    $sent = mail($to, $subject, $message, $headers) ;
            echo 'Thanks for submitting the form';
            die();
    }
    echo '<form method="POST">
    <input type="submit" name="submit" value="go!">
    </form>';
    if($error){ echo '<div class="error">' .$error .'</div>'; }
    ?>
    PHP:
    I'm using wordpress, and this is in a theme functions file, within the loop, so i figured "the_title()" would work.
    Hope this makes sense;) thanks
     
    onizuka, Feb 11, 2009 IP
  2. tihan

    tihan Active Member

    Messages:
    64
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    93
    #2
    Try
    echo the_title();

    If it works, then the problem is somewhere else...
     
    tihan, Feb 11, 2009 IP
  3. onizuka

    onizuka Peon

    Messages:
    39
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    that didnt work :/ i just want to send a mail with the url/title it was sent from as info.
     
    onizuka, Feb 11, 2009 IP
  4. onizuka

    onizuka Peon

    Messages:
    39
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Figured it out, get_the_title() worked, now i only want to find a way to not have to use die(); since then comment form and sidebars wont show after the button is clicked :(
     
    onizuka, Feb 12, 2009 IP
  5. tihan

    tihan Active Member

    Messages:
    64
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    93
    #5
    Try else instead of die:

    if($_POST['submit'] == 'go!'){
    //form was submitted
    $to = "mail@example.com";
    $subject = "hehey";
    $email = "mail2@example.com";
    $message = get_the_title();
    $headers = "From: ";
    $sent = mail($to, $subject, $message, $headers) ;
    echo 'Thanks for submitting the form';
    }
    else {
    echo '<form method="POST">
    <input type="submit" name="submit" value="go!">
    </form>';
    if($error){ echo '<div class="error">' .$error .'</div>'; }
    }
    ?>
     
    tihan, Feb 12, 2009 IP
  6. onizuka

    onizuka Peon

    Messages:
    39
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Thanks alot mate, i love you^^ didn't see that at all :p
     
    onizuka, Mar 9, 2009 IP