I need to change this script to c# as i am writing an MVC 5 website or any suggestions on how I can write it in C# it basically takes the post data from a rfid reader and pushes it to a web url. Thanks if you can help at all
<?php
// Uncomment this block for debug.
// It writes the raw POST data to a file.
/*
$fn = "log.txt";
$fp = fopen($fn, "a");
$rawPostData = file_get_contents('php://input');
fwrite($fp, date("l F d, Y, h:i A") . "," . $rawPostData . "\n");
fclose($fp);
*/
// Define the user name, password,
// MySQL hostname and database name.
define("DB_USER", "user");
define("DB_PASS", "pass");
define("DB_HOST", "mysql.myhost.com");
define("DB_NAME", "dbname");
// Store the POST variables.
$readerName = $_POST[reader_name];
$macAddress = $_POST[mac_address];
$lineEnding = $_POST[line_ending];
$fieldDelim = $_POST[field_delim];
$fieldNames = $_POST[field_names];
$fieldValues = $_POST[field_values];
// Connect to the database.
$con = mysql_connect(DB_HOST, DB_USER, DB_PASS);
mysql_select_db(DB_NAME) or die( "Unable to select database");
// Replace the field delimiter with a comma.
str_replace($fieldDelim, ",", $fieldNames);
// Break the field values up into rows.
$rows = explode("\n", $fieldValues);
// Remove the last row. It's always blank
if (sizeof($rows)) array_pop($rows);
$fieldNames = "reader_name,mac_address," . $fieldNames;
foreach ($rows as $row)
{
$row = $readerName . "," . $macAddress . "," .
$row;
$query = "INSERT INTO tags ($fieldNames) VALUES ($row)";
echo $query . "\n";
mysql_query($query);
}
mysql_close($con);
?>