Convert PHP code into C#

May 28 2019 5:55 AM
<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "XYZ";

$user=$_REQUEST["username"];
$mobile=$_REQUEST["mobile"];
$email=$_REQUEST["email"];
$city=$_REQUEST["city"];
$gender=$_REQUEST["gender"];
 
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
}

$sql = "INSERT INTO registration (username, mobile,email,city,gender)VALUES ('$user', '$mobile', '$email', '$city', '$gender')";

if ($conn->query($sql) === TRUE) {
    echo "New record created successfully";
} else {
    echo "Error: " . $sql . "<br>" . $conn->error;
}

$conn->close();
?>

Answers (1)