Skip to content
Loading
It's saving very well without bug but datas doesnt appear into DB  
  •   
  •   
  •   
  • server.php
    1. // initialize variables  
    2. $name = "";  
    3. $address = "";  
    4. $id = 0;  
    5. // connect to database  
    6. $db = mysqli_connect('localhost:3307','root','','crud1');  
    7. // if save button is clicked  
    8. if (isset($_POST['save'])) {  
    9. $name = $_POST['name'];  
    10. $address = $_POST['address'];  
    11.   
    12. $query = "INSERT INTO info (name, address) VALUES ('$name', '$address')";  
    13. mysqli_query($db$query);  
    14. $_SESSION['msg'] = "Address saved";  
    15. header('location: index.php'); // redirect to index page after inserting  
    16. }  
    17. // retrieve records  
    18. $results = mysqli_query($db"SELECT * FROM info");  
    19. ?>  
    style.css
    1. body {  
    2. font-size19px;  
    3. }  
    4. table{  
    5. width50px;  
    6. margin30px auto;  
    7. border-collapsecollapse;  
    8. text-alignleft;  
    9. }  
    10. tr{  
    11. border-bottom1px solid #cbcbcb;  
    12. }  
    13.   
    14. th, td{  
    15. bordernone;  
    16. height30px;  
    17. padding2px;  
    18. }  
    19. tr:hover{  
    20. background#f5f5f5;  
    21. }  
    22. form{  
    23. width45%;  
    24. margin50px auto;  
    25. text-alignleft;  
    26. padding20px;  
    27. border1px solid #bbbbbb;  
    28. border-radius: 5px;  
    29. }  
    30. .input-group{  
    31. margin10px 0px 10px 0px;  
    32. }  
    33. .input-group label{  
    34. displayblock;  
    35. text-alignleft;  
    36. margin3px;  
    37. }  
    38. .input-group input{  
    39. height30px;  
    40. width93%;  
    41. padding5px 10px;  
    42. font-size16px;  
    43. border-radius: 5px;  
    44. border1px solid gray;  
    45. }  
    46. .btn {  
    47. padding10px;  
    48. font-size15px;  
    49. colorwhite;  
    50. background#5F9EA0;  
    51. bordernone;  
    52. border-radius: 5px;  
    53. }.msg{  
    54. margin30px auto;  
    55. padding10px;  
    56. border-radius: 5px;  
    57. color#3c763d;  
    58. background#dff0d8;  
    59. width50%;  
    60. text-aligncenter;  
    61. }  

    4 Replies

    Know the answer? Post it — somebody with the same question will find it here.