Last active
March 20, 2021 22:16
-
-
Save farithadnan/fcf764b8e081e01d00c291125be3ae6f to your computer and use it in GitHub Desktop.
Simple inserting data to DB with basic PHP.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?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