Ajax not working but why?


#1

Hi
My website is sems1.000webhostapp.com
I want to insert a course name without refreshing the page into the database…
The file names in my website are
insert.php a form to insert the value
ajax.php is where the insertion operation takes place

The code in insert.php is


The code in ajax.php is

<?php $conn=mysqli_connect("localhost","id3581319_srini","srini","id3581319_test"); if (!$conn) { die("Connection failed: " . mysqli_connect_error()); } $sql = "INSERT INTO `programs`(`cid`) VALUES('$_POST['couseid']')"; if(mysqli_query($conn, $sql)) { echo "Your Response has been successfully updated to our database"; } else { echo"Not updated"; } ?>

#2

The insert.php code : if I type it here it disappears… So uploading the pic
[Uploading…]


#3

Did You Include The jQuery library?


#4

Watch out, there is an enormous SQL injection vulnerability in that code. Read more here:


#5

Yes… you can have a look at the code in that picture


#6

Hey @srini

How can I trigger the ajax request in your website? (what button should I click)


#7

Under
sems1.000webhostapp.com/insert.php
There will be only one input text field and a button.
The function which triggers the button is shown in the above picture


#8

Try changing .$ajax to $.ajax in your JS code.