Find this useful? Enter your email to receive occasional updates for securing PHP code.
Signing you up...
Thank you for signing up!
PHP Decode
<?php // Check if form is submitted if ($_SERVER["REQUEST_METHOD"] == "POST") { // ..
Decoded Output download
<?php
// Check if form is submitted
if ($_SERVER["REQUEST_METHOD"] == "POST") {
// Database connection
// Create connection
$conn = new mysqli("localhost","root","","singup");
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
// Get user details from POST data
$name = $conn->real_escape_string($_POST['name']);
$mobile = $conn->real_escape_string($_POST['mobile']);
$reportDescription = $conn->real_escape_string($_POST['reportDescription']);
$accusedSocialMedia = $conn->real_escape_string($_POST['accusedSocialMedia']);
$accusedMobile = $conn->real_escape_string($_POST['accusedMobile']);
$accusedEmail = $conn->real_escape_string($_POST['accusedEmail']);
// Prepare SQL statement
$sql = "INSERT INTO cases (name, mobile, ReportDescription, AccusedSocialMedia, AccusedMobile, AccusedEmail)
VALUES ('$name', '$mobile', '$reportDescription', '$accusedSocialMedia', '$accusedMobile', '$accusedEmail')";
if ($conn->query($sql) === TRUE) {
echo "New record created successfully";
} else {
echo "Error: " . $sql . "<br>" . $conn->error;
}
$conn->close();
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="home.css">
<title>Chatbot</title>
</head>
<body>
<div class="chatbot-box">
<h1 class="cha">Secure Tech Chatbot</h1>
<div id="chatbox"></div>
<script>
const chatbox = document.getElementById('chatbox');
let step = 1;
let userDetails = {};
function displayMessage(sender, message) {
const messageElement = document.createElement('div');
messageElement.innerHTML = '<strong>' + sender + ':</strong> ' + message;
chatbox.appendChild(messageElement);
}
function collectUserDetails() {
const userInput = document.getElementById('userInput');
if (step === 1) {
displayMessage('Bot', 'Hi there! What is your name?');
} else if (step === 2) {
userDetails.name = userInput.value;
displayMessage('You', userInput.value);
displayMessage('Bot', 'What is your mobile number?');
} else if (step === 3) {
userDetails.mobile = userInput.value;
displayMessage('You', userInput.value);
displayMessage('Bot', 'Please describe the issue you want to report.');
} else if (step === 4) {
userDetails.reportDescription = userInput.value;
displayMessage('You', userInput.value);
displayMessage('Bot', 'Who is the accused/offender?');
} else if (step === 5) {
userDetails.accusedSocialMedia = userInput.value;
displayMessage('You', userInput.value);
displayMessage('Bot', 'Please provide the accused/offender\'s mobile number.');
} else if (step === 6) {
userDetails.accusedMobile = userInput.value;
displayMessage('You', userInput.value);
displayMessage('Bot', 'Please provide the accused/offender\'s email address.');
} else if (step === 7) {
userDetails.accusedEmail = userInput.value;
displayMessage('You', userInput.value);
displayMessage('Bot', 'Please provide the accused/offender\'s social account address.');
} else if (step === 8) {
userDetails.accusedSocialMedia = userInput.value;
displayMessage('You', userInput.value);
displayMessage('Bot', 'Thank you for providing the information. Your report has been submitted. Our team will further contact you. Have a good day');
// AJAX to send data to PHP script
var xhr = new XMLHttpRequest();
xhr.open("POST", "process_form.php", true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.onreadystatechange = function() {
if (xhr.readyState == 4 && xhr.status == 200) {
console.log(xhr.responseText);
}
}
var data = "name=" + userDetails.name + "&mobile=" + userDetails.mobile + "&reportDescription=" + userDetails.reportDescription + "&accusedSocialMedia=" + userDetails.accusedSocialMedia + "&accusedMobile=" + userDetails.accusedMobile + "&accusedEmail=" + userDetails.accusedEmail;
xhr.send(data);
}
step++;
userInput.value = '';
}
// Trigger bot to start conversation
collectUserDetails();
// Handle user input
function sendMessage() {
collectUserDetails();
}
</script>
<input type="text" id="userInput">
<button onclick="sendMessage()">
<svg
height="24"
width="24"
viewBox="0 0 24 24"
xmlns="http://www.w3.org/2000/svg"
>
<path d="M0 0h24v24H0z" fill="none"></path>
<path
d="M5 13c0-5.088 2.903-9.436 7-11.182C16.097 3.564 19 7.912 19 13c0 .823-.076 1.626-.22 2.403l1.94 1.832a.5.5 0 0 1 .095.603l-2.495 4.575a.5.5 0 0 1-.793.114l-2.234-2.234a1 1 0 0 0-.707-.293H9.414a1 1 0 0 0-.707.293l-2.234 2.234a.5.5 0 0 1-.793-.114l-2.495-4.575a.5.5 0 0 1 .095-.603l1.94-1.832C5.077 14.626 5 13.823 5 13zm1.476 6.696l.817-.817A3 3 0 0 1 9.414 18h5.172a3 3 0 0 1 2.121.879l.817.817.982-1.8-1.1-1.04a2 2 0 0 1-.593-1.82c.124-.664.187-1.345.187-2.036 0-3.87-1.995-7.3-5-8.96C8.995 5.7 7 9.13 7 13c0 .691.063 1.372.187 2.037a2 2 0 0 1-.593 1.82l-1.1 1.039.982 1.8zM12 13a2 2 0 1 1 0-4 2 2 0 0 1 0 4z"
fill="currentColor"
></path>
</svg>
<span>Submit</span>
</button>
</div>
</body>
</html>
Did this file decode correctly?
Original Code
<?php
// Check if form is submitted
if ($_SERVER["REQUEST_METHOD"] == "POST") {
// Database connection
// Create connection
$conn = new mysqli("localhost","root","","singup");
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
// Get user details from POST data
$name = $conn->real_escape_string($_POST['name']);
$mobile = $conn->real_escape_string($_POST['mobile']);
$reportDescription = $conn->real_escape_string($_POST['reportDescription']);
$accusedSocialMedia = $conn->real_escape_string($_POST['accusedSocialMedia']);
$accusedMobile = $conn->real_escape_string($_POST['accusedMobile']);
$accusedEmail = $conn->real_escape_string($_POST['accusedEmail']);
// Prepare SQL statement
$sql = "INSERT INTO cases (name, mobile, ReportDescription, AccusedSocialMedia, AccusedMobile, AccusedEmail)
VALUES ('$name', '$mobile', '$reportDescription', '$accusedSocialMedia', '$accusedMobile', '$accusedEmail')";
if ($conn->query($sql) === TRUE) {
echo "New record created successfully";
} else {
echo "Error: " . $sql . "<br>" . $conn->error;
}
$conn->close();
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="home.css">
<title>Chatbot</title>
</head>
<body>
<div class="chatbot-box">
<h1 class="cha">Secure Tech Chatbot</h1>
<div id="chatbox"></div>
<script>
const chatbox = document.getElementById('chatbox');
let step = 1;
let userDetails = {};
function displayMessage(sender, message) {
const messageElement = document.createElement('div');
messageElement.innerHTML = '<strong>' + sender + ':</strong> ' + message;
chatbox.appendChild(messageElement);
}
function collectUserDetails() {
const userInput = document.getElementById('userInput');
if (step === 1) {
displayMessage('Bot', 'Hi there! What is your name?');
} else if (step === 2) {
userDetails.name = userInput.value;
displayMessage('You', userInput.value);
displayMessage('Bot', 'What is your mobile number?');
} else if (step === 3) {
userDetails.mobile = userInput.value;
displayMessage('You', userInput.value);
displayMessage('Bot', 'Please describe the issue you want to report.');
} else if (step === 4) {
userDetails.reportDescription = userInput.value;
displayMessage('You', userInput.value);
displayMessage('Bot', 'Who is the accused/offender?');
} else if (step === 5) {
userDetails.accusedSocialMedia = userInput.value;
displayMessage('You', userInput.value);
displayMessage('Bot', 'Please provide the accused/offender\'s mobile number.');
} else if (step === 6) {
userDetails.accusedMobile = userInput.value;
displayMessage('You', userInput.value);
displayMessage('Bot', 'Please provide the accused/offender\'s email address.');
} else if (step === 7) {
userDetails.accusedEmail = userInput.value;
displayMessage('You', userInput.value);
displayMessage('Bot', 'Please provide the accused/offender\'s social account address.');
} else if (step === 8) {
userDetails.accusedSocialMedia = userInput.value;
displayMessage('You', userInput.value);
displayMessage('Bot', 'Thank you for providing the information. Your report has been submitted. Our team will further contact you. Have a good day');
// AJAX to send data to PHP script
var xhr = new XMLHttpRequest();
xhr.open("POST", "process_form.php", true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.onreadystatechange = function() {
if (xhr.readyState == 4 && xhr.status == 200) {
console.log(xhr.responseText);
}
}
var data = "name=" + userDetails.name + "&mobile=" + userDetails.mobile + "&reportDescription=" + userDetails.reportDescription + "&accusedSocialMedia=" + userDetails.accusedSocialMedia + "&accusedMobile=" + userDetails.accusedMobile + "&accusedEmail=" + userDetails.accusedEmail;
xhr.send(data);
}
step++;
userInput.value = '';
}
// Trigger bot to start conversation
collectUserDetails();
// Handle user input
function sendMessage() {
collectUserDetails();
}
</script>
<input type="text" id="userInput">
<button onclick="sendMessage()">
<svg
height="24"
width="24"
viewBox="0 0 24 24"
xmlns="http://www.w3.org/2000/svg"
>
<path d="M0 0h24v24H0z" fill="none"></path>
<path
d="M5 13c0-5.088 2.903-9.436 7-11.182C16.097 3.564 19 7.912 19 13c0 .823-.076 1.626-.22 2.403l1.94 1.832a.5.5 0 0 1 .095.603l-2.495 4.575a.5.5 0 0 1-.793.114l-2.234-2.234a1 1 0 0 0-.707-.293H9.414a1 1 0 0 0-.707.293l-2.234 2.234a.5.5 0 0 1-.793-.114l-2.495-4.575a.5.5 0 0 1 .095-.603l1.94-1.832C5.077 14.626 5 13.823 5 13zm1.476 6.696l.817-.817A3 3 0 0 1 9.414 18h5.172a3 3 0 0 1 2.121.879l.817.817.982-1.8-1.1-1.04a2 2 0 0 1-.593-1.82c.124-.664.187-1.345.187-2.036 0-3.87-1.995-7.3-5-8.96C8.995 5.7 7 9.13 7 13c0 .691.063 1.372.187 2.037a2 2 0 0 1-.593 1.82l-1.1 1.039.982 1.8zM12 13a2 2 0 1 1 0-4 2 2 0 0 1 0 4z"
fill="currentColor"
></path>
</svg>
<span>Submit</span>
</button>
</div>
</body>
</html>
Function Calls
None |
Stats
MD5 | fbdbcbbf3e57a8112e61f79db137483f |
Eval Count | 0 |
Decode Time | 67 ms |