我想让文本框中输入的名称和日期作为 .txt 文件的保存名称,如果有意义的话,答案会保存到。目前我可以让它使用名称变量,但不能同时使用?
这是我的代码:
<?php
$answer1="";
$answer2="";
$answer3="";
$answer4="";
$answer5="";
$answer6="";
$answer7="";
$answer8="";
if(isset($_POST['submit'])){ //if button is clicked do this:
$name = $_POST['myname'];
$date = $_POST['date'];
$answer1 = $_POST['q1answer'];
$answer2 = $_POST['q2answer'];
$answer3 = $_POST['q3answer'];
$answer4 = $_POST['q4answer'];
$answer5 = $_POST['q5answer'];
$answer6 = $_POST['q6answer'];
$answer7 = $_POST['q7answer'];
$answer8 = $_POST['q8answer'];
$answersText = "QUESTION 1\r\n\r\n". $answer1. "\r\n\r\nQUESTION 2\r\n\r\n". $answer2. "\r\n\r\nQUESTION 3\r\n\r\n". $answer3. "\r\n\r\nQUESTION 4\r\n\r\n". $answer4. "\r\n\r\nQUESTION 5\r\n\r\n". $answer5. "\r\n\r\nQUESTION 6\r\n\r\n". $answer6. "\r\n\r\nQUESTION 7\r\n\r\n". $answer7. "\r\n\r\nQUESTION 8\r\n\r\n". $answer8. "\r\n\r\n";
$file = fopen($name ".txt","w");
fwrite($file, $answersText);
fclose($file);