Code: Select all
tags when posting PHP code. Read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]
Hi, I'm having a total mental block, I need the code below to fail if the 'images' field of my form is not filed in, but under all other circumstances write to my text file.
At the moment, the error displays under all circumstances and nothing writes to the file.
I'm sure it's a simple fix....
anyoneCode: Select all
<?
$done = true;
$fp = fopen('news.txt','a');
if (!$fp) {
echo "Sorry could'n open file!<br>";
}
else {
if(!(isset($_POST[Images]) && $_POST[Images] != "")) {
print("please add image link.\n\n");
$done= false;
}
else {
echo "go back and add image";
}
if($done == true) {
$fp = fopen('news.txt','a');
$line = date("d.m.y") . "¬" . $HTTP_POST_VARS['name'] . "¬".$HTTP_POST_VARS["email"] . "¬".trim
($HTTP_POST_VARS["subject"]). "¬".$HTTP_POST_VARS["images"]. "¬".$HTTP_POST_VARS["url"];
$line .= "¬" . $HTTP_POST_VARS['news'];
$line = str_replace("\r\n","<BR></BR>",$line);
$line = str_replace(" < "," LESS THAN ",$line);
$line = str_replace(" > "," GREATER THAN ",$line);
$line = str_replace(" >= "," GREATER THAN OR EQUAL TO ",$line);
$line = str_replace(" <= "," LESS THAN OR EQUAL TO ",$line);
$line = str_replace(" & "," and ",$line);
$line = str_replace("&","and",$line);
$line = stripslashes($line);
$line .= "\r\n";
fwrite($fp, $line);
}
}
if(!fclose($fp))
?>