hey there ,i've got a question about the fwrite function there's an html code , i want to write <html> <head> <form action="edit_content.php" method="post"> <title><h2>delete content</h2></title> <h1>choose content to delete</h1> <select> I WANT TO FWRITE TO WRITE HERE <input type="submit" value="submit" name="submit"> </select> </form> </head> </html> is it possible? how ?
Here's how you do it: <html> <head> <form action="edit_content.php" method="post"> <title><h2>delete content</h2></title> <h1>choose content to delete</h1> <select> <?php // *** insert your fwrite function here *** ?> <input type="submit" value="submit" name="submit"> </select> </form> </head> </html>
you gotta be kidding there's one more .php file instead of this html file in the php file there's a fwrite function whice writes into the html file i want it to write into a specific place in the html file
Open the html file with fread, parse it, insert the code you want then use fwrite to overwrite the original file with the new code.
Ok, so you've got a function that writes data into a .html file, right? Let's say you've got: $string = "This data goes in the HTML file at a specific point."; PHP: And you've got: $html = "<html> ... Your HTML page ... </html>"; $handle = fopen("my.html", "w+"); fwrite($handle, $html); fclose($handle); PHP: What you want to do is this: <html> <head> <form action="edit_content.php" method="post"> <title><h2>delete content</h2></title> <h1>choose content to delete</h1> <select> <!-- I WANT TO FWRITE TO WRITE HERE --> {MY_FWRITE} <input type="submit" value="submit" name="submit"> </select> </form> </head> </html> HTML: $html = "<html> ... Your HTML page ... </html>"; $html = str_replace("{MY_FWRITE}", $string, $html); $handle = fopen("my.html", "w+"); fwrite($handle, $html); fclose($handle); PHP: