Writing to File - Please Help
Posted: Sun Jun 06, 2010 9:15 pm
Hi Everyone,
For the past 2 days I've been struggling on writing a PHP script that takes info entered into a form that then gets posted to a seperate file. This is the form code:
As you can see the form asks for two pieces of info. This info is then posted to writer1.php - here's the code:
The above code then writes to another php file called inter.php - here's the code for that:
Now all of the above works, the problem being in the inter.php file, I can't get those two variables ($var1 and $var2) to work with anything else I put in that file. Echo statements won't work, nor will HTML work, if I put something into that file, the variable information dissapears or the echo/html statements (or whatever I'm trying to enter actually) just won't work. Basically I'd like to be able to use the take the outputs of $var1 and $var2 and put them wherever I want in the page. For example, I'd like to make a table containing the two variables, like this:
Which won't work, nor will something like this work:
Etc etc...........any ideas on what's wrong? Thanks in advance!
For the past 2 days I've been struggling on writing a PHP script that takes info entered into a form that then gets posted to a seperate file. This is the form code:
Code: Select all
<form id="Form" name="Form" method="post" action="writer1.php">
<input name="filename1" type="text" class="textfield" id="filename1" />
<input name="filedescription1" type="text" class="textfield" id="filedescription1" />Code: Select all
<?php
$filename1 = $_POST['filename1'];
$filedescription1 = $_POST['filedescription1'];
$my_file = "inter.php";
$fh = fopen($my_file, 'a') or die("can't open file");
$string_data1 = "$filename1";
$string_data2 = "$filedescription1";
fwrite($fh, $string_data1);
fwrite($fh, $string_data2);
echo "File successfully written";
?>Code: Select all
<?php
$var1 = html_entity_decode($string_data1);
$var2 = html_entity_decode($string_data2);
?>Code: Select all
<table align=center width=100%>
<tr><td>$var1</td><td>$var2</td></tr></table>Code: Select all
<?php
$var1;
echo "<br>";
$var2;
?>