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
Zeceer
Forum Contributor
Posts: 136 Joined: Fri Aug 02, 2002 5:10 am
Location: Norway
Post
by Zeceer » Sun Oct 06, 2002 9:43 am
I got a document before the actual mail script. This document have two hidden variables.
<input name="username" type="hidden" value="<?=$username?>">
<input name="password" type="hidden" value="<?=$password?>">
These variables are sent with the document to this file:
<?php
$to = "
zeceer@hotmail.com ";
$subject = "Order";
$headers = "
zeceer@hotmail.com ";
$body ="
Navn: ".$_POST['navn']."
Post adresse: ".$_POST['postadresse']."
Postnummer: ".$_POST['postnummer']."
Sted: ".$_POST['sted']."
Telefon: ".$_POST['telefon']."
E-mail: ".$_POST['email'];
mail($to,$subject,$body,"From: $headers");
header( "Location: index.php" );
?>
The two variables that are passed is set together so they match a file.
include(users/'.$_POST[username].$_POST[password].'.php');
What i need i something that includes this file in the $body variable of the mail script. So that the body of the mail is that file. Or whats inside the file is printet in the mail. If you know what mean
.
A stupid example just to show what I mean
:
<?php
$to = "
zeceer@hotmail.com ";
$subject = "Order";
$headers = "
zeceer@hotmail.com ";
$body ="
Navn: ".$_POST['navn']."
Post adresse: ".$_POST['postadresse']."
Postnummer: ".$_POST['postnummer']."
Sted: ".$_POST['sted']."
Telefon: ".$_POST['telefon']."
E-mail: ".$_POST['email']
include(users/'.$_POST[username].$_POST[password].'.php');
;
mail($to,$subject,$body,"From: $headers");
header( "Location: index.php" );
?>
The thing is that this file contains information about the user that I need
Takuma
Forum Regular
Posts: 931 Joined: Sun Aug 04, 2002 10:24 am
Location: UK
Contact:
Post
by Takuma » Sun Oct 06, 2002 10:49 am
Why not use fopen and fread?
Code: Select all
<?php
$fp = fopen("users/{$_POSTїusername]}.{$_POSTїpassword]}.php");
$content = fread($fp,filesize("users/{$_POSTїusername]}.{$_POSTїpassword]}.php"));
fclose($fp);
$body .= $fp;
?>
Zeceer
Forum Contributor
Posts: 136 Joined: Fri Aug 02, 2002 5:10 am
Location: Norway
Post
by Zeceer » Mon Oct 07, 2002 10:25 am
Tried your example. Didn't make it work, but it leaded me in the right direction
.
I made this:
<?php
$to = "
zeceer@hotmail.com ";
$subject = "Order";
$headers = "
zeceer@hotmail.com ";
$fp = fopen('brukere/'.$_POST['brukernavn'].$_POST['passord'].'.php', "r");
$body = fpassthru( $fp );
mail($to,$subject,$body,"From: $headers");
?>
It worked 50%
. It prints the file to the browser and everyhing looks fine untill I get the mail. The mail only says "1622" for some reason. What I need is something that put's the text inside of the file in the body of the mail
Zeceer
Forum Contributor
Posts: 136 Joined: Fri Aug 02, 2002 5:10 am
Location: Norway
Post
by Zeceer » Tue Oct 08, 2002 9:51 am
Anyone?
nielsene
DevNet Resident
Posts: 1834 Joined: Fri Aug 16, 2002 8:57 am
Location: Watertown, MA
Post
by nielsene » Tue Oct 08, 2002 9:59 am
fpassthru returnes the number of characters read, so thats why your email's body was 1622. fpassthru displays the file to screen as a side effect which is why it looked good on the browser.
Modifiying Takuma's version
Code: Select all
<?php
$fp = fopen("users/{$_POSTїusername]}.{$_POSTїpassword]}.php");
$content = fread($fp,filesize("users/{$_POSTїusername]}.{$_POSTїpassword]}.php"));
fclose($fp);
$body .= $content; // not $fp!
?>
This should work. If it doesn't tell us why and we can take it from there.
Zeceer
Forum Contributor
Posts: 136 Joined: Fri Aug 02, 2002 5:10 am
Location: Norway
Post
by Zeceer » Wed Oct 09, 2002 6:18 am
Why is this error popping up?
Parse error: parse error, unexpected T_VARIABLE in D:\inc shop\tilkassen3.php on line 4
Heres the script:
<?php
$fp = fopen("brukere/".$_POST['brukernavn']$_POST['passord'].".php");
$content = fread($fp,filesize("brukere/".$_POST['brukernavn']$_POST['passord'].".php"));
fclose($fp);
$body = "$content";
print("$body");
?>
[/quote]
twigletmac
Her Royal Site Adminness
Posts: 5371 Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK
Post
by twigletmac » Wed Oct 09, 2002 7:21 am
You need to add a period (.) between your variables in order to concenate them:
Code: Select all
$_POSTї'brukernavn'].$_POSTї'passord']
instead of
Code: Select all
$_POSTї'brukernavn']$_POSTї'passord']
Mac
Zeceer
Forum Contributor
Posts: 136 Joined: Fri Aug 02, 2002 5:10 am
Location: Norway
Post
by Zeceer » Wed Oct 09, 2002 7:40 am
I had it that way before, but then I get this pretty lady
:
Warning: Wrong parameter count for fopen() in D:\inc shop\tilkassen3.php on line 4
Warning: fread(): supplied argument is not a valid File-Handle resource in D:\inc shop\tilkassen3.php on line 5
Warning: fclose(): supplied argument is not a valid File-Handle resource in D:\inc shop\tilkassen3.php on line 6
Zeceer
Forum Contributor
Posts: 136 Joined: Fri Aug 02, 2002 5:10 am
Location: Norway
Post
by Zeceer » Wed Oct 09, 2002 7:46 am
Stupid ME! Done that mistake before
. Thanx!
Zeceer
Forum Contributor
Posts: 136 Joined: Fri Aug 02, 2002 5:10 am
Location: Norway
Post
by Zeceer » Wed Oct 09, 2002 8:53 am
When I send this to a hotmail account it works great. It displays the text as HTML. But by sending it to some other account it only display the HTML codes as basic text. What I want is to display the mail as HTML. In other mail programs than Hotmail. Is there i code I must include so the mail client displays it as HTML??
<br>
Navn: gg
<br>
Post adresse: dg
<br>
Postnummer: dgq
<br>
Sted: fgdg
<br>
Telefon: gdfgws
<br>
E-mail: grg
<html>
<body>
<table width="650" border="0" cellspacing="0" align="center"
bgcolor="#ffffff"><tr><td width="200" valign="left"><font color="#000000" size="1"
face="Verdana, Arial, Helvetica, sans-serif">Whey Tech 3000g</font></td><td
width="200" align="right"><font color="#000000" size="1" face="Verdana, Arial,
Helvetica, sans-serif"><strong>1</strong></font></td><td width="200"
align="right"><font color="#000000" size="1" face="Verdana, Arial, Helvetica,
sans-serif"><strong>729,-</strong></font></td></tr></table><br><?php $pris = $pris +
"729"; ?>
<table width="650" border="0" cellspacing="0" align="center"
bgcolor="#ffffff"><tr><td width="200" valign="left"><font color="#000000" size="1"
face="Verdana, Arial, Helvetica, sans-serif">Whey Tech 1500g</font></td><td
width="200" align="right"><font color="#000000" size="1" face="Verdana, Arial,
Helvetica, sans-serif"><strong>1</strong></font></td><td width="200"
align="right"><font color="#000000" size="1" face="Verdana, Arial, Helvetica,
sans-serif"><strong>429,-</strong></font></td></tr></table><br><?php $pris = $pris +
"429"; ?>
<table width="650" border="0" cellspacing="0" align="center"
bgcolor="#ffffff"><tr><td width="200" valign="left"><font color="#000000" size="1"
face="Verdana, Arial, Helvetica, sans-serif">Whey Tech 750g</font></td><td
width="200" align="right"><font color="#000000" size="1" face="Verdana, Arial,
Helvetica, sans-serif"><strong>1</strong></font></td><td width="200"
align="right"><font color="#000000" size="1" face="Verdana, Arial, Helvetica,
sans-serif"><strong>279,-</strong></font></td></tr></table><br><?php $pris = $pris +
"279"; ?>
</body>
</html>
Zeceer
Forum Contributor
Posts: 136 Joined: Fri Aug 02, 2002 5:10 am
Location: Norway
Post
by Zeceer » Wed Oct 09, 2002 1:16 pm
Thanx, that worked fine. The only problem is that i can't set who the mail is from. I've tried some solutions but didn't get it.
Heres my mail() line.
mail($to,$subject,$body,"Content-type: text/html; charset=iso-8859-1\r\n");
twigletmac
Her Royal Site Adminness
Posts: 5371 Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK
Post
by twigletmac » Thu Oct 10, 2002 1:55 am
You can add a from line in your headers (check the docs on the mail function for what it should look like) but that may not work depending on whether you are using windows or *nix but the manual page will explain more.
Mac
Zeceer
Forum Contributor
Posts: 136 Joined: Fri Aug 02, 2002 5:10 am
Location: Norway
Post
by Zeceer » Thu Oct 10, 2002 7:37 am
I tried that, but didn't get it. Gonna read the whole manual and then try.