Advertisement
Guest User

Untitled

a guest
Jul 12th, 2017
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.94 KB | None | 0 0
  1. //this is how the code looks for the insert.php file. Every time I run this code I get the same error that my variables are not defined. Below also you have my index page//
  2. $dbhost = 'localhost';
  3. $dbuser = 'root';
  4. $dbpass = 'admin';
  5. $dbname = 'test_emilian';
  6. $con = new mysqli($dbhost, $dbuser, $dbpass, $dbname);
  7. // check the connection
  8. if ($con->connect_errno){
  9. die("Failed to connect to MySQL: (" . $con->connect_errno . ") " . $con->connect_error);
  10. }
  11. $id = mysqli_real_escape_string($con,$_POST['id']);
  12. $first = mysqli_real_escape_string($con,$_POST['first']);
  13. $last = mysqli_real_escape_string($con,$_POST['last']);
  14. $email = mysqli_real_escape_string($con,$_POST['email']);
  15. $mobile = mysqli_real_escape_string($con,$_POST['mobile']);
  16. $date = mysqli_real_escape_string($con,$_POST['date']);
  17. $gender = mysqli_real_escape_string($con,$_POST['gender']);
  18. $cnp = mysqli_real_escape_string($con,$_POST['cnp']);
  19. //made the INSERT duction
  20.  
  21. if (!mysqli_query($con,$AddQuery))
  22. {echo 'Not Inserted';
  23. }else{
  24. echo 'Inserted Successfully';
  25. }
  26. --------------
  27. this is where I have defined the variables
  28. echo "<tr><form action=insert.php method = post>";
  29. echo "<tr>";
  30. echo "<td><input type=text name =first></input></td>";
  31. echo "<td><input type=text name =last></input></td>";
  32. echo "<td><input type=text name =email></input></td>";
  33. echo "<td><input type=text name =mobile></input></td>";
  34. echo "<td><input type=text name =date></input></td>";
  35. echo "<td><input type=text name =gender></input></td>";
  36. echo "<td><input type=text name =cnp></input></td>";
  37. echo "<td><input type=submit name =add value = add>" ."</td</tr>";
  38. echo "</form>";
  39. echo "</table>";
  40. ?>
  41. //at the end is not inserting anything, please help!!
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement