Reputation:
I have created a GAE php app using the Phpstorm but the problem is in the site created. When the site loads it shows everything correct and when I submit the form the site understands the second php file that handles the form as the same as the index.php file. It happened to me with the css file too and chrome described the error as "Resource interpreted as Stylesheet but transferred with MIME type text/html", but i used the style tag I tried to print the received data from the form and it prints the whole index.php file. I think the problem is in the app.yaml file. I have 3 files in my project : app.yaml, index.php, toAction.php .
Note : I use ajax/jquery to connect to php because I don't want php to reload my page. I tried without it, the problem remains the same. The same site works on other web hosting services. I have posted the ajax/jquery code too.
Here is my app.yaml :
application: santamailer
version: 1
runtime: php
api_version: 1
threadsafe: true
handlers:
- url: .*
script: main.php
ajax/jquery code :
$(document).ready(function(){
$('#form').on('submit',function(e) {
$.ajax({
url:'/toAction.php',
data:$(this).serialize(),
type:'POST',
success:function(data){
console.log(data);
$("#error").show().fadeOut(5000);
},
error:function(data){
$("#error").show().fadeOut(5000);
}
});
e.preventDefault();
});
});
toAction.php :
<?php
if(isset($_POST['name'])) {
//print_r($_POST);
$name = $_POST['name'];
$message1 = $_POST['message'];
echo $name;
echo $message1;
}
echo $_POST['name'];
echo $_POST['message1'];
?>
Upvotes: 1
Views: 602
Reputation: 1412
Assuming you have a folder that contains all the css files, say /static/css, you should have the corresponding entry in your app.yaml file
handlers:
- url: /static/css
static_dir: static/css
- url: .*
script: main.php
This way, when you request a css via http://.appspot.com/static/css/foo.css, GAE will serve the correct static file instead of hitting your main.php.
Upvotes: 0