Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 9 of 9
  1. #1
    Senior Member splufdaddy's Avatar
    Join Date
    Feb 2003
    Location
    Boston, MA
    Posts
    4,488
    Member #
    735
    I know very little about PHP, which is why I'm taking a class on it next semester (so expect a lot more stupid questions in the coming months). In the meantime, I have a problem.

    I made a feedback form for a client, and it worked fine on their old host. They changed hosts, and the whole site needed to be tweaked on this new host. One thing that needed to be changed was every extension had to be changed to php4. Easily done. Now, this feedback form is not passing the information from the first page to the second. It sends the email without the info the user entered. Here's what I have in the head of the submit page. Any thoughts?
    PHP Code:
    <?php
    $bundle
    ="Here is the name: " $testtext;
    mail("my@emailaddress.com""form test"$bundle);
    ?>
    This may be an ancient way of doing this, I found a tutorial on it a while ago, and I have been using it since. Never caused me a problem til now. I bundle it because in the actual form there are over 20 fields.

  2.  

  3. #2
    Senior Member filburt1's Avatar
    Join Date
    Jul 2002
    Location
    Maryland, US
    Posts
    11,774
    Member #
    3
    Liked
    21 times
    If $testtext was a form variable on the past page, use $_POST['testtext'] (or $_GET).
    filburt1, Web Design Forums.net founder
    Site of the Month contest: submit your site or vote for the winner!

  4. #3
    Senior Member rosland's Avatar
    Join Date
    Jul 2003
    Location
    Norway
    Posts
    1,944
    Member #
    2096
    Filburt has most probably identified the problem.
    Not to repeat filburt's answer, but to elaborate a little, the global scope was altered from PHP v.4.2.0. Prior to that release, the "register_globals" directive was set to default "on" (in the php.ini file). As PHP doesn't require variable initialization, this made it easy for crackers to manipulate script values, as all variables had a global scope once they were set. Big security issue!

    You can leave your script as is if you want to, just set $testtext=$_POST['testtext']; or $_GET['testtext'] above the actual function call where the variable is needed.

    However, that's not the reason I posted this. I thought I could give you an example of how to add a fourth argument to the mail() function to enable it to send HTML formatted text, and to include senders mailadress (will show senders email in the "From" section of the incoming email).

    The 3 mandatory arguments to the mail function are to, subject, messagebody, the fourth will be headers. If you add an email adress text field in your form, and name it "from", you could alter your script to this:
    PHP Code:
    <?php
    $to
    ="your@destination.adress";
    $sub="default subjectname";
    $txt=$bulk;

    $headers  "MIME-Version: 1.0\r\n";
    $headers .= "Content-type: text/html; ";
    $headers .= "charset=iso-8859-1\r\n";
    $headers .= "read this header note below";
    $headers .= "Cc: $some_cc_recieveremail \r\n"#optional of course

    mail($to$sub$txt$headers);
    ?>
    (The "read this header note below" should be replaced with "From colon $name". Colon should be replaced with the symbol ":"
    For some reason, vBulletin alters this to "Wrom: LJHYFKFKL" if I try to print as it's supposed to be!)

    The "\r\n" means respectively "carriage return" and "newline". Different header values must be seperated this way.

    Don't know if you'll find this useful.
    S. Rosland

  5. #4
    JR
    JR is offline
    Senior Member JR's Avatar
    Join Date
    Nov 2002
    Location
    UK
    Posts
    4,354
    Member #
    257
    Tip: Put a space between \r\n (\r \n) or the headers won't work properly in Outlook.
    JR

  6. #5
    Senior Member splufdaddy's Avatar
    Join Date
    Feb 2003
    Location
    Boston, MA
    Posts
    4,488
    Member #
    735
    Thanks to all of you. Filburt identified the problem, and I used Rosland and JR's post too when redoing the page. Don't go to far, there will be plenty more questions to come.

  7. #6
    Senior Member splufdaddy's Avatar
    Join Date
    Feb 2003
    Location
    Boston, MA
    Posts
    4,488
    Member #
    735
    OK, dragging this thread up again:

    The form is set up and it works fine, with one exception. The company I did this for has some sort of filtering software by Symantec that's bouncing this out. The software is on a server seperate from their email server and their virus scanner, and I'm not completely sure what it does, but it refuses the email because of "improper line terminators" in the header. They are looking into creating a rule to allow only these emails through, and I'm trying to figure out how to rewrite the headers so they will still customize the from address and display HTML format without being rejected. Here are the exact headers I have:
    PHP Code:
    $headers "MIME-Version: 1.0\r \n";
    $headers .= "Content-Type: text/html;";
    $headers .= "charset=iso-8859-1\r \n";
    $headers .= "From:thanks@theirdomain.com"
    Any ideas?

  8. #7
    Senior Member filburt1's Avatar
    Join Date
    Jul 2002
    Location
    Maryland, US
    Posts
    11,774
    Member #
    3
    Liked
    21 times
    Don't include a space between the \r and the \n.
    filburt1, Web Design Forums.net founder
    Site of the Month contest: submit your site or vote for the winner!

  9. #8
    Senior Member splufdaddy's Avatar
    Join Date
    Feb 2003
    Location
    Boston, MA
    Posts
    4,488
    Member #
    735
    The space between the r and the n is still there and not causing an issue, but the lack of a space before the \r was. I put a space before the \r and now they recieve it.

  10. #9
    Member bwedekin's Avatar
    Join Date
    Feb 2004
    Location
    The Midwest
    Posts
    33
    Member #
    4819
    PHP Code:
    if ($submit) {
    $subject "$fromText has sent you an email";
    $message "Blah Blah Bah....
                        
    Thanks, 
    $fromText";
                        
    mail("$toEmail"$subject$message
    "From: $fromText <$fromEmail>\r\n" 
    ."X-Mailer: PHP 4.x");

    In a FORM, submit it to $PHP_SELF and have input tags with:

    fromText = senders name
    fromEmail = senders email address
    toEmail = address being sent to...

    Everything else you can assign above the mail() function.


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 04:25 PM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com