Advertisement
Khurrum

insert.php

May 10th, 2017
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.32 KB | None | 0 0
  1. <?php
  2.  
  3. $servername = "localhost:8889";
  4. $username = "root";
  5. $password = "root";
  6. $dbname = "Forms";
  7.  
  8. // Create connection
  9. $conn = new mysqli($servername, $username, $password, $dbname);
  10. // Check connection
  11. if ($conn->connect_error) {
  12.     die("Connection failed: " . $conn->connect_error);
  13. }
  14.  
  15. $sql1 = "INSERT INTO Users1 (username, password, firstname, surname, address, postcode, email, phone, birthday, birthmonth, birthyear, gender)
  16. VALUES ('$_POST[username]','$_POST[password]','$_POST[firstname]','$_POST[surname]','$_POST[address]','$_POST[postcode]','$_POST[email]','$_POST[phone]','$_POST[birthday]','$_POST[birthmonth]','$_POST[birthyear]','$_POST[gender]')";
  17.  
  18. $sql2 = "INSERT INTO Currencies1 (email, camount, currency)
  19. VALUES ('$_POST[email]','$_POST[camount]','$_POST[currency]')";
  20.  
  21. // First connection for user data
  22. if ($conn->query($sql1) === TRUE) {
  23.     echo "Victorrry!";
  24. } else {
  25.     echo "Error: " . $sql . "<br>" . $conn->error;
  26. }
  27.  
  28. // Second connection for currencies
  29. if ($conn->query($sql2) === TRUE) {
  30.     echo "";
  31. } else {
  32.     echo "Error: " . $sql . "<br>" . $conn->error;
  33. }
  34.  
  35. $chkbox = $_POST['chk'];
  36. $txtbox = $_POST['camount'];
  37. $country = $_POST['currency'];
  38.  
  39. foreach($txtbox as $a => $b)
  40.   echo "$chkbox[$a]  -  $camount[$a]  -  $currency[$a] <br />";
  41.  
  42. $conn->close();
  43. ?>
  44.  
  45. <?php
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement