PDA

View Full Version : could you help me this script


0810
09-14-2002, 06:29 AM
Could you please help my script
Hi how are you doing? What I am trying to do is I would like to print name, E-mail , password in the next page. In other words, when a user clicks sends button, next page will print name, E-mail, password. I tried to do this one but I couldn't do it.

Also,if a user misses filling out E-mail, it warns like " Fill out the E-mail"

My php is 4.22

Could you help me my script


here is my script

<html>
<head>
</head>
<body>
<p>Enter whatever</p>

<form action="<?php $_SERVER['PHP_SELF']; ?>" method="post">
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


if(isset($_POST["submit"]))
{

$msg=$_POST["msg"];
$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);

print("Thank you for filling out my form<br>\n");

}



?>
</body>
</html>

Could you please help me

Thanks

downsize
09-14-2002, 10:25 AM
I do not understand the problem. what is the logic you want? the user to fill out the form, have it write to the file 'log.txt', and then display a page with the information they just submitted?

right now your script should work fine if you want the logic to be: user fills out the form, submits and the application outputs to a file named 'log.txt'.

so I am not sure what you are trying to accomplish. But if you output with echo() or print() in the same conditional "if(isset($_POST["submit"])) " you could easily display the same info you are writing out to log.txt.

0810
09-14-2002, 06:18 PM
What I am trying to do is outputs(name,E-mail,password) should be next page. When a user clicks sends button, it goes to next page. Then it will show output like(name, E-mail, password) like print.

could you explain to me with my script.

Thanks.

downsize
09-14-2002, 09:29 PM
well, like I said - simply print out the values as you have them going to the file.

Just as a test, copy all of your code which outputs to the file:

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");



and change the fwrite to print.

this will display above your confirmation print message:
print("Thank you for filling out my form<br>\n");

0810
09-15-2002, 08:14 AM
it didn't print anything

I means that I would like to print next page not same page.

If i follow your way, it prints same page. when I click a submit button, the next page will print it..

Do you understand what I am trying to explain to you?

Thanks

Please fix my code

Then I will understand

Thanks

downsize
09-15-2002, 06:00 PM
Please fix my code
now that's funny..

you will need another file then. point the form to post to another file and then print out the text and variables.


<html>
<head>
</head>
<body>
<p>Enter whatever</p>

<form action="<?php filename.php ?>" method="post">
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>

</body>
</html>


filename.php:

<?php


if(isset($_POST["submit"]))
{

$msg=$_POST["msg"];
$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);

print("Thank you for filling out my form<br>\n");

}



?>