SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast
    Join Date
    Jan 2003
    Posts
    74
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How Can I Write This To A File?

    Hello. I used fwrite before, but I cannot remember how to
    write html code with javascript into a file

    Example code being:





    Code:
     
    <html>
    <body onLoad="document.forms['myForm'].submit()">
    <form name = "myForm" action="response.php" method="post">
    <input type="hidden" name="id" value="$id">
    
    <SCRIPT LANGUAGE="JavaScript"><!--
    document.myForm.submit;
    //--></SCRIPT>
    </html>
    How do I write that to a file, because I want the file I write to to be able to function with this code. Why? Because I will always be re-writing it dynamically with a variable based on user input. You see value=$id I want that, if it is 4, to turn into value=4

    See what I mean? Including the rest of the code. How can I do this without string errors?

  2. #2
    SitePoint Wizard silver trophy someonewhois's Avatar
    Join Date
    Jan 2002
    Location
    Canada
    Posts
    6,364
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    http://php.net/fwrite

    PHP Code:
    $file fopen("file.php""w");
    fwrite("Blahblah"$file);
    fclose($file); 

  3. #3
    ********* Genius Mike's Avatar
    Join Date
    Apr 2001
    Location
    Canada
    Posts
    5,458
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    <?php

    $data 
    =<<<DATA
    <html>
    <body onLoad="document.forms['myForm'].submit()">
    <form name = "myForm" action="response.php" method="post">
    <input type="hidden" name="id" value="
    {$id}">

    <SCRIPT LANGUAGE="JavaScript"><!--
    document.myForm.submit;
    //--></SCRIPT>
    </html>
    DATA;

    $file fopen("file-to-be-written-to.php""w" ); 
    fwrite($data$file); 
    fclose($file); 

    ?>
    Mike
    It's not who I am underneath, but what I do that defines me.


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
  •