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 5 of 5

Thread: Writing PHP

  1. #1
    Regular Coder
    Join Date
    Mar 2004
    Posts
    232
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Writing PHP

    I have php page that writes to a php page, except the variables aren't writing, is there something I need to do?

    Heres the php source:
    PHP Code:
     fputs($file, '<table class="post"><tr><td>');
        fputs($file, '<hr>'); 
        fputs($file, $_POST['Name']); fputs($file,'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;');
        fputs($file, $time);
        fputs($file, '<HR>'); 
        fputs($file, '<center>'); 
        fputs($file, $_POST['comments']); 
        fputs($file, '<br>');
        fputs($file, '<font color="CDCDCD" size=2>');
        fputs($file, $IP);
        fputs($file, '</font><hr><hr>'); 
        fputs($file, '</td></tr></table>');
        fputs($file, $newline);
        fputs($file, "<?php ");
        fputs($file, $newline);
        fputs($file, '$IPP = getenv (REMOTE_ADDR)');
        fputs($file, $newline);
        fputs($file, "
    if($IPP=='12.202.20.222' || $IPP=='213.235.131.26' || $IPP=='194.228.174.157'){ ");
        fputs($file, $newline);
        fputs($file, "
    <form action='gb.php' method='post'><input type='Submit' Name='delete$lines' Value='Delete Post Above'></form> }"); 
        fputs($file, $newline);
        fputs($file, "
    ?>");
    It writes back as a variable

  • #2
    Senior Coder
    Join Date
    Feb 2004
    Posts
    1,206
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Can you give us some sample output? Like what is happening, and what's not exactly?

    I don't like to copy+paste code and play around with it.. I'd prefer to have it all laid out in front of me before I consider trying to answer the question... but maybe that's just me..

    Sadiq.

  • #3
    Regular Coder
    Join Date
    Mar 2004
    Posts
    115
    Thanks
    0
    Thanked 0 Times in 0 Posts
    $var in ' ' eg '$var' should be taken as $var not its value

    you could also try escaping the $ with \ ie \$

    eg
    $IPP="test";
    echo"\$IPP"; should output $IPP

  • #4
    Senior Coder missing-score's Avatar
    Join Date
    Jan 2003
    Location
    UK
    Posts
    2,194
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Also, Im assuming you have, but I dont see that you have opened the file... If not look at http://www.php.net/fopen. To open the file you need the fopen function.

  • #5
    Regular Coder
    Join Date
    Mar 2004
    Posts
    232
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Yes it does have fopen. What it does is output a guestbook post. I just need to have a deleting part for the admin...


  •  

    Posting Permissions

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