Jump to content

AlexMalex

New Members
  • Posts

    4
  • Joined

  • Last visited

AlexMalex's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Thank you so much, you made my life so easy.....exactly what I wanted. I wanted to do the breaks - thats why I asked earlier if I can have it "rather" in a way that it saves every submission on a different file file1.txt file2.txt file3.txt and so on.... or alternatively I think its easier to have a breaker like ( ------------------ or even some <br><br><br>'s ) after every submission to distinguish between every time someone submits. could you guide me through this? on how or where to add what? For the project i am doing txt format is perfectly fine as it is only a few submissions but I am sure the correct way of doing it would be some sort of database as you all mentioned.
  2. Barand: what youve done seems very cool and pretty much makes my life easier in writing it as the questionare is very long. but it tells me that line 15 is wrong (your fwrite script). if you could look at line 9 also to see if that one is correct or does it need [] ? Many thanks. <?php if(isset($_POST['submit'])){ $firstName = "First Name:".$_POST['firstName']." "; $lastName = "Last Name:".$_POST['lastName']." "; $sex = "Sex:".$_POST['sex']." "; $fruit = "Fav Fruits:".$_POST['fruit']." "; $file=fopen("file2.txt", "a"); fwrite($file, $firstName); fwrite($file, $lastName); fwrite($file, $sex); fwrite($file, join(', ', $_POST['fruit']); fclose($file); } ?> <form method="post"> Name<input type="text" name="firstName" placeholder="First Name" required autocomplete="off"> <br> Last Name<input type="text" name="lastName" placeholder="Last Name" required autocomplete="off"> <br> Sex<input type="radio" name="sex" value="male">Male <input type="radio" name="sex" value="female">Female<br> Fav Fruit<input type="checkbox" name="fruit[]" value="apple">Apple <input type="checkbox" name="fruit[]" value="orange">Orange <input type="checkbox" name="fruit[]" value="berry">Berry<br> <input type="submit" name="submit" value="Submit"> </form>
  3. Okay I did the following by separating it to all individual lines. It does work, but on the output text file it shows the following. First Name:a Last Name:b Sex:male Fav Fruits: Fav Fruits:orange Fav Fruits:berry I would like to have it like Fav Fruits: orange berry (whichever selected) rather than having them on individual lines. is that possible? Also, on the text file exported. it stacks up all the answers in file repeatedly - I would like to have individual files for every submission. like file1.txt file2.txt ..... numbers going up. many thanks in advance. <?php if(isset($_POST['submit'])){ $firstName = "First Name:".$_POST['firstName']." "; $lastName = "Last Name:".$_POST['lastName']." "; $sex = "Sex:".$_POST['sex']." "; $fruit = "Fav Fruits:".$_POST['fruit']." "; $fruit2 = "Fav Fruits:".$_POST['fruit2']." "; $fruit3 = "Fav Fruits:".$_POST['fruit3']." "; $file=fopen("file.txt", "a"); fwrite($file, $firstName); fwrite($file, $lastName); fwrite($file, $sex); fwrite($file, $fruit); fwrite($file, $fruit2); fwrite($file, $fruit3); fclose($file); } ?> <form method="post"> Name<input type="text" name="firstName" placeholder="First Name" required autocomplete="off"> <br> Last Name<input type="text" name="lastName" placeholder="Last Name" required autocomplete="off"> <br> Sex<input type="radio" name="sex" value="male">Male <input type="radio" name="sex" value="female">Female<br> Fav Fruit<input type="checkbox" name="fruit" value="apple">Apple <input type="checkbox" name="fruit2" value="orange">Orange <input type="checkbox" name="fruit3" value="berry">Berry<br> <input type="submit" name="submit" value="Submit"> </form>
  4. Hi, I am kind of new to PHP, I looked around google and found what I was looking for (questionnaire to text) works perfectly fine with input type text and radio but when I try to do a checkbox it would not write the multiple answers on text file it would rather do one or return with an error. could someone please look at the script below and see what I am doing wrong? <?php if(isset($_POST['submit'])){ $firstName = "First Name:".$_POST['firstName']." "; $lastName = "Last Name:".$_POST['lastName']." "; $sex = "Sex:".$_POST['sex']." "; $fruit = "Fav Fruits:".$_POST['fruit, fruit2, fruit3']." "; $file=fopen("file.txt", "a"); fwrite($file, $firstName); fwrite($file, $lastName); fwrite($file, $sex); fwrite($file, $fruit, $fruit2, $fruit3); fclose($file); } ?> <form method="post"> Name<input type="text" name="firstName" placeholder="First Name" required autocomplete="off"> <br> Last Name<input type="text" name="lastName" placeholder="Last Name" required autocomplete="off"> <br> Sex<input type="radio" name="sex" value="male">Male <input type="radio" name="sex" value="female">Female<br> Fav Fruit<input type="checkbox" name="fruit" value="apple">Apple <input type="checkbox" name="fruit2" value="orange">Orange <input type="checkbox" name="fruit3" value="berry">Berry<br> <input type="submit" name="submit" value="Submit"> </form>
×
×
  • 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.