PHP not working in google app engine with app.yaml -
i'm making html website using google app engine. have contact form in index.html calls on send_mail.php send email. problem when click on send asks me download php. there way fix this. here's app.yaml file
application: engineapp version: 1 runtime: php api_version: 1 handlers: - url: / static_files: assets/index.html upload: assets/index.html - url: / static_dir: assets the code of html file normal contact form
<form class="form" id="form1" action="send_mail.php" method="post"> <p> <input name="name" type="text" id="name" /> </p> <p> <input name="email" type="text" id="email" /> </p> <p> <input name="email" type="text" id="sub" /> </p> <p> <textarea name="text" id="comments" placeholder="الرسالة"></textarea> </p> <input type="submit" value="ارسل" id="button-pink"/> </font> </form> and php file looks this
<?php /* first bit sets email address want form submitted to. need change value valid email address can access. */ $webmaster_email = "xyz@hotmail.com"; /* bit sets urls of supporting pages. if change names of of pages, need change values here. */ $index = "index.html"; $error_page = "error_message.html"; $thankyou_page = "thank_you.html"; /* next bit loads form field data variables. if add form field, need add here. */ $name = $_request ['name'] $email_address = $_request['email'] ; $sub = $_request ['sub'] $comments = $_request['comments'] ; /* following function checks email injection. specifically, checks carriage returns - typically used spammers inject cc list. */ function isinjected($str) { $injections = array('(\n+)', '(\r+)', '(\t+)', '(%0a+)', '(%0d+)', '(%08+)', '(%09+)' ); $inject = join('|', $injections); $inject = "/$inject/i"; if(preg_match($inject,$str)) { return true; } else { return false; } } // if user tries access script directly, redirect them feedback form, if (!isset($_request['email_address'])) { header( "location: $index" ); } // if form fields empty, redirect error page. elseif (empty($email_address) || empty($comments)) { header( "location: $error_page" ); } // if email injection detected, redirect error page. elseif ( isinjected($email_address) ) { header( "location: $error_page" ); } // if passed previous tests, send email redirect thank page. else { mail( "$webmaster_email", "contact form", "subject: $sub", $comments, "from: $email_address" ); header( "location: $thankyou_page" ); } ?>
you need url handler send_mail.php, like:
- url: /(.+\.php)$ script: assets/\1 that serves somefile.php scripts. or, hard code 1 script, as:
- url: /send_mail.php script: assets/send_mail.php
Comments
Post a Comment