zzdobrusky Posted March 11, 2007 Share Posted March 11, 2007 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 Quote Link to comment https://forums.phpfreaks.com/topic/42262-solved-how-to-execute-php-email-form-without-opening-the-browser/ Share on other sites More sharing options...
trq Posted March 11, 2007 Share Posted March 11, 2007 In order to run the script you will need to request the page somehow. You might try curl, otherwise, you'll need to be a little clearer in your description of exactly what it is your wanting to achieve. Quote Link to comment https://forums.phpfreaks.com/topic/42262-solved-how-to-execute-php-email-form-without-opening-the-browser/#findComment-205019 Share on other sites More sharing options...
HaLo2FrEeEk Posted March 11, 2007 Share Posted March 11, 2007 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? Quote Link to comment https://forums.phpfreaks.com/topic/42262-solved-how-to-execute-php-email-form-without-opening-the-browser/#findComment-205023 Share on other sites More sharing options...
zzdobrusky Posted March 11, 2007 Author Share Posted March 11, 2007 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 Quote Link to comment https://forums.phpfreaks.com/topic/42262-solved-how-to-execute-php-email-form-without-opening-the-browser/#findComment-205029 Share on other sites More sharing options...
HaLo2FrEeEk Posted March 11, 2007 Share Posted March 11, 2007 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. Quote Link to comment https://forums.phpfreaks.com/topic/42262-solved-how-to-execute-php-email-form-without-opening-the-browser/#findComment-205033 Share on other sites More sharing options...
zzdobrusky Posted March 11, 2007 Author Share Posted March 11, 2007 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!!!!"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/42262-solved-how-to-execute-php-email-form-without-opening-the-browser/#findComment-205035 Share on other sites More sharing options...
trq Posted March 11, 2007 Share Posted March 11, 2007 Remove the _blank parameter from your flash call. gatherForm.send("send_mail.php", "", "POST") Nothing to do with php. Quote Link to comment https://forums.phpfreaks.com/topic/42262-solved-how-to-execute-php-email-form-without-opening-the-browser/#findComment-205037 Share on other sites More sharing options...
HaLo2FrEeEk Posted March 11, 2007 Share Posted March 11, 2007 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. Quote Link to comment https://forums.phpfreaks.com/topic/42262-solved-how-to-execute-php-email-form-without-opening-the-browser/#findComment-205040 Share on other sites More sharing options...
zzdobrusky Posted March 12, 2007 Author Share Posted March 12, 2007 "" 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"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/42262-solved-how-to-execute-php-email-form-without-opening-the-browser/#findComment-205102 Share on other sites More sharing options...
trq Posted March 12, 2007 Share Posted March 12, 2007 Does that mean your issue is resolved? Please mark the thread as such. (Bottom left) Quote Link to comment https://forums.phpfreaks.com/topic/42262-solved-how-to-execute-php-email-form-without-opening-the-browser/#findComment-205105 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.