Email script.

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
Goober
Forum Newbie
Posts: 9
Joined: Wed Jun 25, 2003 10:29 pm
Location: Little Elm, Texas

Email script.

Post by Goober »

Hello,

I'm currently making a really weird email script, there is no need for me to go into great detail, so I won't. I wish to have the contents of the email that is sent in a txt file. Is this possible?

Thanks,
Joe
easyteck
Forum Newbie
Posts: 13
Joined: Thu Jun 05, 2003 12:01 pm
Location: Ecuador
Contact:

weird email

Post by easyteck »

I assume that you know how to get the email data into a string...

So you can use something like:

Code: Select all

<?php
		if ( !file_exists ( $file_name ) )
		{
			$fp = fopen( $file_name, "a" );
			fputs ( $fp, $data_string );
		}
		fclose( $fp );

?>
This creates a new file with the $file_name path + name and inserts the $data_string into!.

cheers!

don pool
User avatar
Goober
Forum Newbie
Posts: 9
Joined: Wed Jun 25, 2003 10:29 pm
Location: Little Elm, Texas

Post by Goober »

hmmm...

Let me rephrase what I ment. I wish to put the contents of a text file into a variable. Is that possible?

I'm also creating a login script. When someone tries to view a page, I wish to check to see if the person is authorized, if not, then be sent directly to the login page, without seeing anything on the page that he was trying to view. This would mean that redirects can't work, because you can see the page you are trying to view for a minimum of one second. Any theories or facts?

Joe
kettle_drum
DevNet Resident
Posts: 1150
Joined: Sun Jul 20, 2003 9:25 pm
Location: West Yorkshire, England

...

Post by kettle_drum »

Simply open the txt file and read the data into a string.

And then for your login. Check to see if the user is logged in before anything is sent to the page and set a varible to true if they are, then just do:

Code: Select all

if($user_logged_in)&#123;
   #
   #this is my secret member area only :)
   #
&#125;else&#123;
   echo "You are being redirected";
   #
   #redirect code
   #
&#125;
As long as you only print the data within the if statement then un-authorised users wont see anything.
User avatar
Goober
Forum Newbie
Posts: 9
Joined: Wed Jun 25, 2003 10:29 pm
Location: Little Elm, Texas

Post by Goober »

You're a genius. You make me feel stupid. I love you.
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

Moved to PHP - Normal -> the PHP - Advanced forum is not intended for 'how to' questons.

Mac
Post Reply