Topic: PHP script on ruby or direction

I have a web form I need to save the contents to a text file. I saw another post about running a PHP script on rails. Can I do this? My script looks like this:

<?php
$name = 'Name';
$email = 'email address';
$phone = 'phone';
$address = '123 main street';
$hear = 'i hear you';
$fp = fopen("formdata.txt", "a");
$savestring = $name . "," . $email . "," . $phone . "," . $address . "," . $hear . PHP_EOL;
fwrite($fp, $savestring);
fclose($fp);
echo "<h1>Thank you!</h1>";
?>

Or, can someone point me to a tutorial for saving form data in Rails.