Jump to content

[SOLVED] how to execute php email form without opening the browser


Recommended Posts

Hi,

my formulation may not be correct but there seems to be no answers online. I have a simple email contact form that is executed from flash website (photographybymiro.com) and I would like to not have any browser window open when the sendMail.php script is called through POST. Is there a way to execute php "silently"?

Thanks for any help,

Zbynek

I think he wants to have a completely server side program that will run independantly of itself, like a calendar or timer that will notify you when a certain point is reached, regardless of if the page is loaded or not, am I right?

I have a contact form and when I click submit it calls a php script and opens a separate browser window, in that window I can put an answer like "Thank you for your request" or something, the catch is that I already have a Thank you page in my flash site and I don't need to have that separate browser window open. It should be more clear when testing it on contact page at www.photographybymiro.com.

 

I found this but I am still lost:

"I think you're looking at an issue with the PHP script, and not Flash. You need to tell your PHP script to return a variable instead of printing HTML. "

 

thanks,

Zbynek

If the function to send the email is in the php page, then you might try require() or include(). require(), as far as I can tell, won't print any html that the php page renders, just reads it as though the code was part of the page you are on, include will do the same, but will also render any html that the included php page creates.  Remember, though, that php is a line-by-line language, so if you have a variable that your emailer needs to use, you have to set that variable before you call up the emailer php file.

 

Hope this helps.

unfortunately I am calling php from flash site by

 

gatherForm.send("send_mail.php", "_blank", "POST")

 

and this is my simple php script that seems to work ok exept that it opens a separate browser window:

 

<?php

//create short variable names

$name=$_POST['visitor_name'];

$email=$_POST['visitor_email'];

$subject=$_POST['visitor_subject'];

$message=$_POST['visitor_comments'];

$name=trim($name);

$email=trim($email);

$subject=StripSlashes($subject);

//lets make the message more explaining

$message="Name: $name\nEmail: $email\nComments: " . StripSlashes($message);

 

//email address where to mail the content of form to

$toaddress=$_POST['email_to'];

 

mail($toaddress,$subject,$message,"From: $name <$email>");

//clear the variables

$name='';

$email='';

$subject='';

$message='';

echo "I don't want this page open!!!!";

?>

Ahhhh, that'll do it, I know nothing about flash, but when I saw that, I realized.  _blank and _new tell it to open in a new window, just like an anchor link in a page: <a href="" target="_blank"></a>, so there you have it, that should work.

"" and "_blank" gives the same problem, it looks like it depends on php print function and how php script is called, this seems to work:

 

in Flash:

//this will be used to get variable back from php script
recVars.txt = "";

//I don't know what this is for
var result_lv:LoadVars = new LoadVars();

gatherForm.sendAndLoad("send_mail.php", result_lv, "POST");

 

in PHP:

<?php
//create short variable names
$name=$_POST['visitor_name'];
$email=$_POST['visitor_email'];
$subject=$_POST['visitor_subject'];
$message=$_POST['visitor_comments'];
$name=trim($name);
$email=trim($email);
$subject=StripSlashes($subject);
//lets make the message more explaining
$message="Name: $name\nEmail: $email\nComments: " . StripSlashes($message);

//email address where to mail the content of form to
$toaddress=$_POST['email_to'];

mail($toaddress,$subject,$message,"From: $name <$email>");
//clear the variables
$name='';
$email='';
$subject='';
$message='';
//echo "I don't want this page open!!!!";	

//now it si sending back variable recVars to flash, this will prevent opening the separate browser window
print "recVars=OK";
?>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.