<?php
// Database connection variables
$servername = "localhost";
$username = "your_username";
$password = "your_password";
$dbname = "your_database";
// Establish a connection using SQLSRV
$connectionInfo = array("UID" => $username, "PWD" => $password, "Database" => $dbname);
$conn = sqlsrv_connect($servername, $connectionInfo);
// Check connection
if (!$conn) {
die(print_r(sqlsrv_errors(), true));
}
// Get values from the form
$worldID = $_POST['worldID'];
$gmName = $_POST['gmName'];
$toName = $_POST['toName'];
$title = $_POST['title'];
$content = $_POST['content'];
$orgObjID = $_POST['orgObjID'];
$count = $_POST['count'];
$mode = $_POST['mode'];
$ip = $_POST['ip'];
$money = $_POST['money'];
$exValue = $_POST['exValue'];
$ability = $_POST['ability'];
$durable = $_POST['durable'];
$createTime = $_POST['createTime'];
$serial = $_POST['serial'];
// Prepare the SQL query
$sql = "INSERT INTO ImportMail (
WorldID, GmName, ToName, Title, Content, OrgObjID, Count, Mode, IP, Money, ExValue, Ability, Durable, CreateTime, Serial
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
// Bind parameters and execute the query
$params = array($worldID, $gmName, $toName, $title, $content, $orgObjID, $count, $mode, $ip, $money, $exValue, $ability, $durable, $createTime, $serial);
$stmt = sqlsrv_prepare($conn, $sql, $params);
$result = sqlsrv_execute($stmt);
// Check if the insertion was successful
if ($result) {
echo "Data inserted successfully!";
} else {
echo "Error: " . $sql . "<br>" . print_r(sqlsrv_errors(), true);
}
// Close the connection
sqlsrv_free_stmt($stmt);
sqlsrv_close($conn);
?>