How to run a php script in a rails application -


running on rails 4.2.1 having trouble on include contact_me.php script contact page created in homepage.html.erb file

here's looks like:

  <!-- contact section -->     <section id="contact">         <div class="container">             <div class="row">                 <div class="col-lg-12 text-center">                     <h2 class="section-heading">contact me</h2>                     <h3 class="section-subheading text-muted">shoot me email if see! schedule flexible , door open.</h3>                 </div>             </div>             <div class="row">                 <div class="col-lg-12">                     <form name="sentmessage" id="contactform" novalidate>                         <div class="row">                             <div class="col-md-6">                                 <div class="form-group">                                     <input type="text" class="form-control" placeholder="your name *" id="name" required data-validation-required-message="please enter name.">                                     <p class="help-block text-danger"></p>                                 </div>                                 <div class="form-group">                                     <input type="email" class="form-control" placeholder="your email *" id="email" required data-validation-required-message="please enter email address.">                                     <p class="help-block text-danger"></p>                                 </div>                                 <div class="form-group">                                     <input type="tel" class="form-control" placeholder="your phone *" id="phone" required data-validation-required-message="please enter phone number.">                                     <p class="help-block text-danger"></p>                                 </div>                             </div>                             <div class="col-md-6">                                 <div class="form-group">                                     <textarea class="form-control" placeholder="your message *" id="message" required data-validation-required-message="please enter message."></textarea>                                     <p class="help-block text-danger"></p>                                 </div>                             </div>                             <div class="clearfix"></div>                             <div class="col-lg-12 text-center">                                 <div id="success"></div>                                 <button type="submit" class="btn btn-xl">send message</button>                             </div> 

and here's contact_me.php looks like:

<?php // check empty fields if(empty($_post['name'])        ||    empty($_post['email'])       ||    empty($_post['phone'])       ||    empty($_post['message']) ||    !filter_var($_post['email'],filter_validate_email))    {     echo "no arguments provided!";     return false;    }  $name = $_post['name']; $email_address = $_post['email']; $phone = $_post['phone']; $message = $_post['message'];  // create email , send message $to = 'yourname@yourdomain.com'; // add email address inbetween '' replacing yourname@yourdomain.com - form send message to. $email_subject = "website contact form:  $name"; $email_body = "you have received new message website contact form.\n\n"."here details:\n\nname: $name\n\nemail: $email_address\n\nphone: $phone\n\nmessage:\n$message"; $headers = "from: noreply@yourdomain.com\n"; // email address generated message from. recommend using noreply@yourdomain.com. $headers .= "reply-to: $email_address";  mail($to,$email_subject,$email_body,$headers); return true;             ?> 

any appreciated!!!

to run php script need php support in web server or @ least php-cli installed in web server.

if have kind of support do:

a) publish script public endpoint public/script.php. , send post endpoint.

b) if don't have support public endpoints, write ruby endpoint executes php script a shell command in server side. like: php script.php arguments. need change script little bit receive args, , create ruby public endpoint.

if don't have server supports php, think little bit complicated. recommend port script ruby since easier maintain code written in 1 programming language @ time.


Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - Bypass Geo Redirect for specific directories -

php - .htaccess mod_rewrite for dynamic url which has domain names -