View Full Version : fwrite script
\Hi how are you doing? This script works but I got warning.
Please check it out for me
my php is 4.2
Here is warning
Notice: Undefined index: msg in c:\itohideo\ito10.php on line 17
Notice: Undefined index: fp in c:\itohideo\ito10.php on line 18
Notice: Undefined index: mail in c:\itohideo\ito10.php on line 19
Notice: Undefined index: password in c:\itohideo\ito10.php on line 20
Notice: Undefined index: submit in c:\itohideo\ito10.php on line 22
Here is script
<html>
<head>
</head>
<body>
<p>Enter whatever</p>
<form method="post" action="ito10.php">
Name<input type="text" size="80" name="msg"><br>
E-mail<input type="text" size="80" name="mail">
<br>
Password<input type="text" size="80" name="password"><br>
<input type="submit" name="submit" value="Send">
<input type="reset" name="reset" value="reset">
</form>
<?php
$msg=$_POST["msg"];
$fp=$_POST["fp"];
$mail=$_POST["mail"];
$password=$_POST["password"];
if($_POST["submit"]!="")
{
$fp=fopen("log.txt","a");
if(!$fp)
{
print("Can't open your file'");
exit;
}
fwrite($fp,"*******************************************************\r\n\r\n");
fwrite($fp,"Name:\t\t\t$msg\r\n");
fwrite($fp,"E-mail:\t\t$mail\r\n\r\n");
fwrite($fp,"Password:\t\t$password\r\n\r\n");
fclose($fp);
}
?>
</body>
</html>
firepages
08-16-2002, 10:10 AM
Hi I assume your error_reporting level is set to E_ALL in which case
$msg=$_POST["msg"];
should be
if(isset($_POST["msg"]){$msg=$_POST["msg"]; }
etc , but as thats sometimes a pain (IMO not everyones) check out http://www.php.net/error_reporting to set a resonable reporting level
Hi I did this way but I sitll got warning!
Notice:Undefined index fp in C:\itohideo\ito.php on line 23
Also I would like to show only text like "Thank you for filling out my form" jsut like this in next page.
Please tell me how to do it
Thanks
<?php
if(isset($_POST["submit"]))
{
$msg=$_POST["msg"];
$fp=$_POST["fp"];
$mail=$_POST["mail"];
$password=$_POST["password"];
$fp=fopen("log.txt","a");
if(!$fp)
{
print("Can't open your file'");
exit;
}
fwrite($fp," **************************************************
*****\r\n\r\n");
fwrite($fp,"Name:\t\t\t$msg\r\n");
fwrite($fp,"E-mail:\t\t$mail\r\n\r\n");
fwrite($fp,"Password:\t\t$password\r\n\r\n");
fclose($fp);
}
?>
mordred
08-17-2002, 10:47 PM
Why do you have this line at all in your script - your form doesn't show an input field named "fp", so where should the value come from?
$fp=$_POST["fp"];
Delete it and the error message will go away.
thanks mordred
You are right.
I have one QUA. I would like to know how to show only text like"thank you for filling my form" to next page.
When I click button, it goes to next page just only show" Thank you for filling out my form"
Do you have any idea?
Thank you very much
mordred
08-18-2002, 12:26 AM
Originally posted by 0810
I have one QUA.
A moment please - I understand this phrase as "I have a question more". But I'm not hundred percent positive on this. Because you wrote "QUA". If you meant "question", then please do write "question". I'm not a native english speaker and sentences like this take more time for me to sort them out. Should "QUA" be a abbreviation or a certain idiom, please enlighten me.
I would like to know how to show only text like"thank you for filling my form" to next page.
When I click button, it goes to next page just only show" Thank you for filling out my form"
Do you have any idea?
:confused:
I'm not sure I understand you completely, what speaks against adding a
echo "Thank you for filling out my form";
after all the file operations were carried succesfully out?
mordred
yeah Eveything is ok. Thanks mordred. I just like to know how I can show only text "thank you for filling my form" to next page when I click send's button.
Now even though I click send button, it doesn't go next page. Just come up text("thank you for filling my form") under the form.
I would like to do next page
Sorry not to explain about well
Do you get it?
Thanks mordred
Bye
mordred
08-18-2002, 04:41 PM
Ah! Now I've got it, thanks to the more detailed request.
It's actually quite easy: You split the whole thing into two separate files. On the first, let's name it page1.php, you only have your form and the HTML, no PHP code at all. In your action attribute of the form tag, you write "page2.php", like
<form action="page2.php">
Then you put your complete PHP code on page2.php and echo the sentence you want to print out after the file has been written.
Hi mordred
I did your way but my datas(Name, E-mail, Password) don't go to "log.txt". It means that fwrite doesn't work if I did your way.
Do you have any idea?
Thanks mordred
mordred
08-19-2002, 12:46 AM
No idea unless you post the code you used...
...we can't mindread.
Here is code
<?php
print("Thank you for filling out my form<br>\n");
?>
like this
But I could get my records to log.txt
Thanks mordred
mordred
08-21-2002, 11:20 AM
:confused:
Am I missing something or does the code above really only contain a print statement? Where's the code responsible for writing into the .txt file?
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.