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 form - blank messages

  • 15-03-2011 11:49AM
    #1
    Registered Users, Registered Users 2 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, Registered Users 2 Posts: 68,173 ✭✭✭✭seamus


    Try using $_POST instead of $_REQUEST


  • Registered Users, Registered Users 2 Posts: 54 ✭✭Dean3y


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


  • Registered Users, Registered Users 2 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, Registered Users 2 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, Registered Users 2 Posts: 68,173 ✭✭✭✭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, Registered Users 2 Posts: 54 ✭✭Dean3y


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


Advertisement