Email handler problem

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Danny Smith

    Email handler problem

    Hi folks,

    I'm having problems with my PHP form handler. It used to work correctly, but
    now for some reason its not. I'm hoping someone here could take a look and
    tell me where I might have gone wrong.

    Just for background info, when I click submit the form sends okay, but when
    the email arrives in my inbox the $name value is non-existent - like nothing
    had been entered in the box on the web page form.

    Also, I'm not sure if this is relevant: The server uses PHP version 4.4.4


    The form handler: (scripts/ct_em.php)

    <?
    $email = $_REQUEST['email'] ;
    $message = $_REQUEST['message'] ;

    mail( "ME@MYDOMAIN.CO M", "SUBJECT OF THE EMAIL",
    "NAME: $name \n\n
    EMAIL ADDRESS: $email \n\n
    MESSAGE FOLLOWS BELOW: \n
    $message",
    "From: $email" );
    header( "Location: THANK-YOU PAGE" );
    ?>


    The form: (03_contact.htm l) - it should be noted that I've got a Javascript
    validation script that checks the length of the value of the email address
    field to ensure that it's not left blank - it's had no impact on the form
    working or not working - when the form did work this Javascript was always
    present.

    <form enctype="multip art/form-data" method="post" action="scripts/ct_em.php"
    name="form1">

    <table width=288 cellpadding=0 cellspacing=0>
    <tr valign=center>
    <td class="body_mid " width=288>Name: <br><input name="name"
    style="font-size: 12px; width: 288px; height: 19px;"></td>
    </tr>
    <tr valign=center>
    <td width=288 height=5></td>
    </tr>
    <tr valign=center>
    <td class="body_mid " width=288>Email address:<br><in put name="email"
    style="font-size: 12px; width: 288px; height: 19px;"></td>
    </tr>
    <tr valign=center>
    <td width=288 height=5></td>
    </tr>
    <tr valign=top>
    <td class="body_mid " width=288>Your message:<br><te xtarea name="message"
    style="font-family: Arial; font-size: 12px; width: 288px; height:
    50px;"></textarea></td>
    </tr>
    <tr valign=center>
    <td width=288 height=10></td>
    </tr>
    <tr valign=center>
    <td width=288><a href="javascrip t:document.form 1.submit()"
    OnMouseOver="se .src='images/bu_se_lt.gif'"
    OnMouseOut="se. src='images/bu_se_dk.gif'" onClick="return validate();"><i mg
    name="se" id="se" src="images/bu_se_dk.gif" alt="Send" border="0"></a></td>
    </tr>
    </table>

    </form>

    Thanks for your time folks!

    Regards,

    Danny.


  • Fabian Fuchs

    #2
    Re: Email handler problem

    Am Mon, 20 Nov 2006 21:59:18 GMT schrieb Danny Smith:
    <?
    $email = $_REQUEST['email'] ;
    $message = $_REQUEST['message'] ;
    >
    mail( "ME@MYDOMAIN.CO M", "SUBJECT OF THE EMAIL",
    "NAME: $name \n\n
    Just try to set your $name variable before you use it :)
    $name = $_REQUEST['name'] ;

    Best Regards,
    Fabian Fuchs

    Comment

    • Pedro Graca

      #3
      Re: Email handler problem

      Danny Smith wrote:
      ... It used to work correctly ...
      register_global s
      PHP is a popular general-purpose scripting language that powers everything from your blog to the most popular websites in the world.


      Add these two lines at the very top of your script, right after the
      first <?php tag

      error_reporting (E_ALL);
      ini_set('displa y_errors', '1');

      With this configuration, PHP will let you know when you try to use an
      inexistent variable.

      --
      I (almost) never check the dodgeit address.
      If you *really* need to mail me, use the address in the Reply-To
      header with a message in *plain* *text* *without* *attachments*.

      Comment

      Working...