SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Member
    Join Date
    Jul 2008
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How to remove backslashes in mail()

    i know you are suppose to use stripslashes but I cannot figure out where to put this function for it to work.
    Here is my code:

    <?php

    $name = $_REQUEST['name'] ;
    $email = $_REQUEST['email'] ;
    $fields = array();
    $fields{"name"} = "Name";
    $fields{"email"} = "email";
    $fields{"comments"} = "comments";
    $body = "We have received the following information:\n\n";
    foreach($fields as $a => $b){
    $body .= sprintf("%20s: %s\n",$b,$_REQUEST[$a]); }

    mail( "mysite'dot'com", "Tournament Register Form",
    "$body", "From: $email");
    header( "Location: 'dot'mysite'dot'com" );
    ?>



    Any help would be great. Thanks

  2. #2
    Theoretical Physics Student bronze trophy Jake Arkinstall's Avatar
    Join Date
    May 2006
    Location
    Lancaster University, UK
    Posts
    7,062
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    $body stripslashes($body); 
    Just before mail().

    But you really shouldn't have magic_quotes on in php.ini, unless you are a beginner.
    Jake Arkinstall
    "Sometimes you don't need to reinvent the wheel;
    Sometimes its enough to make that wheel more rounded"-Molona

  3. #3
    SitePoint Member
    Join Date
    Jul 2008
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Great thanks. It works properly now.
    Yes I am a beginner. I would take it off but I am unsure of what kinda issues I could have if I did.

  4. #4
    Theoretical Physics Student bronze trophy Jake Arkinstall's Avatar
    Join Date
    May 2006
    Location
    Lancaster University, UK
    Posts
    7,062
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Well, basically magic_quotes automatically adds slashes to certain characters in content so that beginners who don't know how to escape data don't get hacked.

    But it allows people to over-use it and, therefore, permits unstable applications, and causes issues with displaying and emailing etc.

    So if you have it off, you escape variables which go into queries with mysql_real_escape_string(), which makes you safe from hackers.
    Jake Arkinstall
    "Sometimes you don't need to reinvent the wheel;
    Sometimes its enough to make that wheel more rounded"-Molona


Bookmarks

Posting Permissions

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