Help - Fclose PHP
Posted: Fri Feb 01, 2013 8:24 am
Good afternoon friends.
I'm brand new to PHP and need a lot of help from you. I have a form code that sends a file to the server. On the form I set the file name and the variables that are called from the form. Everything is working pretty one.
What I need is the following, in the current form I define it the name of the page that goes to the server. I would like to send the same form more than one page to the server, but the function fclose'm not getting. Am I doing something wrong?
I'll put the code below formail.php and comment where I need help. In the sequel will put the HTML form's need for a new field to compose a new page if you want to insert.
Let codes:
formail.php
NOW BELOW THE CODE OF HTML FORM:
I'm brand new to PHP and need a lot of help from you. I have a form code that sends a file to the server. On the form I set the file name and the variables that are called from the form. Everything is working pretty one.
What I need is the following, in the current form I define it the name of the page that goes to the server. I would like to send the same form more than one page to the server, but the function fclose'm not getting. Am I doing something wrong?
I'll put the code below formail.php and comment where I need help. In the sequel will put the HTML form's need for a new field to compose a new page if you want to insert.
Let codes:
formail.php
Code: Select all
<html>
<?php require "config.ini"; ?>
<?php
ini_set ("SMTP","smtp.eb.mil.br");
$nome=$_POST["nome"];
$title=$_POST["title"];
$pagina=$_POST["pagina"];
$mensagemHTML = ' <html>
<head>
<title>'.$nome.',: '.$title.','.$nome.'</title><br>
</head>
<body> </body>
<html>';
// Verifica se O Campo nome táreenchido
if (empty($nome)){
// HTML que aparecera o ERRO
echo "<html><head><title>Ocorreu Um ERRO !!!</title></head>";
echo "<body bgcolor=\"#ffffff\">
</body></html>";
}
else{
// Comfirma o Envio Do E-mail
if ($certo== "1")
{
// Funç de envio Do E-mail
//mail ("meuemail@meuservidor.com.br ","nome","string message", "string additional_headers");
mail ("$emaildest","$assunto","Nome:$nome\n Email:$email\n Mensagem:$mensagem\n IP:$REMOTE_ADDR\n\n ...::: Coloque seu nome aqui ou o nome da empresa ® :::...","From:$nome<$email>");
}
// HTML do redirecionameto e se nãredirecionar aparece um link
echo "<html><head>";
}
?>
</div>
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_reloadPage(init) { //reloads the window if Nav4 resized
if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);
//-->
</script>
// BELOW ARE THE LINES THAT SENDS DATA FILE FOR SERVER
// VARIABLE "$ pagina" comes form
// I wonder if the option below I can generate another changing this or other pages
// variable "$ pagina" variable to another thus creating a second page with other content
<p>
<?
$txt_nome = $_POST['txt_nome'];
$handle = fopen ( 'paginas_criadas/'.$_POST['pagina'], "w");
$conteudo = "$mensagemHTML";
fwrite($handle, $mensagemHTML);
{
echo "Arquivo Salvo corretamente. <br/>";
echo "<br/>Click <a href='index.php'>aqui</a> and re-editing page<p></p>";
}
fclose($handle);
?>
</p>
</html>
Code: Select all
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<form action="formail.php" method="post">
<p align="center"><font face="Arial Narrow">
<input type="hidden" name="emaildest" value="email@servidor.com.br">
<font size="+3">FORMULÁRIO </font></font>
</p>
<p align="center"> </p>
<center><table width="635" bgcolor="#000000" border="0" align="center" cellspacing="0" cellpadding="1" height="270">
<tr>
<td width="633" height="268">
<div align="center">
<center>
<table width="344" bgcolor="#C4C4AA" border="1" cellspacing="0" cellpadding="3" style="border-collapse: collapse" bordercolor="#111111" height="271">
<tr>
<td width="93" height="22"><div align="left"><font size="2" face="Tahoma">Nome</font></div></td>
<td width="239" height="22"> <div align="left"><font face="Arial Narrow">
<input type="text" size="70" name="nome" value="">
</font></div></td>
</tr>
<tr>
<td width="93" height="22"><div align="left"><font face="Tahoma" size="2">Nome da Página Diretório </font></div></td>
<td width="239" height="22"> <div align="left"><font face="Arial Narrow">
<input type="text" size="70" name="pagina" value="">
</font></div></td>
</tr>
<tr>
<td width="93" height="22"><div align="left"><font face="Tahoma" size="2">Title complemento </font></div></td>
<td width="239" height="22"> <div align="left">
<p><font face="Arial Narrow">
<input type="text" size="70" name="title" value="">
</font></p>
</div></td>
</tr>
<tr>
<td colspan="2" align="center" width="331" height="71">
<div align="left"><font face="Arial Narrow">
<input type="submit" value=" Enviar " style="float: left; font-family: Tahoma">
</font><font face="Tahoma">
<input type="reset" value=" Limpar " style="float: left">
</font><font face="Arial Narrow">
</font></div></td>
</tr>
</table>
</center>
</div>
</td>
</tr>
</table>
</center>
</form>
<p align="center">
</body>
</html>