samedi 31 janvier 2015

Php Form Data to Text Problem


Whenever i enter form data, the form action points to my php processing script but instead of writing it to a text file, it opens the code in the browser, what could be wrong?


My form



<form name="web_form" id="web_form" method="post" action="myprocessing.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>


Myprocessing.php



<?php
$name = $_POST['name'];
$email = $_POST['email'];
$fp = fopen("formdata.txt", "a");
$savestring = $name . "," . $email . "n";
fwrite($fp, $savestring);
fclose($fp);
echo "<h1>You data has been saved in a text file!</h1>";
?>




Aucun commentaire:

Enregistrer un commentaire