Jump to content

Simple Solution, For you guys I am sure


zipppy

Recommended Posts

Why does this simple snippet not print the info to .txt file pluged in by the user?

 

<?php

$f=fopen("text.txt","a");

fwrite($f,"****************************************\r\n\r\n");

fwrite($f," Name: $name\r\n");

fwrite($f," Email: $email\r\n\r\n");

fclose($f);

?>

 

It prints to text.txt on the server

 

Name:

Email:

 

but no input data.

 

Any good help appreciated greatly.

 

zippy

Link to comment
https://forums.phpfreaks.com/topic/122760-simple-solution-for-you-guys-i-am-sure/
Share on other sites

Because you haven't defined $name or $email :P

 

Did you mean to do this?

 

<?php
$name = $_POST['name']; // Name form form
$email = $_POST['email']; // Email from form
$f=fopen("text.txt","a");
fwrite($f,"****************************************\r\n\r\n");
fwrite($f," Name: $name\r\n");
fwrite($f," Email: $email\r\n\r\n");
fclose($f);
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.