Israel

Israel

  • 696
  • 1.3k
  • 217.1k

Doesnt save into my PHP

May 9 2021 3:04 PM
Hi,
I do create normally a table into my database and wrote codes to save in. Curiously when I cliick to save datas its looks like datas have been saved. But when I see into my database nothing appear. My table still blank. Other thing very strange is when I delete its works. Just not for saving.
Please see my codes:
 
  1. <?php  
  2. $link=mysqli_connect("localhost:3307","root","");  
  3. mysqli_select_db($link,"rhumanos");  
  4. ?>  
  5.   
  6. <html>  
  7. <title>Untitled Document</title>  
  8. <body>  
  9. <form name="form1" action="" method="post">  
  10. <table>  
  11. <tr>  
  12. <td>Enter Name</td>  
  13. <td><input type="text" name="name"></td>  
  14. </tr>  
  15. <tr>  
  16. <td>Enter City</td>  
  17. <td><input type="text" name="city"></td>  
  18. </tr>  
  19. <tr>  
  20. <td colspan="2" align="center"><input type="submit" name="submit1" value="insert">  
  21. <input type="submit" name="submit2" value="delete">  
  22. </td>  
  23. </tr>  
  24. </table>  
  25. </form>  
  26.   
  27. <?php  
  28. if(isset($_POST["submit1"]))  
  29. {  
  30.     mysqli_query($link,"insert into name_city values('$_POST[name]','$_POST[city]')");  
  31. }  
  32.   
  33. if(isset($_POST["submit2"]))  
  34. {  
  35.     mysqli_query($link,"delete from name_city where name='$_POST[name]'");  
  36. }  
  37.   
  38. ?>  
  39.   
  40. </body>  
  41. </html>  
 

Answers (1)