Help with php

  • stev_ro
  • Beginner
  • Beginner
  • User avatar
  • Posts: 61
  • Loc: ro

Post 3+ Months Ago

I have a template that it supposes to write into an external .txt file trough php.
But it doesn't work. Can anyone tell me what's wrong about it?
Here you will find the source file http://www.box.net/public/y9191zrmkl

Here is the php code:

<?php

$userName = $_POST['userName'];
$userEmail = $_POST['userEmail'];

$add = $userName . "<" . $userEmail . ">;";
$open = fopen('emails.txt', 'a');
$write = fwrite($open, $add);

if($write) { /
echo "&verify=success&";
} else {
echo "&verify=fail&";

}


?>

And here is the as:

var serverLang:String = "php";
var myVars:LoadVars = new LoadVars();
myVars.onLoad = function() {
if (myVars.verify == "success") {
status_txt.text = "data Saved";
} else {
status_txt.text = "Failed Save";
}
};
submit_btn.onRelease = function() {

if (!email_txt.length || email_txt.indexOf("@") == -1 || email_txt.indexOf(".") == -1) {
status_txt.text = "Invalid Email.";

} else if (!name_txt.length) {
status_txt.text = "Missing Name";
} else {
myVars.userName = name_txt;
myVars.userEmail = email_txt;
myVars.sendAndLoad("WriteToFile.php",myVars,"POST");
}
};


Thnx in advance!
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • IceCold
  • Guru
  • Guru
  • User avatar
  • Posts: 1254
  • Loc: Ro

Post 3+ Months Ago

change in your flash, everywhere you have email_txt and name_txt make sure they're followed by .text -> if (!email_txt.text.length ...

Next thing ... since you echo only one var in php, you don't need to really start it with &, but that's not a mistake.
Publish your fla for html,
next make sure you have the swf, html and the php script in the same location and you call it from browser, on a webserver. Otherwise it won't work :D
Either you have installed apache+php on your local computer, or you place the files on a server with php support.
then: http://servername.com/WriteToFile.html
or : localhost/path/WriteToFile.html
I tested it and it works with the proper modifications i pointed above.
  • stev_ro
  • Beginner
  • Beginner
  • User avatar
  • Posts: 61
  • Loc: ro

Post 3+ Months Ago

Am facut modificarile pe care mi leai spus si am pus fisierele pe web
http://www.stevtest.50megs.com
Dar tot nu merge. (am uploadat pe site fisierul index.html writetofile.swf si writetofile.php si am pus chiar si fisierul email.txt)
E posibil ca siteu pe care am pus fisierele sa nu aiba suport php ? Ca nu gasesc pe nicaieri informatii despre asta.
  • IceCold
  • Guru
  • Guru
  • User avatar
  • Posts: 1254
  • Loc: Ro

Post 3+ Months Ago

english please. This isn't a RO forum and other users might have the same problem as you and they won't understand romanian.
this is what i get when accessing: http://www.stevtest.50megs.com/WriteToFile.php

Forbidden
Remote Host: [82.78.244.23]

You do not have permission to access http://www.stevtest.50megs.com/WriteToFile.php

Data files must be stored on the same site they are linked from.

Thank you for using 50megs

So it doesn't support php. Try asp instead.
Create a new file, name it save.asp, and add this code inside it:
Code: [ Select ]
<%
function WriteToFile(FileName, Contents, Append)
on error resume next

if Append = true then
  iMode = 8
else
  iMode = 2
end if
set oFs = server.createobject("Scripting.FileSystemObject")
set oTextFile = oFs.OpenTextFile(FileName, iMode, True)
oTextFile.Write Contents
oTextFile.Close
set oTextFile = nothing
set oFS = nothing

end function

strUser = Request.Form("userName")
strMail = Request.Form("userEmail")

WriteToFile "email.txt", strUser , False
WriteToFile "email.txt", strMail , True

Response.Write("user="&strUser )
Response.Write("email="&strMail )

%>
  1. <%
  2. function WriteToFile(FileName, Contents, Append)
  3. on error resume next
  4. if Append = true then
  5.   iMode = 8
  6. else
  7.   iMode = 2
  8. end if
  9. set oFs = server.createobject("Scripting.FileSystemObject")
  10. set oTextFile = oFs.OpenTextFile(FileName, iMode, True)
  11. oTextFile.Write Contents
  12. oTextFile.Close
  13. set oTextFile = nothing
  14. set oFS = nothing
  15. end function
  16. strUser = Request.Form("userName")
  17. strMail = Request.Form("userEmail")
  18. WriteToFile "email.txt", strUser , False
  19. WriteToFile "email.txt", strMail , True
  20. Response.Write("user="&strUser )
  21. Response.Write("email="&strMail )
  22. %>

then upload it on the server and call it in a browser, and see if it works.
  • stev_ro
  • Beginner
  • Beginner
  • User avatar
  • Posts: 61
  • Loc: ro

Post 3+ Months Ago

I have tried with the .asp file but it still doesn't work. It pop's up the same error.

I installed apache2triad on my local computer an when i try to open the next links it says to me that :
Access forbidden!

You don't have permission to access the requested object. It is either read-protected or not readable by the server.

If you think this is a server error, please contact the webmaster.
Error 403
localhost
03/06/07 03:55:21
Apache/2.2.0 (Win32) PHP/5.1.2

the addresses that i have tried to open are: http://localhost/J:/probe/write/writetofile.asp
http://localhost/J:/probe/write/writetofile.php
  • IceCold
  • Guru
  • Guru
  • User avatar
  • Posts: 1254
  • Loc: Ro

Post 3+ Months Ago

that looks like a misused path .
In order to work, copy your folder which contains the data in:
c:\appserv\www\
probably your path is different, just see or google where you have to place your test files.
Then, is just : localhost/foldername/writetofile.php
  • stev_ro
  • Beginner
  • Beginner
  • User avatar
  • Posts: 61
  • Loc: ro

Post 3+ Months Ago

Thnx IceCold ... you were write....i had to copy my files in the folder c:/a2t/htdocs -> this is the root directory
  • bigdog
  • Born
  • Born
  • bigdog
  • Posts: 4

Post 3+ Months Ago

Hi all

I'm very new to Flash 8 and need something really simple. I want to create one input text field where users can type their message and then submit it to my email, using PHP.

So far I've tried everything and nothing is working.

My actionscript is:

on(release){

messager.loadVariables("email.php","POST");

}

where messager is the movieclip instance as well as the name of the input text field variable.

My PHP script is:

<?php

$to = $_POST["bigdog@hotmail.com"];

$message = $_POST["message"];

mail($to, $message);

?>

When I upload to the web and click the submit button, nothing happens. I'm sure this is a fairly simple action but I just can't get it to work.

Please help me with this.

Many thanks in advance. Apologies if this post has been sent twice.
  • IceCold
  • Guru
  • Guru
  • User avatar
  • Posts: 1254
  • Loc: Ro

Post 3+ Months Ago

noooo, not you again with the same post. Once is ok, twice is accident ... but three times is indeed evil :P

Post Information

  • Total Posts in this topic: 9 posts
  • Users browsing this forum: No registered users and 9 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.