Advertisement
Guest User

Untitled

a guest
Nov 18th, 2019
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.20 KB | None | 0 0
  1. <html>
  2. <title>Order form</title>
  3. <body>
  4. <form method='post' action=''>
  5. <input type="submit" name="submit" value="Save to .csv file"><br>
  6. </form>
  7. </body>
  8. </html>
  9. <?php
  10.  
  11.  
  12.  
  13.  
  14.  
  15.  
  16.  
  17. if(isset($_POST['submit'])){
  18. function array_to_CSV()
  19. {
  20.  
  21.  
  22.  
  23. $FirstName = $_POST["FirstName"];
  24. $LastName = $_POST["LastName"];
  25. $Phone = $_POST["Phone"];
  26. $StreetNum = $_POST["StreetNum"];
  27. $StreenName = $_POST["StreetName"];
  28. $Suburb = $_POST["Suburb"];
  29. $Postcode = $_POST["Postcode"];
  30. $Milk = $_POST["Milk"];
  31. $Bread = $_POST["Bread"];
  32. $Butter = $_POST["Butter"];
  33. $Cheese = $_POST["Cheese"];
  34. $Eggs = $_POST["Eggs"];
  35.  
  36.  
  37. $formInfo = array (
  38. array("$LastName", "$Phone", "$StreetNum", "$StreetName", "$Suburb", "$Postcode", "$Milk", "$Bread", "$Butter", "$Cheese", "$Eggs")
  39. );
  40.  
  41. $file = fopen("orders1.csv","w");
  42.  
  43. foreach ($formInfo as $line) {
  44. fputcsv($file, $line);
  45. }
  46.  
  47. fclose($file);
  48.  
  49. }
  50. array_to_CSV();
  51. }
  52. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement