This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2012-02-28 22:55:34

jji7skyline
Scratcher
Registered: 2010-03-08
Posts: 1000+

PHP help...

This is what I have now. The variables defined at first are variables from a HTML form.

Code:

<?php
    $html = $_POST["html"];
    $to = $_POST["email"];
    $name = $_POST["name"];

    $filename = "$name.html";
    $Content = "$html";
 

    $handle = fopen($filename, 'x+');

    fwrite($handle, $Content);

    fclose($handle);
    echo "Your html document has been processed.";
    
 $subject = "Your HTML file!";
 $body = "Hey there!,\n\nYour requested html file is attached. Thanks for using this service!/nPlease keep in mind that all user created files are deleted daily, so make sure you save your html file in a safe place. /n We hope to see you again soon!";
 
 mail($to, $subject, $body)

?>

Doesn't work...


I don't know why you say goodbye, I say hello!  big_smile

Offline

 

#2 2012-02-29 00:28:46

nathanprocks
Scratcher
Registered: 2011-04-14
Posts: 1000+

Re: PHP help...

jji7skyline wrote:

This is what I have now. The variables defined at first are variables from a HTML form.

Code:

<?php
    $html = $_POST["html"];
    $to = $_POST["email"];
    $name = $_POST["name"];

    $filename = "$name.html";
    $Content = "$html";
 

    $handle = fopen($filename, 'x+');

    fwrite($handle, $Content);

    fclose($handle);
    echo "Your html document has been processed.";
    
 $subject = "Your HTML file!";
 $body = "Hey there!,\n\nYour requested html file is attached. Thanks for using this service!/nPlease keep in mind that all user created files are deleted daily, so make sure you save your html file in a safe place. /n We hope to see you again soon!";
 
 mail($to, $subject, $body)

?>

Doesn't work...

What error does it give you?


http://carrot.cassiedragonandfriends.org/Scratch_Signature/randomsig.php
http://trinary.site40.net/images/scratchrank.php?username=nathanprocks&amp;display=small

Offline

 

#3 2012-02-29 01:05:17

jji7skyline
Scratcher
Registered: 2010-03-08
Posts: 1000+

Re: PHP help...

nathanprocks wrote:

jji7skyline wrote:

This is what I have now. The variables defined at first are variables from a HTML form.

Code:

<?php
    $html = $_POST["html"];
    $to = $_POST["email"];
    $name = $_POST["name"];

    $filename = "$name.html";
    $Content = "$html";
 

    $handle = fopen($filename, 'x+');

    fwrite($handle, $Content);

    fclose($handle);
    echo "Your html document has been processed.";
    
 $subject = "Your HTML file!";
 $body = "Hey there!,\n\nYour requested html file is attached. Thanks for using this service!/nPlease keep in mind that all user created files are deleted daily, so make sure you save your html file in a safe place. /n We hope to see you again soon!";
 
 mail($to, $subject, $body)

?>

Doesn't work...

What error does it give you?

No error, it just doesn't send an email to my email.

Do I need to install some sort of PHP plugin?  hmm


I don't know why you say goodbye, I say hello!  big_smile

Offline

 

#4 2012-02-29 01:14:19

nathanprocks
Scratcher
Registered: 2011-04-14
Posts: 1000+

Re: PHP help...

jji7skyline wrote:

nathanprocks wrote:

jji7skyline wrote:

This is what I have now. The variables defined at first are variables from a HTML form.

Code:

<?php
    $html = $_POST["html"];
    $to = $_POST["email"];
    $name = $_POST["name"];

    $filename = "$name.html";
    $Content = "$html";
 

    $handle = fopen($filename, 'x+');

    fwrite($handle, $Content);

    fclose($handle);
    echo "Your html document has been processed.";
    
 $subject = "Your HTML file!";
 $body = "Hey there!,\n\nYour requested html file is attached. Thanks for using this service!/nPlease keep in mind that all user created files are deleted daily, so make sure you save your html file in a safe place. /n We hope to see you again soon!";
 
 mail($to, $subject, $body)

?>

Doesn't work...

What error does it give you?

No error, it just doesn't send an email to my email.

Do I need to install some sort of PHP plugin?  hmm

You don't need any plugin, i know that much... I haven't actually sent email via PHP though.

One thing I have never seen in PHP syntax before is this:

Code:

    $filename = "$name.html";
    $Content = "$html";

http://carrot.cassiedragonandfriends.org/Scratch_Signature/randomsig.php
http://trinary.site40.net/images/scratchrank.php?username=nathanprocks&amp;display=small

Offline

 

#5 2012-02-29 01:19:13

jji7skyline
Scratcher
Registered: 2010-03-08
Posts: 1000+

Re: PHP help...

nathanprocks wrote:

jji7skyline wrote:

nathanprocks wrote:


What error does it give you?

No error, it just doesn't send an email to my email.

Do I need to install some sort of PHP plugin?  hmm

You don't need any plugin, i know that much... I haven't actually sent email via PHP though.

One thing I have never seen in PHP syntax before is this:

Code:

    $filename = "$name.html";
    $Content = "$html";

