Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

PHP form - blank messages

Options
  • 15-03-2011 11:49am
    #1
    Registered Users Posts: 54 ✭✭


    Hi,

    Could anyone please help. When I received emails from my contact form, the messages are always blank. What have I forgotten?
    Any help would be appreciated.

    Here is my code:

    <form id="contactform" name="contactform" method="post" action="contactform.php">
    <table width="368" border="0" align="left" cellspacing="10">
    <tr>
    <td width="118">Name</td>
    <td width="293"><span id="name">
    <label>
    <input name="Name" type="text" id="Name" size="40" />
    </label>
    <span class="textfieldRequiredMsg"> required</span></span></td>
    </tr>
    <tr>
    <td>Phone</td>
    <td><span id="telephone">
    <label>
    <input name="phone" type="text" id="phone" size="40" />
    </label>
    </span></td>
    </tr>
    <tr>
    <td>Email</td>
    <td><span id="emailaddress">
    <label>
    <input name="email" type="text" id="email" size="40" />
    </label>
    <span class="textfieldRequiredMsg">required</span><span class="textfieldInvalidFormatMsg">Invalid format.</span></span></td>
    </tr>
    <tr>
    <td>Message</td>
    <td><span id="message">
    <label>
    <textarea name="text1" cols="38" rows="8" id="text1"></textarea>
    </label>
    <span class="textfieldRequiredMsg">A value is required.</span></span></td>
    </tr>
    <tr>
    <td> </td>
    <td><label>
    <input type="submit" name="submit" id="submit" value="Submit" />
    </label></td>
    </tr>
    </table>
    </form>
    </div>
    <div id="footer"><!--


    and my PHP:
    <?php
    $to = "example@example.com";
    $subject = "Contact Us";
    $name = $_REQUEST ;
    $phone = $_REQUEST ;
    $email = $_REQUEST ;
    $query = $_REQUEST ;
    $headers = "From: $email";
    $totalmessage = "
    Name: $name \n
    Phone: $phone \n
    Email: $email \n
    Query: $query \n";
    $sent = mail($to, $subject, $totalmessage, $headers) ;
    if($sent)
    {print "Thank you. We will be in touch shortly. Click back to return to the website"; }
    else
    {print "We encountered an error sending your mail"; }
    ?>


Comments

  • Registered Users Posts: 68,317 ✭✭✭✭seamus


    Try using $_POST instead of $_REQUEST


  • Registered Users Posts: 54 ✭✭Dean3y


    Thanks Seamus, but it didn't change anything.
    Thanks Though!


  • Registered Users Posts: 9,579 ✭✭✭Webmonkey


    Change
    <textarea name="text1" cols="38" rows="8" id="text1"></textarea>
    

    To
    <textarea name="query" cols="38" rows="8" id="query"></textarea>
    


  • Registered Users Posts: 54 ✭✭Dean3y


    Webmonkey, I am so grateful! It works!
    I spent too long trying to figure that out!
    Many many thanks!
    Very obvious now! I really should be more careful!!


  • Registered Users Posts: 68,317 ✭✭✭✭seamus


    useful debugging tool for this kind of thing is the print_r statement. This dumps the contents of an array to the screen.

    For example,

    print_r($_POST);

    will print the contents of the $_POST variable to the screen so you can see exactly what's being sent. Very handy for catching typos and the like.


  • Advertisement
  • Registered Users Posts: 54 ✭✭Dean3y


    Excellent!!!!
    Thanks Seamus! Will def use that!


Advertisement