Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    New Coder
    Join Date
    Jun 2003
    Location
    Melbourne, Australia
    Posts
    32
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Why wont this bloody form work???

    It should be straight forward - i have other files almost identical that work fine... have i missed something?

    (i've removed javascript form validators as its not necessary to show them here to solve the problem. it doesnt work without them eitheir)

    Any suggestions would be massively appreciated. i suspect its something so small i cant see it, but its driving me bananas.

    thanks



    File1:

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>
    <title>Contact Us</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

    <link href="style.css" rel="stylesheet" type="text/css">
    </head>

    <body>
    <p>Contact us to find out about upcoming events, to join our mailing list, to
    contribute photos or other material, or for anything else that tickles your
    fancy...</p>

    <table>
    <!-- Table 4 -->
    <FORM ACTION="contactus_2.php" METHOD="post">
    <TR>
    <TD WIDTH='100%' class="contactheader">Name<BR>
    <INPUT TYPE="text" NAME="name" SIZE="30" class="inputbox" VALUE="">
    </TD>
    </TR>
    <TR>
    <TD WIDTH='100%' class="contactheader">Email<BR>
    <INPUT NAME='email' TYPE='text' class="inputbox" onBlur="MM_validateForm('from','','NisEmail');return document.MM_returnValue" VALUE='' SIZE='30'>
    </TD>
    </TR>
    <TR>
    <TD WIDTH='100%' class="contactheader">Message</TD>
    </TR>
    <TR>
    <TD valign='top'>
    <TEXTAREA COLS='45' ROWS='8' NAME='message' class="inputbox" wrap="VIRTUAL"></TEXTAREA>
    </TD>
    </TR>
    <tr>
    <TD valign='top' class="contactheader">Would you like to join our mailing list, to be notified of upcoming events?</TD>
    </tr>
    <TR>
    <TD align="left" class="contactheader">
    Yes <input name="maillist" type="radio" value="Yes" checked> No <input name="maillist" type="radio" value="No">
    </TD>
    </TR>
    <TR>
    <TD HEIGHT='20' VALIGN='bottom' align="left">
    <br>
    <INPUT NAME="send" VALUE="Send" TYPE="submit" class="button" onClick="validate()">
    </TD>
    </TR>

    </form>
    </TABLE>
    </body>
    </html>


    FILE2 (contactus_2.php):

    <?

    Function GetMsgInfo()
    {
    $Name = $HTTP_POST_VARS["name"] ;
    $Email = $HTTP_POST_VARS["email"] ;
    $Message = $HTTP_POST_VARS["message"] ;
    $MailList = $HTTP_POST_VARS["maillist"] ;
    }

    Function MailMsgInfo()
    {
    global $Name ;
    global $Email;
    global $Message;
    global $MailList ;

    $Text= "Name: " .$Name ."\n" ."E-Mail: " .$Email ."\n \n" ."Message: " .stripslashes($text) ."\n \n" ."Mail List: " .$maillist ;
    $From= $Name . "<" . $Email . ">";
    mail("webmessage@berlinit.com", "Sutter Cain Webmail Message", $Text, "From:" .$From );
    }

    Function DisplayMsgInfo()
    {
    global $Name ;
    global $Email;
    global $Message;
    global $MailList ;

    ?>
    <table>
    <tr>
    <td colspan="2" align="left">
    <p><strong>The following details have been emailed to the Sutter Cain Crew:</strong></p>
    <p><strong>Name: </strong><? echo $Name ; ?> <br>
    <strong>Email: </strong><? print $Email ; ?> <br><br>
    <strong>Message: </strong><? print $Message ; ?> <br><br>
    <strong>Mailing List Subscription: </strong><? print $MailList ; ?> <br><br>
    </p>

    <p><strong>Thank you for getting in touch. We appreciate your feedback.</strong> <br><br></p>
    <p align="center"><a href="nextevent.html">[ Home ]</a></p>
    </td>
    </tr>
    </table>
    <? } ?>


    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>
    <title>Contact Us 2</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

    <link href="style.css" rel="stylesheet" type="text/css">
    </head>

    <body>

    <? GetMsgInfo() ;
    //MailMsgInfo() ;
    DisplayMsgInfo() ;?>


    </body>
    </html>
    Berlin IT Services
    - Website Design & Development
    - Content Management Systems

    Located: Melbourne, Australia

  • #2
    Senior Coder
    Join Date
    Jun 2002
    Location
    frankfurt, german banana republic
    Posts
    1,848
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Why wont this bloody form work???

    Originally posted by BerlinIT
    It should be straight forward - i have other files almost identical that work fine... have i missed something?
    Yes, you did. The description of the error or problem, and the expected behaviour of your code and what it did instead. Does it throw any errors? Does the mail not get send? Do some variables not have the right value? Does the server burst into flames?
    De gustibus non est disputandum.

  • #3
    Supreme Overlord Spookster's Avatar
    Join Date
    May 2002
    Location
    Marion, IA USA
    Posts
    6,278
    Thanks
    4
    Thanked 83 Times in 82 Posts
    And also why is your form bloody? Did you cut your finger and bleed on it?
    Spookster
    CodingForums Supreme Overlord
    All Hail Spookster

  • #4
    Senior Coder missing-score's Avatar
    Join Date
    Jan 2003
    Location
    UK
    Posts
    2,194
    Thanks
    0
    Thanked 0 Times in 0 Posts
    lol @ spookster.


    $Name ;
    $Email;
    $Message;
    $MailList ;


    correct me if i am wrong, but i dont see anywhere these vars are being used outside of functions... They are defined in a function, and are neither returned or made global...

    so when you do this:

    global $Name ;
    global $Email;
    global $Message;
    global $MailList ;

    it is not finding anything... If you define these variables outside of functions, you should be ok.

  • #5
    New Coder
    Join Date
    Jun 2003
    Location
    Melbourne, Australia
    Posts
    32
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Re: Why wont this bloody form work???

    Originally posted by mordred
    Yes, you did. The description of the error or problem, and the expected behaviour of your code and what it did instead. Does it throw any errors? Does the mail not get send? Do some variables not have the right value? Does the server burst into flames?
    Oops, sorry.. i'm a goose.

    Basically, the form is not passing the information to the variables in the contactus_2.php file. So whe i go to display the results, no form data is shown.
    Berlin IT Services
    - Website Design & Development
    - Content Management Systems

    Located: Melbourne, Australia

  • #6
    New Coder
    Join Date
    Jun 2003
    Location
    Melbourne, Australia
    Posts
    32
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Originally posted by missing-score
    correct me if i am wrong, but i dont see anywhere these vars are being used outside of functions... They are defined in a function, and are neither returned or made global...

    so when you do this:

    global $Name ;
    global $Email;
    global $Message;
    global $MailList ;

    it is not finding anything... If you define these variables outside of functions, you should be ok.
    No, you're absolutely right. Putting everything outside of the functions actually works (! Why ddint i think of trying this??).. thanks for that missing-score.

    So how come, if i put the table display inside the same function that gets the form data and writes them to variables, and then call that function from the body part at the bottom, ti doesnt work?? Theoretically its just 1 function being called so no globals required (is this assumption correct?). ie:

    <?

    Function GetMsgInfo()
    {
    $Name = $HTTP_POST_VARS["name"] ;
    $Email = $HTTP_POST_VARS["email"] ;
    $Message = $HTTP_POST_VARS["message"] ;
    $MailList = $HTTP_POST_VARS["maillist"] ;
    ?>

    <table>
    <tr>
    <td colspan="2" align="left">
    <p><strong>The following details have been emailed to the Sutter Cain Crew:</strong></p>
    <p><strong>Name: </strong><? echo $Name ; ?> <br>
    <strong>Email: </strong><? print $Email ; ?> <br><br>
    <strong>Message: </strong><? print $Message ; ?> <br><br>
    <strong>Mailing List Subscription: </strong><? print $MailList ; ?> <br><br>
    </p>

    <p><strong>Thank you for getting in touch. We appreciate your feedback.</strong> <br><br></p>
    <p align="center"><a href="nextevent.html">[ Home ]</a></p>
    </td>
    </tr>
    </table>

    <? } ?>


    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>
    <title>Contact Us 2</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

    <link href="style.css" rel="stylesheet" type="text/css">
    </head>

    <body>

    <? GetMsgInfo() ; ?>

    </body>
    </html>
    Berlin IT Services
    - Website Design & Development
    - Content Management Systems

    Located: Melbourne, Australia

  • #7
    Senior Coder
    Join Date
    Jun 2002
    Location
    frankfurt, german banana republic
    Posts
    1,848
    Thanks
    0
    Thanked 0 Times in 0 Posts
    In your function GetMsgInfo(), you use the variable $HTTP_POST_VARS, but it's nowhere defined in that function, so you need to explicitly import that variable by using

    Function GetMsgInfo()
    {
    global $HTTP_POST_VARS;
    $Name = $HTTP_POST_VARS["name"] ;
    [...]

    To confuse matters, exactly for this little nuissance the superglobal $_POST has been introduced in PHP 4.1. With that in mind you could've omitted importing the post variables array into the function's scope.

    Function GetMsgInfo()
    {
    $Name = $_POST["name"] ;
    [...]

    Note that only the prefined arrays like $_GET, $_POST etc. exhibit this particular behaviour - other variables still need to be imported from the global scope.

    BTW, I'd say it's common convention to write the function keyword in lowercase, but that's just a cosmetic nitpick.
    De gustibus non est disputandum.


  •  

    Posting Permissions

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