Click to See Complete Forum and Search --> : php script help
ckarnuth
06-02-2006, 10:54 AM
I am trying to configure a php script that will allow me to write to a networked server that will allow users to request that webpages be unblocked. I have the general page already developed however, when i try to write to the text document that i want, all it does is display the document. Any help?
Li0rE
06-02-2006, 11:26 AM
could you post the script so we could see what is wrong.
ckarnuth
06-02-2006, 10:00 PM
<html>
<body bgcolor="#ff9900">
<center><h3><u>Add this site for evaluation!!!</h3></u></center>
<font color="#ffffff">
ISA 2004 has been implemented at the National Institute of Technology. It's purpose is not
only to protect the school network from harmful internet exposures, but also to help maintain
student productivity. You will notice that several of the popular sites that have no educational
benefit have been restricted, this is in addition to thousands of pornographic and advertisement based sites.
Many game sites have been blocked as well. I have done the best that I can to assure that all appropriate sites
have not been excluded, but our department is only able to think of so many sites. I am offering everyone the
ability to offer their input as to sites that they believe should, or should not, be blocked. Please feel
free to use the script included on the blockin page, by clicking the link and entering the web address in the pop up box, or if trouble is experienced with the link, please feel free to note the sites below and pass on to your lab instructor. The lab instructors will place these in on of the network administration members' mailbox for review. Your understanding and patience is greately appreciated, MIS Department.
</font>
<br><Br>
<FORM ACTION="websiteadd.php" method=post>
<table border=0>
<tr>
<td width=200>Website to unblock:<br>
<td align="center"><input type="text" name="website to add" size="100" maxlength="100"></td>
</tr>
<tr>
<td colspan="2" align="center"><br>
<input type="submit" value="Submit to Network Admin"></td>
</tr>
</table>
</form>
</body>
</html>
From there it shows the following page.
<html>
<body bgcolor="#ff9900">
<br><Br>
<p> </p>
<center>
<p>Thank you!</p>
<p>Your request has been submitted to a Network Admin.</p>
The directory of the text document that i need it to post to is:
\\server001.pepsi.com\websites\text.txt
I tried to use the echo statement to place the name of the website on the "thank you" page, however couldn't get that to work either.
To write to the text file I tried to use:
<?php
$myfilepointer = fopen("myfilename.txt", "w");
?>
with "myfilename.txt" changed to the full directory, and still couldn't get it to work.
Li0rE
06-03-2006, 06:34 AM
All you did right there was defined a variable with the name of the file.
It is kind of stupid to want to write it to a text file. What you should do is make it go to an email address. Not only will it be simpler, it would be better, because you would have to open the text file and manually delete line, etc. every time.
ckarnuth
06-03-2006, 07:13 AM
The system admin doesn't want it emailed to him, but he wants it added to the text file, I thought of the email first. The reason for no email is there are more then 1 system admin that can change the settings. therefore, he wants it written to a text file. Can you help ?
Li0rE
06-03-2006, 08:02 AM
<?php
$somcontent = "Website:".$_POST['website']." \n ----------------- \n";
$myfilepointer = fopen("myfilename.txt", "a");
if (fwrite($myfilepointer, $somecontent) === FALSE) {
echo "Cannot write to file. Change permissions to writable or make sure it exists."; exit; }
?>
That's it, change your variable name for website from website to add to website.