Advertisement
Guest User

Untitled

a guest
Oct 20th, 2016
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.55 KB | None | 0 0
  1. <?php
  2. $servername = "localhost";
  3. $username = "root";
  4. $password = "";
  5. $dbname = "mahamed_hassan";
  6.  
  7. // Create connection
  8. $conn = new mysqli($servername, $username, $password, $dbname);
  9. // Check connection
  10. if ($conn->connect_error) {
  11.     die("Connection failed: " . $conn->connect_error);
  12. }
  13.  
  14. if (ISSET($_POST['addinfo'])) {
  15.    
  16.     if (!empty($_POST['firstname'])) {
  17.  
  18.         $firstname = $_POST['firstname'];
  19.  
  20.         if (!empty($_POST['lastname'])) {
  21.  
  22.             $lastname = $_POST['lastname'];
  23.  
  24.             if (!empty($_POST['email'])) {
  25.  
  26.                 $email = $_POST['email'];
  27.  
  28.                 if (!empty($_POST['phone'])) {
  29.  
  30.                     $phone = $_POST['phone'];
  31.  
  32.                     if (!empty($_POST['country'])) {
  33.  
  34.                     $country = $_POST['country'];
  35.                        
  36.  
  37.                     $sql = "INSERT INTO tbl1_info (firstname, lastname, email, phone, country)
  38.                     VALUES ('$firstname', '$lastname', '$email','$phone','$country')";
  39.  
  40.                     if ($conn->query($sql) === TRUE) {
  41.                         echo "Successfully Add Info :) ";
  42.                     } else {
  43.                         echo "Error: Insert In Table <br>";
  44.                     }
  45.  
  46.                     }else{  $msg = "Plz Complete Country !"; }
  47.  
  48.                 }else{  $msg = "Plz Complete Phone !"; }
  49.  
  50.             }else{  $msg = "Plz Complete Email !"; }
  51.  
  52.         }else{  $msg = "Plz Complete Last Name !"; }
  53.  
  54.     }else{  $msg = "Plz Complete First Name !"; }
  55. }
  56.  
  57. ?>
  58. <!DOCTYPE html>
  59. <html lang="en">
  60. <head>
  61. <meta charset="UTF-8">
  62. <title>Add Record Form</title>
  63. <style type="text/css">
  64.     form{
  65.     background: green;
  66.         width: 300px;
  67.         padding: 10px;
  68.         font-size: 18px;
  69.         font-family: fantasy;
  70.         color: darkorange;
  71.     }
  72.     input{
  73.        
  74.         width: 100%;
  75.         border-style: double;
  76.         font-size: 18px;
  77.     }
  78. </style>
  79. </head>
  80. <body>
  81.     <center>
  82. <form action="" method="POST" name="addinfo">
  83.     <p><?php if (!empty($msg)) {?><a style="color: red ;font-size: 20"><?   echo $msg."</a>";}?></p>
  84.     <p>
  85.         <label for="firstName">First Name:</label>
  86.         <input type="text" name="firstname" id="firstName" required>
  87.     </p>
  88.     <p>
  89.         <label for="lastName">Last Name:</label>
  90.         <input type="text" name="lastname" id="lastName" required>
  91.     </p>
  92.     <p>
  93.         <label for="emailAddress">Email Address:</label>
  94.         <input type="email" name="email" id="emailAddress" required>
  95.     </p>
  96.       <p>
  97.         <label for="phone">Phone Nomber:</label>
  98.         <input type="text" name="phone" id="phone" required>
  99.     </p>
  100.     <p>
  101.         <label for="country">Country:</label>
  102.         <input type="text" name="country" id="phone" required>
  103.     </p>
  104.     <input type="submit" value="Submit" name="addinfo">
  105. </form>
  106. </center>
  107. </body>
  108. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement