SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast
    Join Date
    Jul 2001
    Location
    Tucson, AZ
    Posts
    80
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    problem with slashes

    i type i'm and it comes out i'/m anything with ' has the slash... what can i do about that?


    heres the code thats called from the form on another page. this is the code that saves the file.

    PHP Code:
    <?php 
    $PostPage 
    "post.php";
    $gbPage "index.php";

    if ((
    $name == "") AND ($email == "") AND ($comments == "")):

        
    $error1 "<font size='3' class='s4' color='red' face='Arial, Helvetica'><STRONG>It appears as if you've tried to submit a blank form:</STRONG></font><br>";
        
        echo 
    $error1;
        include(
    $PostPage);

    else:


    $gbFile "messages.txt"// Location of link database file
    $gbPage "index.php";  // Link page file


    $notify 0// Would you like to be notified when a link is added? 1 = yes, 0 = No
    $my_email "you@youremailaddress.com"// Enter your email address
    $subject "New Guestbook Entry" // Enter the subject of the notification email



    /*
    Code Follows Below
    */

        
    $page $gbFile;

    $filename "messages.txt";
    $fd fopen$filename"r" );
    $current fread$fdfilesize$filename ) );
    fclose$fd );

    $comments ereg_replace("\n","<BR>",$comments);



    $fileMessage = ("<div align=\"center\"><table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\">");
    $fileMessage .= ("<tr> <td class=\"text\" bgcolor=\"#000099\">");
    $fileMessage .= ("<table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\">");
    $fileMessage .= ("<tr><td class=\"text\" align=\"left\"><b>Posted by: </b><a href=\"mailto:$email\">$name</font></a></font></td>");
    $fileMessage .= ("<td class=\"text\" align=\"right\">");
    $fileMessage .= (date("l, F dS  Y h:i A"));
    $fileMessage .= ("</font></td></tr></table></td></tr><tr><td class=\"text\">$comments</td></tr></table></div>");

    $fileMessage .= "$current";

    if (
    file_exists("$page")):
        
    $cartFile fopen("$page","w+");
        
    fputs($cartFile,$fileMessage);
        
    fclose($cartFile);
    else:
        
    $cartFile fopen("$page","w");
        
    fputs($cartFile,$fileMessage);
        
    fclose($cartFile);
    endif;

    // EMAIL THE NEW POST

    if ($notify == 1):

    $comments ereg_replace("<BR>","\n",$comments);

    mail
    (
    "$my_email",
    "Example Issues List Entry",
    "Name : $name
    Email : 
    $email
    Note:

    $comments\n
    "
    ,
    "From: $email\n"
    );
    endif;

    //set vars for help checking against double entries

    $name_chk $name;
    $email_chk $email;
    $comments_chk $comments;



    include(
    $gbPage);


    //endif from very top where checking if form is empty
    endif;
    ?>

  2. #2
    SitePoint Enthusiast
    Join Date
    Jul 2001
    Location
    Tucson, AZ
    Posts
    80
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I forgot to mention this was originally a guestbook that I made into a news script. It still had the same problem when it was a guestbook.

  3. #3
    SitePoint Zealot theFinn's Avatar
    Join Date
    Oct 2000
    Location
    Edmonton
    Posts
    102
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The Problem: You must likely have PHP configured with magic_quotes_gpc turned on. This will automatically add slashes to any data passed by Get, Post, or Cookie.

    The Solutions:

    1) Turn magic_quotes_gpc off in php.ini

    2) Run stripslashes() on the data befor you write it to the file.

    eg:
    PHP Code:
    $name stripslashes($name);
    $email stripslashes($email);
    $comments stripslashes($comments); 
    - theFinn
    Creator and Project Manager, phpBB
    http://www.theFinn.net
    http://www.tarotclass.com


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
  •