All of that works. It's just the mail bit that's the problem...

The first line sets the file name to the value of the variable html and then appends .html. The content of the file is in the second line that just says that it is the content of the variable $html.


I don't know why you say goodbye, I say hello!  big_smile

Offline

 

#6 2012-02-29 01:32:45

nathanprocks
Scratcher
Registered: 2011-04-14
Posts: 1000+

Re: PHP help...

jji7skyline wrote:

nathanprocks wrote:

jji7skyline wrote:


No error, it just doesn't send an email to my email.

Do I need to install some sort of PHP plugin?  hmm

You don't need any plugin, i know that much... I haven't actually sent email via PHP though.

One thing I have never seen in PHP syntax before is this:

Code:

    $filename = "$name.html";
    $Content = "$html";

All of that works. It's just the mail bit that's the problem...

The first line sets the file name to the value of the variable html and then appends .html. The content of the file is in the second line that just says that it is the content of the variable $html.

I thought is was like this:

Code:

    $filename = $name . ".html";
    $Content = $html;

http://carrot.cassiedragonandfriends.org/Scratch_Signature/randomsig.php
http://trinary.site40.net/images/scratchrank.php?username=nathanprocks&amp;display=small

Offline

 

#7 2012-02-29 01:35:04

logiblocs
Scratcher
Registered: 2010-05-05
Posts: 100+

Re: PHP help...

What OS are you on?

Offline

 

#8 2012-02-29 01:36:02

ProgramCAT
Scratcher
Registered: 2011-12-13
Posts: 500+

Re: PHP help...

logiblocs wrote:

What OS are you on?

PHP is OS independent.

Last edited by ProgramCAT (2012-02-29 01:36:33)


Programming is an art...
Goodbye, Scratch. I am leaving because of the exams coming up at our school, though I'll check the forums once or twice a week.

Offline

 

#9 2012-02-29 01:41:36

jji7skyline
Scratcher
Registered: 2010-03-08
Posts: 1000+

Re: PHP help...

ProgramCAT wrote:

logiblocs wrote:

What OS are you on?

PHP is OS independent.

Yes, but if it helps...

I'm on Mac OSX 10.7.3 with Chrome 17.0.963.56.

PHP version 5.3.6


I don't know why you say goodbye, I say hello!  big_smile

Offline

 

#10 2012-02-29 01:42:20

TRocket
Scratcher
Registered: 2009-08-18
Posts: 1000+

Re: PHP help...

is mail() returning true or false?


http://i.imgur.com/1QqnHxQ.png

Offline

 

#11 2012-02-29 01:44:25

jji7skyline
Scratcher
Registered: 2010-03-08
Posts: 1000+

Re: PHP help...

TRocket wrote:

is mail() returning true or false?

True, since it doesn't echo that mailing failed.


I don't know why you say goodbye, I say hello!  big_smile

Offline

 

#12 2012-02-29 06:39:32

scimonster
Community Moderator
Registered: 2010-06-13
Posts: 1000+

Re: PHP help...

You forgot the semicolon after the mail statement.

Also, some minor things: You have /n instead of \n a couple times in the body text. Why not just set $content directly to $_POST["html"]?

Last edited by scimonster (2012-02-29 06:40:51)

Offline

 

#13 2012-02-29 17:41:23

jji7skyline
Scratcher
Registered: 2010-03-08
Posts: 1000+

Re: PHP help...

scimonster wrote:

You forgot the semicolon after the mail statement.

Also, some minor things: You have /n instead of \n a couple times in the body text. Why not just set $content directly to $_POST["html"]?

This is what I have now... thanks for the help, but I still don't get any emails. Are you sure I don't have to make changes on the php.ini file to enable mail function? I'm on a Mac.

Code:

<?php
    $html = $_POST["html"];
    $to = $_POST["email"];
    $name = $_POST["name"];

    $filename = "'.$name.'.html";
 

    $handle = fopen($filename, 'x+');

    fwrite($handle, $html);

    fclose($handle);
    
    echo "Your html document has been processed. </br></br> You will be redirected to your file ($name.html) in 3 seconds. </br></br> We delete all user files from our server daily, so to save your file, please download it by right clicking on the page and choosing 'Save As'.";
    
    
      
    
 $subject = "Your HTML file!";
 $body = "$html";
 
 mail($to, $subject, $body);
 
 echo '<META HTTP-EQUIV="Refresh" Content="3"; URL=http://jji7skyline.dyndns.org/userhtmlfiles/'.$name.'.html">';

    exit; 
?>

I don't know why you say goodbye, I say hello!  big_smile

Offline

 

#14 2012-03-01 04:39:37

scimonster
Community Moderator
Registered: 2010-06-13
Posts: 1000+

Re: PHP help...

You may have to. Does it say it has emails enabled?

Offline

 

#15 2012-03-01 19:32:35

jji7skyline
Scratcher
Registered: 2010-03-08
Posts: 1000+

Re: PHP help...

scimonster wrote:

You may have to. Does it say it has emails enabled?

Can't find anything like that...

Oh well...  tongue


I don't know why you say goodbye, I say hello!  big_smile

Offline

 

Board footer