0

I have a Gmail Sponsored Promotion Ad which has a form. The form collects basic data like name and email, then redirects the user to a page where they can download a pdf file and sends the form data to my email via a php file (submit.php). However, I can't host submit.php in the same server as the form, Google doesn't allow any other files other than index.html and the images, and no script either, only vanilla HTML. All I can do is link to an external action.

This works when the submit.php file is hosted on the same server as the form, but not when they are hosted in different servers - I don't get the email with the data from the form. Why is that? And what can I do to circumvent it? ps. I don't know any PHP

Form hosted in http://google.com/

<form action=" http://me.com/submit.php" method="post">
<input type='email' name='email'></input>
<input type='submit'></input>
</form>

submit.php hosted in http://me.com

<?php
$email = $_POST['email'];
$msg .= $email;

if (mail ($email_sender, $email_subject, nl2br($msg), $email_headers)){
?>
 <script language= "JavaScript">
 location.href="http://file.pdf"; </script>
?>
vexalist
  • 67
  • 6

1 Answers1

0

The Problem is not easy to solve ... Here you can find some information about the reason cross-domain-form-posting

One way could be: In submit.php (when i understand you right) you have access of POST/GET data, if so .. write a function to send the data to a foreign domain, eg. use CURL functions or use a DB

Community
  • 1
  • 1
donald123
  • 5,638
  • 3
  • 26
  • 23
  • I'm not sure I understand what you're saying. Sorry, I don't know anything about PHP, or DB, I'm a front-end person. Where should I add this function, to the PHP file? Because I can't have any scripts on the form, unfortunately, google won't allow it. – vexalist Jan 29 '15 at 13:43