Skip to content

Instantly share code, notes, and snippets.

@farithadnan
Last active March 20, 2021 22:16
Show Gist options
  • Select an option

  • Save farithadnan/fcf764b8e081e01d00c291125be3ae6f to your computer and use it in GitHub Desktop.

Select an option

Save farithadnan/fcf764b8e081e01d00c291125be3ae6f to your computer and use it in GitHub Desktop.
Simple inserting data to DB with basic PHP.
<?php
if(isset($_POST['submit']))
{
$firstName = $_POST['firstName'];
$lastName = $_POST['lastName'];
$email = $_POST['email'];
$subject= $_POST['subject'];
$message = $_POST['message'];
$sql="INSERT INTO sentmessage(firstName, lastName, email, subject, message)VALUES('$firstName','$lastName','$email', '$subject','$message')";
$sql_check = mysqli_query($link, $sql) or die("Query failed");
if($sql_check)
{
echo ("<SCRIPT LANGUAGE='JavaScript'>
window.alert('Thank You for Your Message!');
window.location.href='contact.php'
</SCRIPT>");
exit();
}
else
{
echo ("<SCRIPT LANGUAGE='JavaScript'>
window.alert('Error!');
window.location.href='contact.php'
</SCRIPT>");
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment