Results 1 to 5 of 5
  1. #1
    Join Date
    Jul 2005
    Burlington, VT

    Can you tell me whats wrong with this code?

    <form method="post" action="contact1.php">
    Subject:<input type="text" name="subject"><br>
    <textarea name="body" cols="50" rows="12"></textarea>
    <input type="submit" value="Send">
    //if submit has value
    if (isset($_POST['submit'])) {
    //send mail
    mail ('',$_POST['subject'],$_POST['body']);
    } else {
    die ();
    Last edited by -=Superfly=-; 12-04-2005 at 01:28 PM.

  2. #2
    Join Date
    Oct 2005
    I've had problems with the post method recently, and I found toying with it works. It also might be your mail function, but I'm not familar with the mail function. Might try the following

    if (isset($_POST["submit"])) {


    if (isset($_POST["body"]) AND isset($_POST["subject"]){

    Trying mixing up the ' and ", sometimes that solves my problem. Also, before doing the if statement on the second page, try putting "print_r($_POST);" and //ing out the rest. That will print the $_POST superglobal array and tell you if data is being passed from the form page or if your error is there. I wrote a news system (admin can post a news item and users can post comments) a while ago and has SOOOOO many post problems. Good luck. Let me know if any of that works.

  3. #3
    Join Date
    Oct 2003
    dumping the $_POST variable is a very good thing to do when you are stuck in such a situation. dumping vars to debug is always handy.

    If you would dump the $_POST var you would see that it has no "submit" index.

    There fore isset($_POST["submit"]) will return false.

    You have to give your submit button a name in order to post it as a value together with the other form data.

    So do:
    <input type="submit" name="submit" value="Send">

    This makes the variable 'submit' wil be send with the value 'Send';
    $_POST['submit'] == "Send"; //true

  4. #4
    Join Date
    Jul 2005
    Burlington, VT
    ok guys, thanks

  5. #5
    Join Date
    Mar 2002
    dumb question to ask but contact1.php is the page where all this code is located right? So the page submits to itself?
    you could use $_SERVER['PHP_SELF'] as the action then...
    anyway.. yeah it might be your mail function... try also placing a value in die();
    This way a message will be shown if isset($_POST['submit']) fails..

    might also wanna check out

    I am not sure if isset produces the correct outcome with superglobals...

    Well hope this helps.. a little... =)

Posting Permissions

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