Stripping Post Data to a Text File

Discussion in 'PHP' started by dopex, Jan 28, 2008.

  1. #1
    what I want to do is strip post data and write into a text file. I think I have a working script but its not working correctly.

    <?php
    if (isset($_POST['Data1']) && (isset($_POST['Data2']))) {
    $Data1 = trim(strip_tags($_POST['Data1']));
    $Data2 = trim(strip_tags($_POST['Data2']));
    
    $master = fopen('textfile.txt', 'a+', 1);
    $text="$Data1:$Data2:";
    fwrite($master, strip_tags(stripslashes($text)));
    fclose($master);
    echo'<script type="text/javascript">document.location.href=\'http://google.com'</script>\'">';
    
    }
    ?>
    PHP:
    and everytime i send something through the text file, it will strip the data1 and data2 information and write it on the next line, as so
    Data1:Data2
    Data1:Data2
    Data1:Data2
    and i also forgot to mention, the google is there because I want it to go to a website afterwards.
     
    dopex, Jan 28, 2008 IP
  2. lfhost

    lfhost Peon

    Messages:
    232
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #2
    change
    
    $text="$Data1:$Data2:";
    
    Code (markup):
    to

    
    $text="$Data1:$Data2:\n";
    
    Code (markup):
     
    lfhost, Jan 28, 2008 IP
  3. dopex

    dopex Peon

    Messages:
    15
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    i'm assuming that makes a new line?
    the whole code still doesn't work. not sure of the problem.
     
    dopex, Jan 28, 2008 IP
  4. dopex

    dopex Peon

    Messages:
    15
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    i'm also having another problem. when using the code
    php
    header("Location: http://www.google.com")
    it will go to there. what i need is for it is to go to a frame titled I1.
    using html it would be
    <a href="index.html" target="I1"> using the php header location or some header, how can I just make it go to index.html , confusing I know sorry.
    basically i have a website in a frame. and inside one of the pages is a form, whicfh you type something in and submit, the data is written into a text file, and afterward it redirects you to a webpage. i need a way to go to that new webpage, but inside the frame still. thank you.
     
    dopex, Jan 28, 2008 IP
  5. Kaizoku

    Kaizoku Well-Known Member

    Messages:
    1,261
    Likes Received:
    20
    Best Answers:
    1
    Trophy Points:
    105
    #5
    Use these parameters for fopen
    
    $master = fopen('textfile.txt', 'a');
    
    PHP:
    You are not reading it, why make it read and write?
     
    Kaizoku, Jan 28, 2008 IP