I'm trying to host the files repo_display.php
---> repo_ajax.js
---> repo_action_with_DB.php
--->return to repo_display.php
. This works great on my localhost but once I publish it to the server it doesn't work.
When I submit repo_display.php
form to call AJAX, it transfers me to the server page with the error message "error 403 - forbidden"
I try change permissions of js to 755-700 and it's works unless AJAX , it's forbidden to access repo_action_with_DB.php although I change their permission too ! . I try to access the page without submit the form it's display same problem
403 error forbidden Uncaught ReferenceError: prettyPrint is not defined
repo_display.php
<html>
<head>
<!-- report java script -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script type='text/javascript' src='scripts/repo_ajax.js'> </script>
</head>
<body>
<form action="" id="report">
<legend style="margin-left:40px;">text : </legend>
<p id="success" class="success"></p>
<input id="radio1" name="radio" value="Publisher" type="radio" onclick="radioClicked1()" required>
<input id="radio2" name="radio" value="Journal" type="radio" onclick="radioClicked2()" >
<input name="title1" type="text" required>
<input id="ISSN" name="ISSN" type="text" required>
<input id="url" name="url" type="url" required><br>
<input type="text" value="1" style="display:none;"/>
<input type ="submit" value="Save"/>
</form>
</body>
</html>
repo_ajax.js
$(document).ready(function () {
$("#send").click(function () {
var type;
if (document.getElementById('radio1').checked) {
type = document.getElementById('radio1').value;
}
else if (document.getElementById('radio2').checked) {
type = document.getElementById('radio2').value;
}
var title1 = document.getElementById('title1').value;
var ISSN = document.getElementById('ISSN').value;
var url = document.getElementById('url').value;
if (type == 'Journal' && ISSN == '') {
$("report")[0].checkValidity();
}
else if (type == '' || title1 == '' || url == '') {
// alert("fill all required fields !");
("report")[0].checkValidity();
if (type == 'Journal' && ISSN == '') {
$("report")[0].checkValidity();
}
}
else {
var r = confirm
("Are you sure to send this Report ?");
if (r == true)
{
$.ajax({
type: "GET",
url: "repo_action_with_DB.php",
data: "radio=" + type + "&title1=" + title1 + "&ISSN=" + ISSN + "&url=" + url,
success: function (data) {
if (data == 1)
{
$("#success2").html("Done");
}
else if (data == 2)
{
$("#success").html("Your Report is exist already");
}
else
{
$("#success").html("Faild ,please try again !");
}
}
});
}
}
return false;
});
});
function radioClicked1() {
}
function radioClicked2() {
}
repo_action_with_DB.php
<?php
ob_start();
//------------------Database section------------------------------------------
include('database.php');
//------------------Get the data ------------------------------------------
$title = $_GET['title1'];
$type = $_GET['radio'];
$url = $_GET['url'];
// ----------------------add -----------------------------------
if ($type == "k") {
$IS = $_GET['IS'];
$qry ="SELECT k_name FROM k where ISSN = '".$IS."'";
$result = mysql_query($qry);
if (mysql_num_rows($result) == 1) {
echo '2';
}
else {
$qry1 = "insert into k (`k_name`, `IS`, `URL`, `is_r`) values('" . $title . "','" . $IS . "','" . $url . "',1);";
$result1 = mysql_query($qry1);
if ($result1) {
echo '1';
}
}
}
?>