Save input to HTML and PHP txt files

Asked

Viewed 531 times

1

Hi, I’m trying to save the information typed in the HTML Input in txt. I already have my code that seems to be working.. But it is not creating txt. Can someone figure out why?

That’s the form, inside the body:
<form name="web_form" id="web_form" method="post" action="teste.php">
        <p><label>Enter name: </label><input type="text" name="name" id="name" /></p>
        <p><label>Enter email: </label><input type="text" name="email" id="email" /></p>
        <p><input type="submit" name=s1″ id="s1″ value="Submit"></p>
</form>

This is the PHP:

<?php
$name = $_POST['name'];
$email = $_POST['email'];
$fp = fopen("formdata.txt", "a");
$savestring = $name . "," . $email . "n";
fwrite($fp, $savestring);
fclose($fp);
?>
  • This may be a write permission issue in the folder. the $Fp variable is false?

  • I’m not sure, but I believe I didn’t. I tested it on the desktop and also it wasn’t..

  • in my test worked perfectly

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.