Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $servername = "localhost";
- $username = "root";
- $password = "";
- $dbname = "mahamed_hassan";
- // Create connection
- $conn = new mysqli($servername, $username, $password, $dbname);
- // Check connection
- if ($conn->connect_error) {
- die("Connection failed: " . $conn->connect_error);
- }
- if (ISSET($_POST['addinfo'])) {
- if (!empty($_POST['firstname'])) {
- $firstname = $_POST['firstname'];
- if (!empty($_POST['lastname'])) {
- $lastname = $_POST['lastname'];
- if (!empty($_POST['email'])) {
- $email = $_POST['email'];
- if (!empty($_POST['phone'])) {
- $phone = $_POST['phone'];
- if (!empty($_POST['country'])) {
- $country = $_POST['country'];
- $sql = "INSERT INTO tbl1_info (firstname, lastname, email, phone, country)
- VALUES ('$firstname', '$lastname', '$email','$phone','$country')";
- if ($conn->query($sql) === TRUE) {
- echo "Successfully Add Info :) ";
- } else {
- echo "Error: Insert In Table <br>";
- }
- }else{ $msg = "Plz Complete Country !"; }
- }else{ $msg = "Plz Complete Phone !"; }
- }else{ $msg = "Plz Complete Email !"; }
- }else{ $msg = "Plz Complete Last Name !"; }
- }else{ $msg = "Plz Complete First Name !"; }
- }
- ?>
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <title>Add Record Form</title>
- <style type="text/css">
- form{
- background: green;
- width: 300px;
- padding: 10px;
- font-size: 18px;
- font-family: fantasy;
- color: darkorange;
- }
- input{
- width: 100%;
- border-style: double;
- font-size: 18px;
- }
- </style>
- </head>
- <body>
- <center>
- <form action="" method="POST" name="addinfo">
- <p><?php if (!empty($msg)) {?><a style="color: red ;font-size: 20"><? echo $msg."</a>";}?></p>
- <p>
- <label for="firstName">First Name:</label>
- <input type="text" name="firstname" id="firstName" required>
- </p>
- <p>
- <label for="lastName">Last Name:</label>
- <input type="text" name="lastname" id="lastName" required>
- </p>
- <p>
- <label for="emailAddress">Email Address:</label>
- <input type="email" name="email" id="emailAddress" required>
- </p>
- <p>
- <label for="phone">Phone Nomber:</label>
- <input type="text" name="phone" id="phone" required>
- </p>
- <p>
- <label for="country">Country:</label>
- <input type="text" name="country" id="phone" required>
- </p>
- <input type="submit" value="Submit" name="addinfo">
- </form>
- </center>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement