fwrite problem
Posted: Fri May 31, 2002 7:14 pm
im trying to write a code that generates form mail scripts, it is no where near finished, so dont talk about all the security risks it has, im just having a problem with the fwrite function:
at the part where it says
it gives me fwrite errors about bad filehandle resources, it writes the first entry, but nothing past it...any ideas?
Code: Select all
<html>
<head>
<title>Form mail - maker</title>
<style type="text/css">
<!--
input{
font-family:verdana;
font-size:10 px;
color:black;
border:1px solid black
}
td{
font-family:verdana;
font-size:10 px;
color:black;
}
-->
</style>
</head>
<body bgcolor="#9A9A9A" text="#FFFFFF">
<table cellpadding=0 cellspacing=0 height=100% width=100%>
<tr>
<td height=100% width=100% valign=top>
<?
if(!isset($doit)){
/* IF ITS UNSET */
if(!isset($pid)){
echo "Welcome to form mail maker, this wizard will make a form mail script customized to you<br />\n"
."<br />Please select the number of forms..<br />"
."<form action=$PHP_SELF method=GET>\n"
."<input type=text name=num><input type=hidden value=1 name=pid><br /><input type=submit value=Go></form>";
}
/* IF IT IS */
if(isset($pid)){
if($pid == "1"){
echo "<form action=$PHP_SELF method=GET>"
."Email that this form will be sent to: <input type=text name=to_email><br />\n"
."Filename of output: <input type=text name=filename><br />\n";
for($i = 1; $i <= $num; $i++){
echo $i."."." <input type=text name=_$i><br />\n";
}
echo "<input type=hidden name=num value=$num>\n<input type=hidden name=pid value=2>"
."<input type=submit value=Submit></form>";
} // END 1
/* SECOND STEP */
if($pid == "2"){
if($to_email != "" AND $filename != ""){
for($i = 1; $i <= $num; $i++){
$c_s = "_".$i;
if(${$c_s} == ""){
echo "Fill out field $i<br />\n";
} else {
$checkinputs = "1";
}
}
if(isset($checkinputs)){
$fp = fopen($filename, "w+");
for($i = 1; $i <= $num; $i++){
$c_s = "_".$i;
fwrite($fp, "${$c_s}"."\n");
fclose($fp);
}
}
} else {
echo "Put in your email AND check that you specified a filename";
}
} // END 2
} // END PID
?>
<?
// IF $DOIT ISNT SET
} else {
?>
<?
}
?>Code: Select all
if(isset($checkinputs)){
$fp = fopen($filename, "w+");
for($i = 1; $i <= $num; $i++){
$c_s = "_".$i;
fwrite($fp, "${$c_s}"."\n");
fclose($fp);
}
}it gives me fwrite errors about bad filehandle resources, it writes the first entry, but nothing past it...any ideas?