Estoy tratando de enviar un formulario con dos entradas de texto y tratando de guardar las dos entradas en dos archivos de texto separados pero sin éxito. Puedo guardar las dos entradas en un archivo, pero no puedo deslizar las entradas en dos archivos de texto separados.
Esto es lo que he intentado:
formulario HTML:
<form action="run.php" method="post"> Link:<br><input type="text" name="linkisv" value=""><br> Email:<br><input type="text" name="emailisv" value=""><br> <input type="submit" id ="submitButton" value="Submit"> </form>La solución PHP:
<?php $linkisv = $_POST["linkisv"]; //You have to get the form data $emailisv = $_POST["emailisv"]; $file = fopen('configurationSettings.txt', 'w+'); //Open your .txt file ftruncate($file, 0); //Clear the file to 0bit $content = $linkisv. PHP_EOL .$emailisv; fwrite($file , $content); //Now lets write it in there fclose($file ); //Finally close our .txt die(header("Location: ".$_SERVER["HTTP_REFERER"]));?>Con este código:
<?php $linkisv = $_POST["linkisv"]; //You have to get the form data $emailisv = $_POST["emailisv"]; // SAVING FIRST FILE $file = fopen('configurationSettings.txt', 'w+'); //Open your .txt file ftruncate($file, 0); //Clear the file to 0bit $content = $linkisv; fwrite($file , $content); //Now lets write it in there fclose($file); //Finally close our .txt // SAVING SECOND FILE $file = fopen('second_file_name.txt', 'w+'); //Open your .txt file ftruncate($file, 0); //Clear the file to 0bit $content = $emailisv; fwrite($file , $content); //Now lets write it in there fclose($file); //Finally close our .txt // REDIRECT die(header("Location: ".$_SERVER["HTTP_REFERER"]));?>