insert - PHP Online

Form of PHP Sandbox

Enter Your PHP code here for testing/debugging in the Online PHP Sandbox. As in the usual PHP files, you can also add HTML, but do not forget to add the tag <?php in the places where the PHP script should be executed.



Your result can be seen below.

Result of php executing





Full code of insert.php

  1. <?php
  2.   $host = "127.0.0.1"; 
  3.     $user = "root"; 
  4.     $pass = ""; 
  5.     $database = "myangularapp";
  6.     $con = mysql_connect($host,$user,$pass);
  7.     if (!$con) {
  8.         die('Could not connect: ' . mysql_error());
  9.     }
  10.     echo 'Connected successfully'; 
  11.    mysql_select_db($database,$con);  
  12.    
  13.    
  14.  
  15. $date= json_decode(file_get_contents("php://input"));
  16. $FName=mysql_real_escape_string($date->FName);
  17. $LName=mysql_real_escape_string($date->LName);
  18. $IDno=mysql_real_escape_string($date->IDno);
  19. $CellNo=mysql_real_escape_string($date->CellNo);
  20. $Password=mysql_real_escape_string($date->Password);
  21.  
  22. mysql_connect("localhost","root","");
  23. mysql_select_db("myangularapp");
  24. mysql_query("INSERT INTO profile (`First_Name`,`Last_Name`,`ID_Number`,`Cell_Number`,`Password`)VALUES('".$FName."','".$LName."','".$IDno."','".$CellNo."','".$Password."',) ");
  25.  
  26.  
  27. ?>
  28.  
File Description
  • insert
  • PHP Code
  • 06 Jul-2020
  • 852 Bytes
You can Share it: