Writing to a file with posted variable name--HELP
Posted: Tue Oct 14, 2008 9:58 am
Hi, I'm new at PHP development (and programming in general) but have had to learn it for a college project. So hopefully this code doesn't look too dumb.
A Java program is sending me variables through the post method. Here is my code:
<html>
<?php
$ClockNum = $_POST['clock_registration'];
settype($ClockNum, "string");
$Time = $_POST['time'];
$ampm1 = $_POST['ampm1'];
$Alarm = $_POST['alarm'];
$ampm2 = $_POST['ampm2'];
$fh = fopen($ClockNum, 'w');
fwrite($fh, $ClockNum);
fwrite($fh, $Time);
fwrite($fh, $ampm1);
fwrite($fh, $Alarm);
fwrite($fh, $ampm2);
fclose($fh);
?>
</html>
I thought I needed to convert the variable to a string, but even this doesn't help. It wasn't working before of after I tried inserting that line. The permissions settings are all fine, including the files to which the program writes. Any ideas??? I need help...fast.
Also, I know my code is very sloppy. What is the proper way to combine all of the fwrite lines? And do I need the html tags at all? (I also tried with those removed, just in case.)
A Java program is sending me variables through the post method. Here is my code:
<html>
<?php
$ClockNum = $_POST['clock_registration'];
settype($ClockNum, "string");
$Time = $_POST['time'];
$ampm1 = $_POST['ampm1'];
$Alarm = $_POST['alarm'];
$ampm2 = $_POST['ampm2'];
$fh = fopen($ClockNum, 'w');
fwrite($fh, $ClockNum);
fwrite($fh, $Time);
fwrite($fh, $ampm1);
fwrite($fh, $Alarm);
fwrite($fh, $ampm2);
fclose($fh);
?>
</html>
I thought I needed to convert the variable to a string, but even this doesn't help. It wasn't working before of after I tried inserting that line. The permissions settings are all fine, including the files to which the program writes. Any ideas??? I need help...fast.
Also, I know my code is very sloppy. What is the proper way to combine all of the fwrite lines? And do I need the html tags at all? (I also tried with those removed, just in case.)