Put this file together and then placed it up on my Linux server:
PHP Array Practice
<?=$message;?> |
First Name |
|
Last Name |
|
|
City |
|
State |
|
ZIP |
|
Phone |
|
Email |
|
|
Please send me email |
Comments
|
<?php
$fn = $_POST['fn'];
$ln = $_POST['ln'];
$address = $_POST['address'];
$city = $_POST['city'];
$state = $_POST['state'];
$zip = $_POST['zip'];
$phone = $_POST['phone'];
$email = $_POST['email'];
$emailMe = (isset($_POST['emailMe'])) ? $_POST['emailMe'] : 'No';
$comments = $_POST['comments'];
//validate
if(empty($fn) || empty($ln) || empty($address) || empty($city) || empty($state) || empty($zip) || empty($phone) || empty($email)){//show the form
$message = 'Fill in areas in red!';
$aClass = 'errorClass';
//this is where the creating of the csv takes place
$cvsData = $fn . "," . $ln . "," . $address . "," . $city . "," . $state . "," . $zip . "," . $phone . "," . $email . "," .$emailMe . "," . $comments ."\n";
//then we open the file:
$fp = fopen("raTest.csv","a"); // $fp is now the file pointer to file $filename
//And then we write the form contents to the file:
if($fp){
fwrite($fp,$cvsData); // Write information to the file
fclose($fp); // Close the file
?>
I have created the raTest.csv file with header lines and set permissions on everything wide open. If I pull out the <PHP?, the HTML form displays correctly but all the PHP comes out as plain text. I got this code off the HUBS site so it is pretty old. Maybe my version of PHP is off?
I am trying to fill in a Risk Assessment form a little at a time and dump the contents into a CSV file. From there it will go into LibreOffice Calc and some math will need to be performed. The final CSV will have about 35 rows and 70 columns but I want to chunk it up. The plan is to use checkboxes for the columns to allow the user to “check” all vulnerabilities that apply to each row and put them into the CSV file.