FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » CLP - ON TOPIC! - Need PHP form email help, Please!
Show: Today's Messages :: Polls :: Message Navigator
Switch to threaded view of this topic Create a new topic Submit Reply
CLP - ON TOPIC! - Need PHP form email help, Please! [message #173104] Mon, 21 March 2011 22:31 Go to next message
Tim is currently offline  Tim
Messages: 13
Registered: March 2011
Karma: 0
Junior Member
I have a form in which the user can upload a photo, which is then sent
to me along with the other data on the form. I have formatted the data
into an HTML email with the photo attached. I would like the photo
embedded in a specific place on the page, but I have not found the code
to do this and don't know enough about it to write the code myself.

It would also be nice to be able to have the photo, once uploaded, to
replace the upload button and associated text on the page in the place
I want the photo to appear. Then maybe send the page as is as an HTML
email?

Any help would be appreciated.
Re: CLP - ON TOPIC! - Need PHP form email help, Please! [message #173108 is a reply to message #173104] Tue, 22 March 2011 03:02 Go to previous messageGo to next message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma: 0
Senior Member
On 3/21/2011 6:31 PM, Tim wrote:
> I have a form in which the user can upload a photo, which is then sent
> to me along with the other data on the form. I have formatted the data
> into an HTML email with the photo attached. I would like the photo
> embedded in a specific place on the page, but I have not found the code
> to do this and don't know enough about it to write the code myself.
>
> It would also be nice to be able to have the photo, once uploaded, to
> replace the upload button and associated text on the page in the place
> I want the photo to appear. Then maybe send the page as is as an HTML
> email?
>
> Any help would be appreciated.

And your PHP question is?

Sounds more like you need to learn how to format the email correctly,
which is an email/HTML question. Try a more appropriate newsgroup
(maybe alt.html - I don't know).

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
Re: CLP - ON TOPIC! - Need PHP form email help, Please! [message #173110 is a reply to message #173108] Tue, 22 March 2011 04:03 Go to previous messageGo to next message
Tim is currently offline  Tim
Messages: 13
Registered: March 2011
Karma: 0
Junior Member
In article <im93gr$8bp$1(at)news(dot)eternal-september(dot)org>, Jerry Stuckle
<jstucklex(at)attglobal(dot)net> wrote:

> On 3/21/2011 6:31 PM, Tim wrote:
>> I have a form in which the user can upload a photo, which is then sent
>> to me along with the other data on the form. I have formatted the data
>> into an HTML email with the photo attached. I would like the photo
>> embedded in a specific place on the page, but I have not found the code
>> to do this and don't know enough about it to write the code myself.
>>
>> It would also be nice to be able to have the photo, once uploaded, to
>> replace the upload button and associated text on the page in the place
>> I want the photo to appear. Then maybe send the page as is as an HTML
>> email?
>>
>> Any help would be appreciated.
>
> And your PHP question is?
>
> Sounds more like you need to learn how to format the email correctly,
> which is an email/HTML question. Try a more appropriate newsgroup
> (maybe alt.html - I don't know).

The problem is not formatting the email, the problem is getting the php
to take the image, whose name I can't know, and embedding it into the
email. The php code constructs the email using my template and the data
input by the user. Since I don't know the name of the file, and it is
stored in a temp directory, I need the code that will place the image
where I want it. In other words: it needs to convert the filename into
the appropriate "<img src" html.

I'm sure this seems very simple to all the code gurus, but I have found
nothing that even comes close to this in any of the tutorials I have
read.

I have thought about saving the images to a permanent directory and
changing the name to make the html easier, but there are several
reasons to keep the original name and I don't want to keep the images
on the server. So I need some php to assemble the html using unknown
values.

So far I have the image attached to the email, but not embedded. My
attempt at embedding it resulted in the filename being displayed where
the image should be. So it is not just a matter of html formatting.
Re: CLP - ON TOPIC! - Need PHP form email help, Please! [message #173111 is a reply to message #173110] Tue, 22 March 2011 04:58 Go to previous messageGo to next message
The Natural Philosoph is currently offline  The Natural Philosoph
Messages: 993
Registered: September 2010
Karma: 0
Senior Member
Tim wrote:
> In article <im93gr$8bp$1(at)news(dot)eternal-september(dot)org>, Jerry Stuckle
> <jstucklex(at)attglobal(dot)net> wrote:
>
>> On 3/21/2011 6:31 PM, Tim wrote:
>>> I have a form in which the user can upload a photo, which is then sent
>>> to me along with the other data on the form. I have formatted the data
>>> into an HTML email with the photo attached. I would like the photo
>>> embedded in a specific place on the page, but I have not found the code
>>> to do this and don't know enough about it to write the code myself.
>>>
>>> It would also be nice to be able to have the photo, once uploaded, to
>>> replace the upload button and associated text on the page in the place
>>> I want the photo to appear. Then maybe send the page as is as an HTML
>>> email?
>>>
>>> Any help would be appreciated.
>> And your PHP question is?
>>
>> Sounds more like you need to learn how to format the email correctly,
>> which is an email/HTML question. Try a more appropriate newsgroup
>> (maybe alt.html - I don't know).
>
> The problem is not formatting the email, the problem is getting the php
> to take the image, whose name I can't know, and embedding it into the
> email. The php code constructs the email using my template and the data
> input by the user. Since I don't know the name of the file, and it is
> stored in a temp directory, I need the code that will place the image
> where I want it. In other words: it needs to convert the filename into
> the appropriate "<img src" html.
>
> I'm sure this seems very simple to all the code gurus, but I have found
> nothing that even comes close to this in any of the tutorials I have
> read.
>
> I have thought about saving the images to a permanent directory and
> changing the name to make the html easier, but there are several
> reasons to keep the original name and I don't want to keep the images
> on the server. So I need some php to assemble the html using unknown
> values.
>
> So far I have the image attached to the email, but not embedded. My
> attempt at embedding it resulted in the filename being displayed where
> the image should be. So it is not just a matter of html formatting.

Its a bitch actually, and half the time it doesn't work if the target is
Outlook based.

Get yourself a copy of that benighted program and embed a (small)
picture in it, send it to yourself and dump the source.

The <IMG src=" bit refers to the attachment, but there are conventions
to follow, which I did work out once, but it was a bit to trashy in the
end to be worth finishing properly hence I have no code to offer.
Re: CLP - ON TOPIC! - Need PHP form email help, Please! [message #173113 is a reply to message #173104] Tue, 22 March 2011 09:13 Go to previous messageGo to next message
Andy is currently offline  Andy
Messages: 8
Registered: March 2002
Karma: 0
Junior Member
"Tim" <batwzrd(at)hotmail(dot)com> wrote in message
news:210320111731440609%batwzrd(at)hotmail(dot)com...
> I have a form in which the user can upload a photo, which is then sent
> to me along with the other data on the form. I have formatted the data
> into an HTML email with the photo attached. I would like the photo
> embedded in a specific place on the page, but I have not found the code
> to do this and don't know enough about it to write the code myself.
>
> It would also be nice to be able to have the photo, once uploaded, to
> replace the upload button and associated text on the page in the place
> I want the photo to appear. Then maybe send the page as is as an HTML
> email?
>
> Any help would be appreciated.
>

Hi Tim,

Have a look at phpmailer...

http://phpmailer.worxware.com/

....if you can generate an html page that looks like the email page you would
like to email, then phpmailer can wrap it all up, embed the images and send
it as email.

Hope this helps


Andy
Re: CLP - ON TOPIC! - Need PHP form email help, Please! [message #173117 is a reply to message #173110] Tue, 22 March 2011 10:56 Go to previous messageGo to next message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma: 0
Senior Member
On 3/22/2011 12:03 AM, Tim wrote:
> In article<im93gr$8bp$1(at)news(dot)eternal-september(dot)org>, Jerry Stuckle
> <jstucklex(at)attglobal(dot)net> wrote:
>
>> On 3/21/2011 6:31 PM, Tim wrote:
>>> I have a form in which the user can upload a photo, which is then sent
>>> to me along with the other data on the form. I have formatted the data
>>> into an HTML email with the photo attached. I would like the photo
>>> embedded in a specific place on the page, but I have not found the code
>>> to do this and don't know enough about it to write the code myself.
>>>
>>> It would also be nice to be able to have the photo, once uploaded, to
>>> replace the upload button and associated text on the page in the place
>>> I want the photo to appear. Then maybe send the page as is as an HTML
>>> email?
>>>
>>> Any help would be appreciated.
>>
>> And your PHP question is?
>>
>> Sounds more like you need to learn how to format the email correctly,
>> which is an email/HTML question. Try a more appropriate newsgroup
>> (maybe alt.html - I don't know).
>
> The problem is not formatting the email, the problem is getting the php
> to take the image, whose name I can't know, and embedding it into the
> email. The php code constructs the email using my template and the data
> input by the user. Since I don't know the name of the file, and it is
> stored in a temp directory, I need the code that will place the image
> where I want it. In other words: it needs to convert the filename into
> the appropriate "<img src" html.
>
> I'm sure this seems very simple to all the code gurus, but I have found
> nothing that even comes close to this in any of the tutorials I have
> read.
>
> I have thought about saving the images to a permanent directory and
> changing the name to make the html easier, but there are several
> reasons to keep the original name and I don't want to keep the images
> on the server. So I need some php to assemble the html using unknown
> values.
>
> So far I have the image attached to the email, but not embedded. My
> attempt at embedding it resulted in the filename being displayed where
> the image should be. So it is not just a matter of html formatting.

Well, you've got the image in the email; all you need is to get it to
work with the html. You already have the file name, etc - or you
wouldn't have been able to attack it to the email.

So, what is the result you want? Not something nebulous such as
"convert the filename into the appropriate "<img src" html" - EXACTLY
what do you want? I.e. if I send you example.jpg, what does the
resultant raw html in your email look like?

Once you can answer that, your PHP code is easy.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
Re: CLP - ON TOPIC! - Need PHP form email help, Please! [message #173124 is a reply to message #173117] Tue, 22 March 2011 23:11 Go to previous messageGo to next message
Tim is currently offline  Tim
Messages: 13
Registered: March 2011
Karma: 0
Junior Member
In article <im9v9g$jj9$1(at)news(dot)eternal-september(dot)org>, Jerry Stuckle
<jstucklex(at)attglobal(dot)net> wrote:

> On 3/22/2011 12:03 AM, Tim wrote:
>> In article<im93gr$8bp$1(at)news(dot)eternal-september(dot)org>, Jerry Stuckle
>> <jstucklex(at)attglobal(dot)net> wrote:
>>
>>> On 3/21/2011 6:31 PM, Tim wrote:
>>>> I have a form in which the user can upload a photo, which is then sent
>>>> to me along with the other data on the form. I have formatted the data
>>>> into an HTML email with the photo attached. I would like the photo
>>>> embedded in a specific place on the page, but I have not found the code
>>>> to do this and don't know enough about it to write the code myself.
>>>>
>>>> It would also be nice to be able to have the photo, once uploaded, to
>>>> replace the upload button and associated text on the page in the place
>>>> I want the photo to appear. Then maybe send the page as is as an HTML
>>>> email?
>>>>
>>>> Any help would be appreciated.
>>>
>>> And your PHP question is?
>>>
>>> Sounds more like you need to learn how to format the email correctly,
>>> which is an email/HTML question. Try a more appropriate newsgroup
>>> (maybe alt.html - I don't know).
>>
>> The problem is not formatting the email, the problem is getting the php
>> to take the image, whose name I can't know, and embedding it into the
>> email. The php code constructs the email using my template and the data
>> input by the user. Since I don't know the name of the file, and it is
>> stored in a temp directory, I need the code that will place the image
>> where I want it. In other words: it needs to convert the filename into
>> the appropriate "<img src" html.
>>
>> I'm sure this seems very simple to all the code gurus, but I have found
>> nothing that even comes close to this in any of the tutorials I have
>> read.
>>
>> I have thought about saving the images to a permanent directory and
>> changing the name to make the html easier, but there are several
>> reasons to keep the original name and I don't want to keep the images
>> on the server. So I need some php to assemble the html using unknown
>> values.
>>
>> So far I have the image attached to the email, but not embedded. My
>> attempt at embedding it resulted in the filename being displayed where
>> the image should be. So it is not just a matter of html formatting.
>
> Well, you've got the image in the email; all you need is to get it to
> work with the html. You already have the file name, etc - or you
> wouldn't have been able to attack it to the email.
>
> So, what is the result you want? Not something nebulous such as
> "convert the filename into the appropriate "<img src" html" - EXACTLY
> what do you want? I.e. if I send you example.jpg, what does the
> resultant raw html in your email look like?
>
> Once you can answer that, your PHP code is easy.

OK. To be more clear, I have a form in which the user fills in some
information and uploads a headshot. the email is formatted the same as
the form except I want the image to appear next to the information
instead of attached. The info is down the left side and the image on
the right. There is more info under all of that.

I used Forms to Go to create the original form handler. The id for the
image is $FTGheadshot. Simply placing that into the html output section
(like this: headshot : $FTGheadshot<br />) just gets me the file's name
in the space for the image.

Looking at the code, now that I have learned a little more about it, I
am thinking that I should put this: $_FILES['headshot']['tmp_name']
there instead. Would that be right? Isn't that the part that connects
the actual file with the FTG assigned variable?

Previously it said: $FTGheadshot = $_FILES['headshot']['name'];

Am I on the right track with this?
Re: CLP - ON TOPIC! - Need PHP form email help, Please! [message #173125 is a reply to message #173113] Tue, 22 March 2011 23:16 Go to previous messageGo to next message
&lt;nospam is currently offline  &lt;nospam
Messages: 1
Registered: March 2011
Karma: 0
Junior Member
In article <4LZhp.79092$or1(dot)46990(at)newsfe26(dot)ams2>, Andy
<andy(at)NOSPAMmanyplay(dot)com> wrote:

> "Tim" <batwzrd(at)hotmail(dot)com> wrote in message
> news:210320111731440609%batwzrd(at)hotmail(dot)com...
>> I have a form in which the user can upload a photo, which is then sent
>> to me along with the other data on the form. I have formatted the data
>> into an HTML email with the photo attached. I would like the photo
>> embedded in a specific place on the page, but I have not found the code
>> to do this and don't know enough about it to write the code myself.
>>
>> It would also be nice to be able to have the photo, once uploaded, to
>> replace the upload button and associated text on the page in the place
>> I want the photo to appear. Then maybe send the page as is as an HTML
>> email?
>>
>> Any help would be appreciated.
>>
>
> Hi Tim,
>
> Have a look at phpmailer...
>
> http://phpmailer.worxware.com/
>
> ...if you can generate an html page that looks like the email page you would
> like to email, then phpmailer can wrap it all up, embed the images and send
> it as email.
>
> Hope this helps
>
>
> Andy
>
I got phpmailer, but it didn't look like it would solve my problem. I
created an html page that looks the way I want, but without the image.
Since I don't know what the name of the image is I can only put a space
holder. So I need to know how to get the code to place the reference to
the image in that place.

Would something like this do it?

<img src=$_FILES['headshot']['name']>
Re: CLP - ON TOPIC! - Need PHP form email help, Please! [message #173126 is a reply to message #173124] Wed, 23 March 2011 00:08 Go to previous messageGo to next message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma: 0
Senior Member
On 3/22/2011 7:11 PM, Tim wrote:
> In article<im9v9g$jj9$1(at)news(dot)eternal-september(dot)org>, Jerry Stuckle
> <jstucklex(at)attglobal(dot)net> wrote:
>
>> On 3/22/2011 12:03 AM, Tim wrote:
>>> In article<im93gr$8bp$1(at)news(dot)eternal-september(dot)org>, Jerry Stuckle
>>> <jstucklex(at)attglobal(dot)net> wrote:
>>>
>>>> On 3/21/2011 6:31 PM, Tim wrote:
>>>> > I have a form in which the user can upload a photo, which is then sent
>>>> > to me along with the other data on the form. I have formatted the data
>>>> > into an HTML email with the photo attached. I would like the photo
>>>> > embedded in a specific place on the page, but I have not found the code
>>>> > to do this and don't know enough about it to write the code myself.
>>>> >
>>>> > It would also be nice to be able to have the photo, once uploaded, to
>>>> > replace the upload button and associated text on the page in the place
>>>> > I want the photo to appear. Then maybe send the page as is as an HTML
>>>> > email?
>>>> >
>>>> > Any help would be appreciated.
>>>>
>>>> And your PHP question is?
>>>>
>>>> Sounds more like you need to learn how to format the email correctly,
>>>> which is an email/HTML question. Try a more appropriate newsgroup
>>>> (maybe alt.html - I don't know).
>>>
>>> The problem is not formatting the email, the problem is getting the php
>>> to take the image, whose name I can't know, and embedding it into the
>>> email. The php code constructs the email using my template and the data
>>> input by the user. Since I don't know the name of the file, and it is
>>> stored in a temp directory, I need the code that will place the image
>>> where I want it. In other words: it needs to convert the filename into
>>> the appropriate "<img src" html.
>>>
>>> I'm sure this seems very simple to all the code gurus, but I have found
>>> nothing that even comes close to this in any of the tutorials I have
>>> read.
>>>
>>> I have thought about saving the images to a permanent directory and
>>> changing the name to make the html easier, but there are several
>>> reasons to keep the original name and I don't want to keep the images
>>> on the server. So I need some php to assemble the html using unknown
>>> values.
>>>
>>> So far I have the image attached to the email, but not embedded. My
>>> attempt at embedding it resulted in the filename being displayed where
>>> the image should be. So it is not just a matter of html formatting.
>>
>> Well, you've got the image in the email; all you need is to get it to
>> work with the html. You already have the file name, etc - or you
>> wouldn't have been able to attack it to the email.
>>
>> So, what is the result you want? Not something nebulous such as
>> "convert the filename into the appropriate"<img src" html" - EXACTLY
>> what do you want? I.e. if I send you example.jpg, what does the
>> resultant raw html in your email look like?
>>
>> Once you can answer that, your PHP code is easy.
>
> OK. To be more clear, I have a form in which the user fills in some
> information and uploads a headshot. the email is formatted the same as
> the form except I want the image to appear next to the information
> instead of attached. The info is down the left side and the image on
> the right. There is more info under all of that.
>
> I used Forms to Go to create the original form handler. The id for the
> image is $FTGheadshot. Simply placing that into the html output section
> (like this: headshot : $FTGheadshot<br />) just gets me the file's name
> in the space for the image.
>
> Looking at the code, now that I have learned a little more about it, I
> am thinking that I should put this: $_FILES['headshot']['tmp_name']
> there instead. Would that be right? Isn't that the part that connects
> the actual file with the FTG assigned variable?
>
> Previously it said: $FTGheadshot = $_FILES['headshot']['name'];
>
> Am I on the right track with this?

No, you're not, and creating an html email with embedded images is not
easy - but it is NOT a PHP question.

First of all you need to figure out how to create the email in the first
place. Then you can worry about the PHP code needed to create it.

Get a working page in your favorite email program first and see what the
source looks like. That will help you.

Right now you're trying to create something with no idea what you're
creating. You can keep using trial and error methods and maybe get
there. Or you can do as I first suggested and find out how to create
the email you want first, ignoring any language considerations.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
Re: CLP - ON TOPIC! - Need PHP form email help, Please! [message #173130 is a reply to message #173113] Wed, 23 March 2011 18:05 Go to previous messageGo to next message
Tim is currently offline  Tim
Messages: 13
Registered: March 2011
Karma: 0
Junior Member
In article <4LZhp.79092$or1(dot)46990(at)newsfe26(dot)ams2>, Andy
<andy(at)NOSPAMmanyplay(dot)com> wrote:

> "Tim" <batwzrd(at)hotmail(dot)com> wrote in message
> news:210320111731440609%batwzrd(at)hotmail(dot)com...
>> I have a form in which the user can upload a photo, which is then sent
>> to me along with the other data on the form. I have formatted the data
>> into an HTML email with the photo attached. I would like the photo
>> embedded in a specific place on the page, but I have not found the code
>> to do this and don't know enough about it to write the code myself.
>>
>> It would also be nice to be able to have the photo, once uploaded, to
>> replace the upload button and associated text on the page in the place
>> I want the photo to appear. Then maybe send the page as is as an HTML
>> email?
>>
>> Any help would be appreciated.
>>
>
> Hi Tim,
>
> Have a look at phpmailer...
>
> http://phpmailer.worxware.com/
>
> ...if you can generate an html page that looks like the email page you would
> like to email, then phpmailer can wrap it all up, embed the images and send
> it as email.
>
> Hope this helps
>
>
> Andy
>
Actually, I think that is really the issue. if I could get the code to
make the page, sending it as an email wouldn't be a problem.

I also find it strange, and very frustrating, that I seem to have to
become a php expert just to make this one form page behave the way I
want. There are no references or tutorials that I have found that
address this, and apparently no one wants to help other than chastising
me for not already knowing everything.

Could no one just say "it would work better to make the html as a page
separate from the email"? I even suggested as much in my original post,
yet no one acknowledged it.
Re: CLP - ON TOPIC! - Need PHP form email help, Please! [message #173131 is a reply to message #173130] Wed, 23 March 2011 18:11 Go to previous messageGo to next message
Tim Streater is currently offline  Tim Streater
Messages: 328
Registered: September 2010
Karma: 0
Senior Member
In article <230320111305395422%batwzrd(at)hotmail(dot)com>,
Tim <batwzrd(at)hotmail(dot)com> wrote:

> I also find it strange, and very frustrating, that I seem to have to
> become a php expert just to make this one form page behave the way I
> want. There are no references or tutorials that I have found that
> address this, and apparently no one wants to help other than chastising
> me for not already knowing everything

:-) I sympathise - I've also met this attitude too.

But yes, you'll have to become *enough* of an expert in PHP. This is no
different than with any other technology.

--
Tim

"That excessive bail ought not to be required, nor excessive fines imposed,
nor cruel and unusual punishments inflicted" -- Bill of Rights 1689
Re: CLP - ON TOPIC! - Need PHP form email help, Please! [message #173132 is a reply to message #173104] Wed, 23 March 2011 18:25 Go to previous messageGo to next message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma: 0
Senior Member
On 3/23/2011 1:57 PM, Tim wrote:
> In article<imbdle$g3p$1(at)news(dot)eternal-september(dot)org>, Jerry Stuckle
> <jstucklex(at)attglobal(dot)net> wrote:
>
>> On 3/22/2011 7:11 PM, Tim wrote:
>>> In article<im9v9g$jj9$1(at)news(dot)eternal-september(dot)org>, Jerry Stuckle
>>> <jstucklex(at)attglobal(dot)net> wrote:
>>>
>>>> On 3/22/2011 12:03 AM, Tim wrote:
>>>> > In article<im93gr$8bp$1(at)news(dot)eternal-september(dot)org>, Jerry Stuckle
>>>> > <jstucklex(at)attglobal(dot)net> wrote:
>>>> >
>>>> >> On 3/21/2011 6:31 PM, Tim wrote:
>>>> >>> I have a form in which the user can upload a photo, which is then sent
>>>> >>> to me along with the other data on the form. I have formatted the data
>>>> >>> into an HTML email with the photo attached. I would like the photo
>>>> >>> embedded in a specific place on the page, but I have not found the code
>>>> >>> to do this and don't know enough about it to write the code myself.
>>>> >>>
>>>> >>> It would also be nice to be able to have the photo, once uploaded, to
>>>> >>> replace the upload button and associated text on the page in the place
>>>> >>> I want the photo to appear. Then maybe send the page as is as an HTML
>>>> >>> email?
>>>> >>>
>>>> >>> Any help would be appreciated.
>>>> >>
>>>> >> And your PHP question is?
>>>> >>
>>>> >> Sounds more like you need to learn how to format the email correctly,
>>>> >> which is an email/HTML question. Try a more appropriate newsgroup
>>>> >> (maybe alt.html - I don't know).
>>>> >
>>>> > The problem is not formatting the email, the problem is getting the php
>>>> > to take the image, whose name I can't know, and embedding it into the
>>>> > email. The php code constructs the email using my template and the data
>>>> > input by the user. Since I don't know the name of the file, and it is
>>>> > stored in a temp directory, I need the code that will place the image
>>>> > where I want it. In other words: it needs to convert the filename into
>>>> > the appropriate "<img src" html.
>>>> >
>>>> > I'm sure this seems very simple to all the code gurus, but I have found
>>>> > nothing that even comes close to this in any of the tutorials I have
>>>> > read.
>>>> >
>>>> > I have thought about saving the images to a permanent directory and
>>>> > changing the name to make the html easier, but there are several
>>>> > reasons to keep the original name and I don't want to keep the images
>>>> > on the server. So I need some php to assemble the html using unknown
>>>> > values.
>>>> >
>>>> > So far I have the image attached to the email, but not embedded. My
>>>> > attempt at embedding it resulted in the filename being displayed where
>>>> > the image should be. So it is not just a matter of html formatting.
>>>>
>>>> Well, you've got the image in the email; all you need is to get it to
>>>> work with the html. You already have the file name, etc - or you
>>>> wouldn't have been able to attack it to the email.
>>>>
>>>> So, what is the result you want? Not something nebulous such as
>>>> "convert the filename into the appropriate"<img src" html" - EXACTLY
>>>> what do you want? I.e. if I send you example.jpg, what does the
>>>> resultant raw html in your email look like?
>>>>
>>>> Once you can answer that, your PHP code is easy.
>>>
>>> OK. To be more clear, I have a form in which the user fills in some
>>> information and uploads a headshot. the email is formatted the same as
>>> the form except I want the image to appear next to the information
>>> instead of attached. The info is down the left side and the image on
>>> the right. There is more info under all of that.
>>>
>>> I used Forms to Go to create the original form handler. The id for the
>>> image is $FTGheadshot. Simply placing that into the html output section
>>> (like this: headshot : $FTGheadshot<br />) just gets me the file's name
>>> in the space for the image.
>>>
>>> Looking at the code, now that I have learned a little more about it, I
>>> am thinking that I should put this: $_FILES['headshot']['tmp_name']
>>> there instead. Would that be right? Isn't that the part that connects
>>> the actual file with the FTG assigned variable?
>>>
>>> Previously it said: $FTGheadshot = $_FILES['headshot']['name'];
>>>
>>> Am I on the right track with this?
>>
>> No, you're not, and creating an html email with embedded images is not
>> easy - but it is NOT a PHP question.
>>
>> First of all you need to figure out how to create the email in the first
>> place. Then you can worry about the PHP code needed to create it.
>>
>> Get a working page in your favorite email program first and see what the
>> source looks like. That will help you.
>>
>> Right now you're trying to create something with no idea what you're
>> creating. You can keep using trial and error methods and maybe get
>> there. Or you can do as I first suggested and find out how to create
>> the email you want first, ignoring any language considerations.
>
> I looked at an email with images both attached and embedded: the same
> images in both. The line that placed the image inline looks like this:
>
> <IMG=20
> id=3DMA2.1289279864 border=3D0=20
> =
> src=3D"cid:4EDBE5C8B2CC44F8ADDD6F853B321989@desktop619"=20
> width=3D480 height=3D604=20
> =
> DATASIZE=3D"144908">
>
> Where "cid:4EDBE5C8B2CC44F8ADDD6F853B321989@desktop619" is the Content
> ID. Obviously this is something that is compiled by the email program
> when the email is sent. Since HTML can not create itself, I need some
> code to do it.
>
> I have created the email, as I said, and it works perfectly other than
> this image issue. The source for the emails from this form look like
> this:
>
> --FTG_BOUNDRY
> Content-Type: text/html; charset="UTF-8"
> Content-Transfer-Encoding: base64
>
> PGh0bWw+CjxoZWFkPgo8dGl0bGU+PC90aXRsZT4KPC9oZWFkPgo8Ym9keT4KPHRhYmxlIHdp
> ZHRo
> PSI4MDAiIGJvcmRlcj0iMCIgY2VsbHNwYWNpbmc9IjIiIGNlbGxwYWRkaW5nPSIxMCI+PHRy
> Pgo8
> dGQgd2lkdGg9MzUwPkZpcnN0IE5hbWUgOiBUaW08YnI+PGJyIC8+Ckxhc3QgTmFtZSA6IExh
> d3Nv
> bjxiciAvPjxiciAvPgpBZGRyZXNzIDogMjM3OTUgSW93YSBSZC48YnIgLz48YnIgLz4KQ2l0
> eSA6
> IExlYmFub24KU3RhdGUgOiBNTwpaSVAgOiA2NTUzNjxiciAvPjxiciAvPgpNYWluIENvbnRh
> Y3Qg
> OiBjZWxsbnVtPGJyIC8+PGJyIC8+CkhvbWUgTnVtYmVyIDogNDE3LTUzMi04NDc4PGJyIC8+
> PGJy
> IC8+CkNlbGwgUGhvbmUgTnVtYmVyIDogNDE3LTY1MC04NDA2PGJyIC8+PGJyIC8+Cldvcmsg
> TnVt
> YmVyIDogNDE3IDUzMi04NDc4PGJyIC8+PGJyIC8+CkZheCBOdW1iZXIgOiA0MTcgNTMyLTg0
> Nzg8
> YnIgLz48YnIgLz4KRW1haWwgQWRkcmVzcyA6IGJhdHd6cmRAaG90bWFpbC5jb208YnIgLz48
> YnIg
> Lz48L3RkPgo8dGQ+MDAwMS5qcGc8L3RkPjwvdHI+PC90YWJsZT48aHI+Cjx0YWJsZSB3aWR0
> aD0i
> ODAwIiBib3JkZXI9IjAiIGNlbGxzcGFjaW5nPSIyIiBjZWxscGFkZGluZz0iMTAiPjx0cj48
> dGQg
> d2lkdGg9MzkwPgpCaXJ0aGRheSA6IDEyLzA4LzE5NzA8YnIgLz48YnIgLz4KSSBhbSBvdmVy
> MTg8
> YnIgLz48YnIgLz4KR2VuZGVyIDogTWFsZTxiciAvPjxiciAvPgpSYWNlIDogd2hpdGU8L3Rk
> Pgo8
> dGQ+SGVpZ2h0IDogNicxIjxiciAvPjxiciAvPgpXZWlnaHQgOiAyMTA8YnIgLz48YnIgLz4K
> SGFp
> ciBDb2xvciA6IGJyb3duPGJyIC8+PGJyIC8+CkV5ZSBDb2xvciA6IGhhemVsPC90ZD48L3Ry
> Pjwv
> dGFibGU+PGhyPgo8dGFibGUgd2lkdGg9IjgwMCIgYm9yZGVyPSIwIiBjZWxsc3BhY2luZz0i
> MiIg
> Y2VsbHBhZGRpbmc9IjEwIj48dHI+PHRkIHdpZHRoPTM5MD4KQWdlIFJhbmdlIDogMjUgCnRv
> IDog
> NDU8YnIgLz48YnIgLz4KTmVjayBTaXplIDogMTc8YnIgLz48YnIgLz4KV2Fpc3QgU2l6ZSA6
> IDM2
> PGJyIC8+PGJyIC8+Ckluc2VhbSA6IDM0PGJyIC8+PGJyIC8+ClNsZWV2ZSA6IDxiciAvPjxi
> ciAv
> PgpTaGlydCBTaXplIDogeGw8YnIgLz48YnIgLz4KU3VpdCBTaXplIDogPC90ZD4KPHRkPkJ1
> c3Qg
> OiA8YnIgLz4KSGlwcyA6IDxiciAvPjxiciAvPgpEcmVzcyBTaXplIDogPGJyIC8+PGJyIC8+
> ClNo
> b2UgU2l6ZSA6IDEwLjU8YnIgLz48YnIgLz4KUmluZyBTaXplIDogMTA8YnIgLz48YnIgLz4K
> R2xv
> dmUgU2l6ZSA6IGw8L3RkPjwvdHI+PC90YWJsZT48aHI+Cjx0YWJsZSB3aWR0aD0iODAwIiBi
> b3Jk
> ZXI9IjAiIGNlbGxzcGFjaW5nPSIyIiBjZWxscGFkZGluZz0iMTAiPjx0cj48dGQ+CldpbGxp
> bmcg
> dG8gYXBwZWFyIGluIHVuZGVyIGNsb3RoZXM/IDogCldpbGxpbmcgdG8gYXBwZWFyIHRvcGxl
> c3M/
> IDogPGJyIC8+CldpbGxpbmcgdG8gZG8gZnVsbCBmcm9udGFsIG51ZGl0eT8gOiAgb3IgClJl
> YXIg
> OiA8YnIgLz48L3RkPjwvdHI+PC90YWJsZT4KPC9ib2R5Pgo8L2h0bWw+Cg==
>
> Which doesn't help me in the slightest. There is also no Content ID
> statement in the code that creates this email.
>
> Since the best suggestion I have received amounts to "figure it out
> yourself" I guess I will just have to do without it the way I want.
> Obviously, if I could figure it out myself I wouldn't be here.
>
> So lets forget about the email. How about just generating a new web
> page with the image where I want it. Is that any easier?

None of this has ANYTHING to do with PHP. As I've told you before -
create the proper HTML to place the image where you want that. No PHP
needed at all. And it's still not a PHP question.

You need to completely forget about PHP and get the HTML (and email)
right. Then the PHP (or Perl or ASP or whatever you use to code it)
becomes simple.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
Re: CLP - ON TOPIC! - Need PHP form email help, Please! [message #173133 is a reply to message #173130] Wed, 23 March 2011 18:26 Go to previous messageGo to next message
Michael Vilain is currently offline  Michael Vilain
Messages: 88
Registered: September 2010
Karma: 0
Member
In article <230320111305395422%batwzrd(at)hotmail(dot)com>,
Tim <batwzrd(at)hotmail(dot)com> wrote:

> In article <4LZhp.79092$or1(dot)46990(at)newsfe26(dot)ams2>, Andy
> <andy(at)NOSPAMmanyplay(dot)com> wrote:
>
>> "Tim" <batwzrd(at)hotmail(dot)com> wrote in message
>> news:210320111731440609%batwzrd(at)hotmail(dot)com...
>>> I have a form in which the user can upload a photo, which is then sent
>>> to me along with the other data on the form. I have formatted the data
>>> into an HTML email with the photo attached. I would like the photo
>>> embedded in a specific place on the page, but I have not found the code
>>> to do this and don't know enough about it to write the code myself.
>>>
>>> It would also be nice to be able to have the photo, once uploaded, to
>>> replace the upload button and associated text on the page in the place
>>> I want the photo to appear. Then maybe send the page as is as an HTML
>>> email?
>>>
>>> Any help would be appreciated.
>>>
>>
>> Hi Tim,
>>
>> Have a look at phpmailer...
>>
>> http://phpmailer.worxware.com/
>>
>> ...if you can generate an html page that looks like the email page you
>> would
>> like to email, then phpmailer can wrap it all up, embed the images and send
>> it as email.
>>
>> Hope this helps
>>
>>
>> Andy
>>
> Actually, I think that is really the issue. if I could get the code to
> make the page, sending it as an email wouldn't be a problem.
>
> I also find it strange, and very frustrating, that I seem to have to
> become a php expert just to make this one form page behave the way I
> want. There are no references or tutorials that I have found that
> address this, and apparently no one wants to help other than chastising
> me for not already knowing everything.
>
> Could no one just say "it would work better to make the html as a page
> separate from the email"? I even suggested as much in my original post,
> yet no one acknowledged it.

Not so strange in my view as your requirements are rather specific. If
you accepted what existing packages do "out of the box" then you won't
have to learn php to customize your form. It's just in the nature of
the beast, IMO.

The php email packages deal specifically with how to send a variety of
email types from within php. You want to _embed_ a graphic in an email
body which requires you to learn how to encode create your own in-line
attachment and encode them rather than let a package do it for you. If
this is beyond your skill level, hire someone or change the requirements.

--
DeeDee, don't press that button! DeeDee! NO! Dee...
[I filter all Goggle Groups posts, so any reply may be automatically ignored]
Re: CLP - ON TOPIC! - Need PHP form email help, Please! [message #173134 is a reply to message #173104] Wed, 23 March 2011 18:45 Go to previous messageGo to next message
Tim Streater is currently offline  Tim Streater
Messages: 328
Registered: September 2010
Karma: 0
Senior Member
In article <230320111257235633%batwzrd(at)hotmail(dot)com>,
Tim <batwzrd(at)hotmail(dot)com> wrote:

> In article <imbdle$g3p$1(at)news(dot)eternal-september(dot)org>, Jerry Stuckle
> <jstucklex(at)attglobal(dot)net> wrote:

>> No, you're not, and creating an html email with embedded images is not
>> easy - but it is NOT a PHP question.
>>
>> First of all you need to figure out how to create the email in the first
>> place. Then you can worry about the PHP code needed to create it.
>>
>> Get a working page in your favorite email program first and see what the
>> source looks like. That will help you.
>>
>> Right now you're trying to create something with no idea what you're
>> creating. You can keep using trial and error methods and maybe get
>> there. Or you can do as I first suggested and find out how to create
>> the email you want first, ignoring any language considerations.
>
> I looked at an email with images both attached and embedded: the same
> images in both.

Yes, and you'll have to learn how an e-mail is structured. Try looking
at these RFCs:

RFC 5322 (Internet Message Format), and RFCs 2045, 2046, 2047, 2048,
2049, (MIME), and 2183. You'll need to find which bits you need for your
particular situation.

> The line that placed the image inline looks like this:
>
> <IMG=20
> id=3DMA2.1289279864 border=3D0=20
> =
> src=3D"cid:4EDBE5C8B2CC44F8ADDD6F853B321989@desktop619"=20
> width=3D480 height=3D604=20
> =
> DATASIZE=3D"144908">

Yes, that's encoded using quoted-printable (e.g., =20 is a space).

> Where "cid:4EDBE5C8B2CC44F8ADDD6F853B321989@desktop619" is the Content
> ID. Obviously this is something that is compiled by the email program
> when the email is sent. Since HTML can not create itself, I need some
> code to do it.
>
> I have created the email, as I said, and it works perfectly other than
> this image issue. The source for the emails from this form look like
> this:
>
> --FTG_BOUNDRY
> Content-Type: text/html; charset="UTF-8"
> Content-Transfer-Encoding: base64
>
> PGh0bWw+CjxoZWFkPgo8dGl0bGU+PC90aXRsZT4KPC9oZWFkPgo8Ym9keT4KPHRhYmxlIHdp
> ZHRo
> PSI4MDAiIGJvcmRlcj0iMCIgY2VsbHNwYWNpbmc9IjIiIGNlbGxwYWRkaW5nPSIxMCI+PHRy
> Pgo8

[snip]

This is an email "part", encoded in base-64. Why is it thus encoded -
who is doing that?

--
Tim

"That excessive bail ought not to be required, nor excessive fines imposed,
nor cruel and unusual punishments inflicted" -- Bill of Rights 1689
Re: CLP - ON TOPIC! - Need PHP form email help, Please! [message #173135 is a reply to message #173104] Wed, 23 March 2011 19:08 Go to previous messageGo to next message
The Natural Philosoph is currently offline  The Natural Philosoph
Messages: 993
Registered: September 2010
Karma: 0
Senior Member
Tim wrote:
> In article <imbdle$g3p$1(at)news(dot)eternal-september(dot)org>, Jerry Stuckle
> <jstucklex(at)attglobal(dot)net> wrote:
>
>> On 3/22/2011 7:11 PM, Tim wrote:
>>> In article<im9v9g$jj9$1(at)news(dot)eternal-september(dot)org>, Jerry Stuckle
>>> <jstucklex(at)attglobal(dot)net> wrote:
>>>
>>>> On 3/22/2011 12:03 AM, Tim wrote:
>>>> > In article<im93gr$8bp$1(at)news(dot)eternal-september(dot)org>, Jerry Stuckle
>>>> > <jstucklex(at)attglobal(dot)net> wrote:
>>>> >
>>>> >> On 3/21/2011 6:31 PM, Tim wrote:
>>>> >>> I have a form in which the user can upload a photo, which is then sent
>>>> >>> to me along with the other data on the form. I have formatted the data
>>>> >>> into an HTML email with the photo attached. I would like the photo
>>>> >>> embedded in a specific place on the page, but I have not found the code
>>>> >>> to do this and don't know enough about it to write the code myself.
>>>> >>>
>>>> >>> It would also be nice to be able to have the photo, once uploaded, to
>>>> >>> replace the upload button and associated text on the page in the place
>>>> >>> I want the photo to appear. Then maybe send the page as is as an HTML
>>>> >>> email?
>>>> >>>
>>>> >>> Any help would be appreciated.
>>>> >> And your PHP question is?
>>>> >>
>>>> >> Sounds more like you need to learn how to format the email correctly,
>>>> >> which is an email/HTML question. Try a more appropriate newsgroup
>>>> >> (maybe alt.html - I don't know).
>>>> > The problem is not formatting the email, the problem is getting the php
>>>> > to take the image, whose name I can't know, and embedding it into the
>>>> > email. The php code constructs the email using my template and the data
>>>> > input by the user. Since I don't know the name of the file, and it is
>>>> > stored in a temp directory, I need the code that will place the image
>>>> > where I want it. In other words: it needs to convert the filename into
>>>> > the appropriate "<img src" html.
>>>> >
>>>> > I'm sure this seems very simple to all the code gurus, but I have found
>>>> > nothing that even comes close to this in any of the tutorials I have
>>>> > read.
>>>> >
>>>> > I have thought about saving the images to a permanent directory and
>>>> > changing the name to make the html easier, but there are several
>>>> > reasons to keep the original name and I don't want to keep the images
>>>> > on the server. So I need some php to assemble the html using unknown
>>>> > values.
>>>> >
>>>> > So far I have the image attached to the email, but not embedded. My
>>>> > attempt at embedding it resulted in the filename being displayed where
>>>> > the image should be. So it is not just a matter of html formatting.
>>>> Well, you've got the image in the email; all you need is to get it to
>>>> work with the html. You already have the file name, etc - or you
>>>> wouldn't have been able to attack it to the email.
>>>>
>>>> So, what is the result you want? Not something nebulous such as
>>>> "convert the filename into the appropriate"<img src" html" - EXACTLY
>>>> what do you want? I.e. if I send you example.jpg, what does the
>>>> resultant raw html in your email look like?
>>>>
>>>> Once you can answer that, your PHP code is easy.
>>> OK. To be more clear, I have a form in which the user fills in some
>>> information and uploads a headshot. the email is formatted the same as
>>> the form except I want the image to appear next to the information
>>> instead of attached. The info is down the left side and the image on
>>> the right. There is more info under all of that.
>>>
>>> I used Forms to Go to create the original form handler. The id for the
>>> image is $FTGheadshot. Simply placing that into the html output section
>>> (like this: headshot : $FTGheadshot<br />) just gets me the file's name
>>> in the space for the image.
>>>
>>> Looking at the code, now that I have learned a little more about it, I
>>> am thinking that I should put this: $_FILES['headshot']['tmp_name']
>>> there instead. Would that be right? Isn't that the part that connects
>>> the actual file with the FTG assigned variable?
>>>
>>> Previously it said: $FTGheadshot = $_FILES['headshot']['name'];
>>>
>>> Am I on the right track with this?
>> No, you're not, and creating an html email with embedded images is not
>> easy - but it is NOT a PHP question.
>>
>> First of all you need to figure out how to create the email in the first
>> place. Then you can worry about the PHP code needed to create it.
>>
>> Get a working page in your favorite email program first and see what the
>> source looks like. That will help you.
>>
>> Right now you're trying to create something with no idea what you're
>> creating. You can keep using trial and error methods and maybe get
>> there. Or you can do as I first suggested and find out how to create
>> the email you want first, ignoring any language considerations.
>
> I looked at an email with images both attached and embedded: the same
> images in both. The line that placed the image inline looks like this:
>
> <IMG=20
> id=3DMA2.1289279864 border=3D0=20
> =
> src=3D"cid:4EDBE5C8B2CC44F8ADDD6F853B321989@desktop619"=20
> width=3D480 height=3D604=20
> =
> DATASIZE=3D"144908">
>
> Where "cid:4EDBE5C8B2CC44F8ADDD6F853B321989@desktop619" is the Content
> ID. Obviously this is something that is compiled by the email program
> when the email is sent. Since HTML can not create itself, I need some
> code to do it.
>

So write it.

You also need to look at the mail *headers*. Beause thats where the
parts are defined so that "cid:4EDBE5C8B2CC44F8ADDD6F853B321989@desktop619"
actually means something.



> I have created the email, as I said, and it works perfectly other than
> this image issue. The source for the emails from this form look like
> this:
>

Ok, Not sure if this works or not.

Create a message body as HTML and include in it, this

<img width= "480" src="cid:Logo2.gif" alt="logo"> where you want the
picture.

Now here is my function to create a multipart mime message and send it.
De wrap it because the exact syntax of the headers is crucial

Pass a proper HTML page to it, as $body but don't get smart. Outlook
understands Tables, but not Divs.

I think this more or less works: it should serve as a starting point anyway.

function mail_html_file($email, $subject,$from,$return_path,$body)
{

$attach=
chunk_split(base64_encode(file_get_contents('../Images/Logo2.gif')));
$boundary = md5( time() );

$headers = sprintf("From: %s\nMIME-Version: 1.0\nContent-Type:
multipart/related; boundary=\"%s\"",
$from, $boundary);

$message = sprintf("--%s\nContent-Type: text/html;
charset=\"iso-9959-1\"\nContent-Transfer-Encoding:
quoted-printable\n\n%s\n\n--%s\nContent-Type: Image/gif;
name=\"Logo.gif\"\nContent-ID: <Logo2.gif>\nContent-Transfer-Encoding:
base64\n\n%s\n\n--%s--\n",
$boundary,$body,$boundary,$attach,$boundary);
mail($email, $subject, $message, $headers, "-f ".$return_path );
}
Re: CLP - ON TOPIC! - Need PHP form email help, Please! [message #173136 is a reply to message #173130] Wed, 23 March 2011 19:10 Go to previous messageGo to next message
The Natural Philosoph is currently offline  The Natural Philosoph
Messages: 993
Registered: September 2010
Karma: 0
Senior Member
Tim wrote:
> In article <4LZhp.79092$or1(dot)46990(at)newsfe26(dot)ams2>, Andy
> <andy(at)NOSPAMmanyplay(dot)com> wrote:
>
>> "Tim" <batwzrd(at)hotmail(dot)com> wrote in message
>> news:210320111731440609%batwzrd(at)hotmail(dot)com...
>>> I have a form in which the user can upload a photo, which is then sent
>>> to me along with the other data on the form. I have formatted the data
>>> into an HTML email with the photo attached. I would like the photo
>>> embedded in a specific place on the page, but I have not found the code
>>> to do this and don't know enough about it to write the code myself.
>>>
>>> It would also be nice to be able to have the photo, once uploaded, to
>>> replace the upload button and associated text on the page in the place
>>> I want the photo to appear. Then maybe send the page as is as an HTML
>>> email?
>>>
>>> Any help would be appreciated.
>>>
>> Hi Tim,
>>
>> Have a look at phpmailer...
>>
>> http://phpmailer.worxware.com/
>>
>> ...if you can generate an html page that looks like the email page you would
>> like to email, then phpmailer can wrap it all up, embed the images and send
>> it as email.
>>
>> Hope this helps
>>
>>
>> Andy
>>
> Actually, I think that is really the issue. if I could get the code to
> make the page, sending it as an email wouldn't be a problem.
>
> I also find it strange, and very frustrating, that I seem to have to
> become a php expert just to make this one form page behave the way I
> want. There are no references or tutorials that I have found that
> address this, and apparently no one wants to help other than chastising
> me for not already knowing everything.
>

Join teh club :-)

> Could no one just say "it would work better to make the html as a page
> separate from the email"? I even suggested as much in my original post,
> yet no one acknowledged it.

I think the thing is, here is talked the details of Php the language,
not how to construct a multipart HTML with embedded image mail message.

Its probably all in some obscure RFC.
Re: CLP - ON TOPIC! - Need PHP form email help, Please! [message #173137 is a reply to message #173134] Wed, 23 March 2011 19:18 Go to previous messageGo to next message
The Natural Philosoph is currently offline  The Natural Philosoph
Messages: 993
Registered: September 2010
Karma: 0
Senior Member
Tim Streater wrote:
> In article <230320111257235633%batwzrd(at)hotmail(dot)com>,
> Tim <batwzrd(at)hotmail(dot)com> wrote:
>
>> In article <imbdle$g3p$1(at)news(dot)eternal-september(dot)org>, Jerry Stuckle
>> <jstucklex(at)attglobal(dot)net> wrote:
>
>>> No, you're not, and creating an html email with embedded images is
>> not > easy - but it is NOT a PHP question.
>>>> First of all you need to figure out how to create the email in the
>> first > place. Then you can worry about the PHP code needed to create
>> it.
>>>> Get a working page in your favorite email program first and see
>> what the > source looks like. That will help you.
>>>> Right now you're trying to create something with no idea what
>> you're > creating. You can keep using trial and error methods and
>> maybe get > there. Or you can do as I first suggested and find out
>> how to create > the email you want first, ignoring any language
>> considerations.
>>
>> I looked at an email with images both attached and embedded: the same
>> images in both.
>
> Yes, and you'll have to learn how an e-mail is structured. Try looking
> at these RFCs:
>
> RFC 5322 (Internet Message Format), and RFCs 2045, 2046, 2047, 2048,
> 2049, (MIME), and 2183. You'll need to find which bits you need for your
> particular situation.
>
>> The line that placed the image inline looks like this:
>>
>> <IMG=20
>> id=3DMA2.1289279864 border=3D0=20
>> =
>> src=3D"cid:4EDBE5C8B2CC44F8ADDD6F853B321989@desktop619"=20
>> width=3D480 height=3D604=20
>> =
>> DATASIZE=3D"144908">
>
> Yes, that's encoded using quoted-printable (e.g., =20 is a space).
>
>> Where "cid:4EDBE5C8B2CC44F8ADDD6F853B321989@desktop619" is the Content
>> ID. Obviously this is something that is compiled by the email program
>> when the email is sent. Since HTML can not create itself, I need some
>> code to do it.
>>
>> I have created the email, as I said, and it works perfectly other than
>> this image issue. The source for the emails from this form look like
>> this:
>>
>> --FTG_BOUNDRY
>> Content-Type: text/html; charset="UTF-8"
>> Content-Transfer-Encoding: base64
>>
>> PGh0bWw+CjxoZWFkPgo8dGl0bGU+PC90aXRsZT4KPC9oZWFkPgo8Ym9keT4KPHRhYmxlIHdp
>> ZHRo
>> PSI4MDAiIGJvcmRlcj0iMCIgY2VsbHNwYWNpbmc9IjIiIGNlbGxwYWRkaW5nPSIxMCI+PHRy
>> Pgo8
>
> [snip]
>
> This is an email "part", encoded in base-64. Why is it thus encoded -
> who is doing that?
>
His email client. I recommended he should disassemble it and reverse
engineer it, because that is what I did.

Look the code I posted should work or at least work near enough to
puzzle the thing out. I only went as far as getting something that works
for me BUT the basic message format for embedded images is this:

Create OR they can reference inline embedded stuff: there is a special
format for that. src="cid:...."


Then you have to set up the mail headers to reflect the fact this is
multipart mime encoded HTML and that certain bits will be base 64 encoded,.

Then you have to create the message with separators, parts and where
appropriate base 64 encoding.

And, as I discovered,. all mail clients are not equal, and PHP frigs
with line endings. I had to rework my code to first of all work on Mac
mail, then Outlook, and finally going PHP4 to 5 broke it..all to do with
line endings.
Re: CLP - ON TOPIC! - Need PHP form email help, Please! [message #173138 is a reply to message #173137] Wed, 23 March 2011 19:48 Go to previous messageGo to next message
Tim Streater is currently offline  Tim Streater
Messages: 328
Registered: September 2010
Karma: 0
Senior Member
In article <imdh2i$v5v$1(at)news(dot)albasani(dot)net>,
The Natural Philosopher <tnp(at)invalid(dot)invalid> wrote:

> Tim Streater wrote:

>> Yes, and you'll have to learn how an e-mail is structured. Try looking
>> at these RFCs:
>>
>> RFC 5322 (Internet Message Format), and RFCs 2045, 2046, 2047, 2048,
>> 2049, (MIME), and 2183. You'll need to find which bits you need for your
>> particular situation.

>> This is an email "part", encoded in base-64. Why is it thus encoded -
>> who is doing that?
>>
> His email client. I recommended he should disassemble it and reverse
> engineer it, because that is what I did.

Hmm, perhaps I came late to this thread. I thought he had a web page
which when submitted caused a PHP script to run that created the e-mail.
Hence my question.

> Look the code I posted should work or at least work near enough to
> puzzle the thing out. I only went as far as getting something that works
> for me BUT the basic message format for embedded images is this:
>
> Create OR they can reference inline embedded stuff: there is a special
> format for that. src="cid:...."
>
> Then you have to set up the mail headers to reflect the fact this is
> multipart mime encoded HTML and that certain bits will be base 64 encoded,.
>
> Then you have to create the message with separators, parts and where
> appropriate base 64 encoding.

Yeah yeah I know all this. I have written an email client myself so had
to research all this stuff, including wading through the RFCs I listed
above.

I'm trying to hint to the OP that there aren't any shortcuts. As Jerry
said, figure out what you want to do, first, then research and assemble
the components you need. Coding comes last.

--
Tim

"That excessive bail ought not to be required, nor excessive fines imposed,
nor cruel and unusual punishments inflicted" -- Bill of Rights 1689
Re: CLP - ON TOPIC! - Need PHP form email help, Please! [message #173139 is a reply to message #173130] Wed, 23 March 2011 20:46 Go to previous messageGo to next message
Jonathan Stein is currently offline  Jonathan Stein
Messages: 43
Registered: September 2010
Karma: 0
Member
On 23-03-2011 19:05, Tim wrote:

> I also find it strange, and very frustrating, that I seem to have to
> become a php expert just to make this one form page behave the way I
> want.

The PHP is actually rather simple, and the good thing is that PHP has
built in functions for most of the operations, that you need.

However you do need a good knowledge of multi-part MIME messages to succeed.

> There are no references or tutorials that I have found that
> address this,

I tried "php send email embedded image" on Google - first suggestion was
http://www.phpeveryday.com/articles/PHP-Email-Using-Embedded-Images-in-HTML -Email-P113.html
- I think that's what you're looking for.

Regards

Jonathan
Re: CLP - ON TOPIC! - Need PHP form email help, Please! [message #173140 is a reply to message #173139] Thu, 24 March 2011 04:08 Go to previous messageGo to next message
Denis McMahon is currently offline  Denis McMahon
Messages: 634
Registered: September 2010
Karma: 0
Senior Member
On Wed, 23 Mar 2011 21:46:12 +0100, Jonathan Stein wrote:

> On 23-03-2011 19:05, Tim wrote:
>
>> I also find it strange, and very frustrating, that I seem to have to
>> become a php expert just to make this one form page behave the way I
>> want.
>
> The PHP is actually rather simple, and the good thing is that PHP has
> built in functions for most of the operations, that you need.
>
> However you do need a good knowledge of multi-part MIME messages to
> succeed.

Indeed

>> There are no references or tutorials that I have found that address
>> this,
>
> I tried "php send email embedded image" on Google - first suggestion was
> http://www.phpeveryday.com/articles/PHP-Email-Using-Embedded-Images-in-
HTML-Email-P113.html
> - I think that's what you're looking for.

Yes, I tried to take that and, as an exercise in making sure I understood
it, make it work with an array of attached files.

I did discover that on my linux server, I needed to sort out some cr/lf
issues before it would work properly, and there was a warning generated
(first use of headers is '$headers .=' which causes "variable is
undefined").

However, I made it work, it wasn't overly difficult, looking at the raw
text source of valid messages with attachments in my mail client helped
me see where the problems were when the mail client wasn't interpreting
what it received the way I expected and wanted it to.

Rgds

Denis McMahon
Re: CLP - ON TOPIC! - Need PHP form email help, Please! [message #173142 is a reply to message #173135] Thu, 24 March 2011 09:23 Go to previous messageGo to next message
crankypuss is currently offline  crankypuss
Messages: 147
Registered: March 2011
Karma: 0
Senior Member
The Natural Philosopher <tnp(at)invalid(dot)invalid> wrote:

> Tim wrote:
>> In article <imbdle$g3p$1(at)news(dot)eternal-september(dot)org>, Jerry Stuckle
>> <jstucklex(at)attglobal(dot)net> wrote:
>>
>>> On 3/22/2011 7:11 PM, Tim wrote:
>>>> In article<im9v9g$jj9$1(at)news(dot)eternal-september(dot)org>, Jerry Stuckle
>>>> <jstucklex(at)attglobal(dot)net> wrote:
>>>>
>>>> > On 3/22/2011 12:03 AM, Tim wrote:
>>>> >> In article<im93gr$8bp$1(at)news(dot)eternal-september(dot)org>, Jerry Stuckle
>>>> >> <jstucklex(at)attglobal(dot)net> wrote:
>>>> >>
>>>> >>> On 3/21/2011 6:31 PM, Tim wrote:
>>>> >>>> I have a form in which the user can upload a photo, which is then sent
>>>> >>>> to me along with the other data on the form. I have formatted the data
>>>> >>>> into an HTML email with the photo attached. I would like the photo
>>>> >>>> embedded in a specific place on the page, but I have not found the code
>>>> >>>> to do this and don't know enough about it to write the code myself.
>>>> >>>>
>>>> >>>> It would also be nice to be able to have the photo, once uploaded, to
>>>> >>>> replace the upload button and associated text on the page in the place
>>>> >>>> I want the photo to appear. Then maybe send the page as is as an HTML
>>>> >>>> email?
>>>> >>>>
>>>> >>>> Any help would be appreciated.
>>>> >>> And your PHP question is?
>>>> >>>
>>>> >>> Sounds more like you need to learn how to format the email correctly,
>>>> >>> which is an email/HTML question. Try a more appropriate newsgroup
>>>> >>> (maybe alt.html - I don't know).
>>>> >> The problem is not formatting the email, the problem is getting the php
>>>> >> to take the image, whose name I can't know, and embedding it into the
>>>> >> email. The php code constructs the email using my template and the data
>>>> >> input by the user. Since I don't know the name of the file, and it is
>>>> >> stored in a temp directory, I need the code that will place the image
>>>> >> where I want it. In other words: it needs to convert the filename into
>>>> >> the appropriate "<img src" html.
>>>> >>
>>>> >> I'm sure this seems very simple to all the code gurus, but I have found
>>>> >> nothing that even comes close to this in any of the tutorials I have
>>>> >> read.
>>>> >>
>>>> >> I have thought about saving the images to a permanent directory and
>>>> >> changing the name to make the html easier, but there are several
>>>> >> reasons to keep the original name and I don't want to keep the images
>>>> >> on the server. So I need some php to assemble the html using unknown
>>>> >> values.
>>>> >>
>>>> >> So far I have the image attached to the email, but not embedded. My
>>>> >> attempt at embedding it resulted in the filename being displayed where
>>>> >> the image should be. So it is not just a matter of html formatting.
>>>> > Well, you've got the image in the email; all you need is to get it to
>>>> > work with the html. You already have the file name, etc - or you
>>>> > wouldn't have been able to attack it to the email.
>>>> >
>>>> > So, what is the result you want? Not something nebulous such as
>>>> > "convert the filename into the appropriate"<img src" html" - EXACTLY
>>>> > what do you want? I.e. if I send you example.jpg, what does the
>>>> > resultant raw html in your email look like?
>>>> >
>>>> > Once you can answer that, your PHP code is easy.
>>>> OK. To be more clear, I have a form in which the user fills in some
>>>> information and uploads a headshot. the email is formatted the same as
>>>> the form except I want the image to appear next to the information
>>>> instead of attached. The info is down the left side and the image on
>>>> the right. There is more info under all of that.
>>>>
>>>> I used Forms to Go to create the original form handler. The id for the
>>>> image is $FTGheadshot. Simply placing that into the html output section
>>>> (like this: headshot : $FTGheadshot<br />) just gets me the file's name
>>>> in the space for the image.
>>>>
>>>> Looking at the code, now that I have learned a little more about it, I
>>>> am thinking that I should put this: $_FILES['headshot']['tmp_name']
>>>> there instead. Would that be right? Isn't that the part that connects
>>>> the actual file with the FTG assigned variable?
>>>>
>>>> Previously it said: $FTGheadshot = $_FILES['headshot']['name'];
>>>>
>>>> Am I on the right track with this?
>>> No, you're not, and creating an html email with embedded images is not
>>> easy - but it is NOT a PHP question.
>>>
>>> First of all you need to figure out how to create the email in the first
>>> place. Then you can worry about the PHP code needed to create it.
>>>
>>> Get a working page in your favorite email program first and see what the
>>> source looks like. That will help you.
>>>
>>> Right now you're trying to create something with no idea what you're
>>> creating. You can keep using trial and error methods and maybe get
>>> there. Or you can do as I first suggested and find out how to create
>>> the email you want first, ignoring any language considerations.
>>
>> I looked at an email with images both attached and embedded: the same
>> images in both. The line that placed the image inline looks like this:
>>
>> <IMG=20
>> id=3DMA2.1289279864 border=3D0=20
>> =
>> src=3D"cid:4EDBE5C8B2CC44F8ADDD6F853B321989@desktop619"=20
>> width=3D480 height=3D604=20
>> =
>> DATASIZE=3D"144908">
>>
>> Where "cid:4EDBE5C8B2CC44F8ADDD6F853B321989@desktop619" is the Content
>> ID. Obviously this is something that is compiled by the email program
>> when the email is sent. Since HTML can not create itself, I need some
>> code to do it.
>>
>
> So write it.
>
> You also need to look at the mail *headers*. Beause thats where the
> parts are defined so that "cid:4EDBE5C8B2CC44F8ADDD6F853B321989@desktop619"
> actually means something.
>
>
>
>> I have created the email, as I said, and it works perfectly other than
>> this image issue. The source for the emails from this form look like
>> this:
>>
>
> Ok, Not sure if this works or not.
>
> Create a message body as HTML and include in it, this
>
> <img width= "480" src="cid:Logo2.gif" alt="logo"> where you want the
> picture.
>
> Now here is my function to create a multipart mime message and send it.
> De wrap it because the exact syntax of the headers is crucial
>
> Pass a proper HTML page to it, as $body but don't get smart. Outlook
> understands Tables, but not Divs.
>
> I think this more or less works: it should serve as a starting point anyway.
>
> function mail_html_file($email, $subject,$from,$return_path,$body)
> {
>
> $attach=
> chunk_split(base64_encode(file_get_contents('../Images/Logo2.gif')));
> $boundary = md5( time() );
>
> $headers = sprintf("From: %s\nMIME-Version: 1.0\nContent-Type:
> multipart/related; boundary=\"%s\"",
> $from, $boundary);
>
> $message = sprintf("--%s\nContent-Type: text/html;
> charset=\"iso-9959-1\"\nContent-Transfer-Encoding:
> quoted-printable\n\n%s\n\n--%s\nContent-Type: Image/gif;
> name=\"Logo.gif\"\nContent-ID: <Logo2.gif>\nContent-Transfer-Encoding:
> base64\n\n%s\n\n--%s--\n",
> $boundary,$body,$boundary,$attach,$boundary);
> mail($email, $subject, $message, $headers, "-f ".$return_path );
> }

Nobody seems to have mentioned yet that embedding images (especially
large images) in emails is just plain rude. If the image exists on
the web and you're sending an html email then use the image from the
web. That way the recipient won't have to sit and wait while your
(potentially) multi-megabyte image (that the recipient may not even
want to see) is downloaded. Not everyone enables html in their email
client, and for those who don't you're just wasting their bandwidth.

--
no aluminum siding offers today
Re: CLP - ON TOPIC! - Need PHP form email help, Please! [message #173143 is a reply to message #173130] Thu, 24 March 2011 09:27 Go to previous messageGo to next message
crankypuss is currently offline  crankypuss
Messages: 147
Registered: March 2011
Karma: 0
Senior Member
Tim <batwzrd(at)hotmail(dot)com> wrote:

> Could no one just say "it would work better to make the html as a page
> separate from the email"? I even suggested as much in my original post,
> yet no one acknowledged it.

It's much better, at least better imo, to simply send a brief email
that says "oh lookie blah blah go here for details" and include a
link.

--
no aluminum siding offers today
Re: CLP - ON TOPIC! - Need PHP form email help, Please! [message #173144 is a reply to message #173142] Thu, 24 March 2011 10:17 Go to previous messageGo to next message
The Natural Philosoph is currently offline  The Natural Philosoph
Messages: 993
Registered: September 2010
Karma: 0
Senior Member
crankypuss wrote:
> The Natural Philosopher <tnp(at)invalid(dot)invalid> wrote:
>
>> Tim wrote:
>>> In article <imbdle$g3p$1(at)news(dot)eternal-september(dot)org>, Jerry Stuckle
>>> <jstucklex(at)attglobal(dot)net> wrote:
>>>
>>>> On 3/22/2011 7:11 PM, Tim wrote:
>>>> > In article<im9v9g$jj9$1(at)news(dot)eternal-september(dot)org>, Jerry Stuckle
>>>> > <jstucklex(at)attglobal(dot)net> wrote:
>>>> >
>>>> >> On 3/22/2011 12:03 AM, Tim wrote:
>>>> >>> In article<im93gr$8bp$1(at)news(dot)eternal-september(dot)org>, Jerry Stuckle
>>>> >>> <jstucklex(at)attglobal(dot)net> wrote:
>>>> >>>
>>>> >>>> On 3/21/2011 6:31 PM, Tim wrote:
>>>> >>>>> I have a form in which the user can upload a photo, which is then sent
>>>> >>>>> to me along with the other data on the form. I have formatted the data
>>>> >>>>> into an HTML email with the photo attached. I would like the photo
>>>> >>>>> embedded in a specific place on the page, but I have not found the code
>>>> >>>>> to do this and don't know enough about it to write the code myself.
>>>> >>>>>
>>>> >>>>> It would also be nice to be able to have the photo, once uploaded, to
>>>> >>>>> replace the upload button and associated text on the page in the place
>>>> >>>>> I want the photo to appear. Then maybe send the page as is as an HTML
>>>> >>>>> email?
>>>> >>>>>
>>>> >>>>> Any help would be appreciated.
>>>> >>>> And your PHP question is?
>>>> >>>>
>>>> >>>> Sounds more like you need to learn how to format the email correctly,
>>>> >>>> which is an email/HTML question. Try a more appropriate newsgroup
>>>> >>>> (maybe alt.html - I don't know).
>>>> >>> The problem is not formatting the email, the problem is getting the php
>>>> >>> to take the image, whose name I can't know, and embedding it into the
>>>> >>> email. The php code constructs the email using my template and the data
>>>> >>> input by the user. Since I don't know the name of the file, and it is
>>>> >>> stored in a temp directory, I need the code that will place the image
>>>> >>> where I want it. In other words: it needs to convert the filename into
>>>> >>> the appropriate "<img src" html.
>>>> >>>
>>>> >>> I'm sure this seems very simple to all the code gurus, but I have found
>>>> >>> nothing that even comes close to this in any of the tutorials I have
>>>> >>> read.
>>>> >>>
>>>> >>> I have thought about saving the images to a permanent directory and
>>>> >>> changing the name to make the html easier, but there are several
>>>> >>> reasons to keep the original name and I don't want to keep the images
>>>> >>> on the server. So I need some php to assemble the html using unknown
>>>> >>> values.
>>>> >>>
>>>> >>> So far I have the image attached to the email, but not embedded. My
>>>> >>> attempt at embedding it resulted in the filename being displayed where
>>>> >>> the image should be. So it is not just a matter of html formatting.
>>>> >> Well, you've got the image in the email; all you need is to get it to
>>>> >> work with the html. You already have the file name, etc - or you
>>>> >> wouldn't have been able to attack it to the email.
>>>> >>
>>>> >> So, what is the result you want? Not something nebulous such as
>>>> >> "convert the filename into the appropriate"<img src" html" - EXACTLY
>>>> >> what do you want? I.e. if I send you example.jpg, what does the
>>>> >> resultant raw html in your email look like?
>>>> >>
>>>> >> Once you can answer that, your PHP code is easy.
>>>> > OK. To be more clear, I have a form in which the user fills in some
>>>> > information and uploads a headshot. the email is formatted the same as
>>>> > the form except I want the image to appear next to the information
>>>> > instead of attached. The info is down the left side and the image on
>>>> > the right. There is more info under all of that.
>>>> >
>>>> > I used Forms to Go to create the original form handler. The id for the
>>>> > image is $FTGheadshot. Simply placing that into the html output section
>>>> > (like this: headshot : $FTGheadshot<br />) just gets me the file's name
>>>> > in the space for the image.
>>>> >
>>>> > Looking at the code, now that I have learned a little more about it, I
>>>> > am thinking that I should put this: $_FILES['headshot']['tmp_name']
>>>> > there instead. Would that be right? Isn't that the part that connects
>>>> > the actual file with the FTG assigned variable?
>>>> >
>>>> > Previously it said: $FTGheadshot = $_FILES['headshot']['name'];
>>>> >
>>>> > Am I on the right track with this?
>>>> No, you're not, and creating an html email with embedded images is not
>>>> easy - but it is NOT a PHP question.
>>>>
>>>> First of all you need to figure out how to create the email in the first
>>>> place. Then you can worry about the PHP code needed to create it.
>>>>
>>>> Get a working page in your favorite email program first and see what the
>>>> source looks like. That will help you.
>>>>
>>>> Right now you're trying to create something with no idea what you're
>>>> creating. You can keep using trial and error methods and maybe get
>>>> there. Or you can do as I first suggested and find out how to create
>>>> the email you want first, ignoring any language considerations.
>>> I looked at an email with images both attached and embedded: the same
>>> images in both. The line that placed the image inline looks like this:
>>>
>>> <IMG=20
>>> id=3DMA2.1289279864 border=3D0=20
>>> =
>>> src=3D"cid:4EDBE5C8B2CC44F8ADDD6F853B321989@desktop619"=20
>>> width=3D480 height=3D604=20
>>> =
>>> DATASIZE=3D"144908">
>>>
>>> Where "cid:4EDBE5C8B2CC44F8ADDD6F853B321989@desktop619" is the Content
>>> ID. Obviously this is something that is compiled by the email program
>>> when the email is sent. Since HTML can not create itself, I need some
>>> code to do it.
>>>
>> So write it.
>>
>> You also need to look at the mail *headers*. Beause thats where the
>> parts are defined so that "cid:4EDBE5C8B2CC44F8ADDD6F853B321989@desktop619"
>> actually means something.
>>
>>
>>
>>> I have created the email, as I said, and it works perfectly other than
>>> this image issue. The source for the emails from this form look like
>>> this:
>>>
>> Ok, Not sure if this works or not.
>>
>> Create a message body as HTML and include in it, this
>>
>> <img width= "480" src="cid:Logo2.gif" alt="logo"> where you want the
>> picture.
>>
>> Now here is my function to create a multipart mime message and send it.
>> De wrap it because the exact syntax of the headers is crucial
>>
>> Pass a proper HTML page to it, as $body but don't get smart. Outlook
>> understands Tables, but not Divs.
>>
>> I think this more or less works: it should serve as a starting point anyway.
>>
>> function mail_html_file($email, $subject,$from,$return_path,$body)
>> {
>>
>> $attach=
>> chunk_split(base64_encode(file_get_contents('../Images/Logo2.gif')));
>> $boundary = md5( time() );
>>
>> $headers = sprintf("From: %s\nMIME-Version: 1.0\nContent-Type:
>> multipart/related; boundary=\"%s\"",
>> $from, $boundary);
>>
>> $message = sprintf("--%s\nContent-Type: text/html;
>> charset=\"iso-9959-1\"\nContent-Transfer-Encoding:
>> quoted-printable\n\n%s\n\n--%s\nContent-Type: Image/gif;
>> name=\"Logo.gif\"\nContent-ID: <Logo2.gif>\nContent-Transfer-Encoding:
>> base64\n\n%s\n\n--%s--\n",
>> $boundary,$body,$boundary,$attach,$boundary);
>> mail($email, $subject, $message, $headers, "-f ".$return_path );
>> }
>
> Nobody seems to have mentioned yet that embedding images (especially
> large images) in emails is just plain rude. If the image exists on
> the web and you're sending an html email then use the image from the
> web. That way the recipient won't have to sit and wait while your
> (potentially) multi-megabyte image (that the recipient may not even
> want to see) is downloaded. Not everyone enables html in their email
> client, and for those who don't you're just wasting their bandwidth.
>

I didn't mention it, because its context dependent. You cant make such a
blanket statement.

IF the image is an intrinsic part of what you are communicating, it has
to be downloaded anyway, assuming the customer or whatever wants the
email at all.

If they don't want it, or the image is not vital, one questions why you
are sending the email at all.

And my replies to technical questions seldom question the morality of
the person asking: Just possibly their technical approach.

In short, its none of my business.
Re: CLP - ON TOPIC! - Need PHP form email help, Please! [message #173145 is a reply to message #173143] Thu, 24 March 2011 10:24 Go to previous messageGo to next message
The Natural Philosoph is currently offline  The Natural Philosoph
Messages: 993
Registered: September 2010
Karma: 0
Senior Member
crankypuss wrote:
> Tim <batwzrd(at)hotmail(dot)com> wrote:
>
>> Could no one just say "it would work better to make the html as a page
>> separate from the email"? I even suggested as much in my original post,
>> yet no one acknowledged it.
>
> It's much better, at least better imo, to simply send a brief email
> that says "oh lookie blah blah go here for details" and include a
> link.
>
That assumes your client base are smart enough to click on something.

Experience shows me - and that's why I wrote that bit of code - that
some customers can't even open an attachment. Or click on the button
that says 'load images' or even click on a link.

Probably scared of catching AIDS or something.

I fully agree that huge images are bad news, but a nicely presented
shipping notification with a company logo in the corner, is not a huge
amount of downloading. Maybe 5-10k for a logo, and it just polishes the
job off.

About 90% of the less sophisticated people are in fact using a webmail
client anyay, so HTML rendering is petty 'de rigeur'

Of the rest, the vast majority will be on the default Microsoft mail,
with a smattering of Firefox and Mac mail clients.

The smarter people who have weird mail clients like Emacs, may be
expected to know how to do whatever they choose to get the thing to
render properly.
Re: CLP - ON TOPIC! - Need PHP form email help, Please! [message #173153 is a reply to message #173145] Thu, 24 March 2011 18:07 Go to previous messageGo to next message
Tim is currently offline  Tim
Messages: 13
Registered: March 2011
Karma: 0
Junior Member
In article <imf652$fom$1(at)news(dot)albasani(dot)net>, The Natural Philosopher
<tnp(at)invalid(dot)invalid> wrote:

> crankypuss wrote:
>> Tim <batwzrd(at)hotmail(dot)com> wrote:
>>
>>> Could no one just say "it would work better to make the html as a page
>>> separate from the email"? I even suggested as much in my original post,
>>> yet no one acknowledged it.
>>
>> It's much better, at least better imo, to simply send a brief email
>> that says "oh lookie blah blah go here for details" and include a
>> link.
>>
> That assumes your client base are smart enough to click on something.
>
> Experience shows me - and that's why I wrote that bit of code - that
> some customers can't even open an attachment. Or click on the button
> that says 'load images' or even click on a link.
>
> Probably scared of catching AIDS or something.
>
> I fully agree that huge images are bad news, but a nicely presented
> shipping notification with a company logo in the corner, is not a huge
> amount of downloading. Maybe 5-10k for a logo, and it just polishes the
> job off.
>
> About 90% of the less sophisticated people are in fact using a webmail
> client anyay, so HTML rendering is petty 'de rigeur'
>
> Of the rest, the vast majority will be on the default Microsoft mail,
> with a smattering of Firefox and Mac mail clients.
>
> The smarter people who have weird mail clients like Emacs, may be
> expected to know how to do whatever they choose to get the thing to
> render properly.
>
>
>
These are good, valid points. But since I am sending the email with the
image to myself, I guess I would be expecting it. Also, not keeping it
on the web server is somewhat of a priority for several reasons.
Re: CLP - ON TOPIC! - Need PHP form email help, Please! [message #173154 is a reply to message #173139] Thu, 24 March 2011 18:16 Go to previous messageGo to next message
Tim is currently offline  Tim
Messages: 13
Registered: March 2011
Karma: 0
Junior Member
In article <4d8a5c0e$0$23756$14726298(at)news(dot)sunsite(dot)dk>, Jonathan Stein
<jstein(at)image(dot)dk> wrote:

> On 23-03-2011 19:05, Tim wrote:
>
>> I also find it strange, and very frustrating, that I seem to have to
>> become a php expert just to make this one form page behave the way I
>> want.
>
> The PHP is actually rather simple, and the good thing is that PHP has
> built in functions for most of the operations, that you need.
>
> However you do need a good knowledge of multi-part MIME messages to succeed.
>
>> There are no references or tutorials that I have found that
>> address this,
>
> I tried "php send email embedded image" on Google - first suggestion was
>
> http://www.phpeveryday.com/articles/PHP-Email-Using-Embedded-Images-in-HTML -Em
> ail-P113.html
> - I think that's what you're looking for.
>
> Regards
>
> Jonathan

I looked at that briefly. I hadn't searched for that exact string so I
suppose that is why I hadn't seen it before.

It is on the right track, though it would require a lot of modification
to get it to work with my existing code since it uses an image located
on the server and whose name is known.

But I think I have decided to go a different route. Instead of emailing
the form and trying to get the image thing right, I will have it create
a new page and save that to a directory. Then have another script on
the "success" page that sends all html pages in that directory as
attachments. Possibly with some provision to only do it once or twice a
day. I'm not sure if I have access to cron. I'm on 1 & 1. Does anyone
know? If so I could just have it search the directory for pages
automatically.

Anyone have any advice about that? I think it will be better all the
way around.
Re: CLP - ON TOPIC! - Need PHP form email help, Please! [message #173155 is a reply to message #173154] Thu, 24 March 2011 18:34 Go to previous messageGo to next message
Denis McMahon is currently offline  Denis McMahon
Messages: 634
Registered: September 2010
Karma: 0
Senior Member
On Thu, 24 Mar 2011 13:16:33 -0500, Tim wrote:

> In article <4d8a5c0e$0$23756$14726298(at)news(dot)sunsite(dot)dk>, Jonathan Stein
> <jstein(at)image(dot)dk> wrote:
>
>> On 23-03-2011 19:05, Tim wrote:
>>
>>> I also find it strange, and very frustrating, that I seem to have to
>>> become a php expert just to make this one form page behave the way I
>>> want.

>> http://www.phpeveryday.com/articles/PHP-Email-Using-Embedded-Images-in-
HTML-Em
>> ail-P113.html

> I looked at that briefly. I hadn't searched for that exact string so I
> suppose that is why I hadn't seen it before.
>
> It is on the right track, though it would require a lot of modification
> to get it to work with my existing code since it uses an image located
> on the server and whose name is known.

If you don't know what the file name of the image file is, how the heck
do you expect to be able to do anything at all with it?

Perhaps your questions should start with:

"How do I find out where the uploaded file is, and what it was called?"

http://uk2.php.net/manual/en/reserved.variables.files.php

After you have absorbed that information, perhaps you will then be ready
to ask "How do I use PHP to email this uploaded image to someone else?"

Rgds

Denis McMahon
Re: CLP - ON TOPIC! - Need PHP form email help, Please! [message #173156 is a reply to message #173155] Thu, 24 March 2011 20:26 Go to previous messageGo to next message
Tim is currently offline  Tim
Messages: 13
Registered: March 2011
Karma: 0
Junior Member
In article <4d8b8eb6$0$995$bed64819(at)gradwell(dot)net>, Denis McMahon
<denis(dot)m(dot)f(dot)mcmahon(at)gmail(dot)com> wrote:

> On Thu, 24 Mar 2011 13:16:33 -0500, Tim wrote:
>
>> In article <4d8a5c0e$0$23756$14726298(at)news(dot)sunsite(dot)dk>, Jonathan Stein
>> <jstein(at)image(dot)dk> wrote:
>>
>>> On 23-03-2011 19:05, Tim wrote:
>>>
>>>> I also find it strange, and very frustrating, that I seem to have to
>>>> become a php expert just to make this one form page behave the way I
>>>> want.
>
>>> http://www.phpeveryday.com/articles/PHP-Email-Using-Embedded-Images-in-
> HTML-Em
>>> ail-P113.html
>
>> I looked at that briefly. I hadn't searched for that exact string so I
>> suppose that is why I hadn't seen it before.
>>
>> It is on the right track, though it would require a lot of modification
>> to get it to work with my existing code since it uses an image located
>> on the server and whose name is known.
>
> If you don't know what the file name of the image file is, how the heck
> do you expect to be able to do anything at all with it?
>
> Perhaps your questions should start with:
>
> "How do I find out where the uploaded file is, and what it was called?"
>
> http://uk2.php.net/manual/en/reserved.variables.files.php
>
> After you have absorbed that information, perhaps you will then be ready
> to ask "How do I use PHP to email this uploaded image to someone else?"
>
> Rgds
>
> Denis McMahon

Thanks for the concern, but I already have the form and handler code
that gets the file's name. I was just pointing out that the example at
that link was using a pre-existing image file, rather than an uploaded
one, and hard-coding it into the script.

This is all about getting the data, including the image, to me in the
desired format so I can print it out without needing to make
modifications to it such as placing the attached image where I want it.
Re: CLP - ON TOPIC! - Need PHP form email help, Please! [message #173157 is a reply to message #173153] Thu, 24 March 2011 20:48 Go to previous messageGo to next message
P E Schoen is currently offline  P E Schoen
Messages: 86
Registered: January 2011
Karma: 0
Member
"Tim" wrote in message news:240320111307285760%batwzrd(at)hotmail(dot)com...

> These are good, valid points. But since I am sending the email with
> the image to myself, I guess I would be expecting it. Also, not
> keeping it on the web server is somewhat of a priority for several
> reasons.

I'm not sure I can help, although I have done some work with a form that can
contain a link to an image and then display it in an HTML page which is
dynamically generated with a PHP script. And it also sends a copy of the
submitted information to me, but it is in plain text and only shows the
link, rather than the actual picture.

I will assume that the web page form is for submitting user information
which includes a "headshot", and the user just uploads an image to your web
server. And you want the form to be regenerated with that headshot and any
other updated information to provide feedback to the user. Then I would also
assume that his/her image and other information will appear in another web
page which may be something like a blog or discussion forum or a dating
site.

In this case, it seems unnecessary to have the formatted page emailed to
you, and it would be better to just receive a notification that the user has
submitted the information. Then you can go to the site and see if it is OK.
Even better, perhaps, if you have the new page in a private area where you
can approve or deny the submission. But it seems that you will need to have
the image and the information on your web server, unless you want to have it
on your local machine. And in that case, the user should just email the
image and other data to you directly.

It's difficult to give advice without knowing all these details, and then it
may or may not be a PHP issue. If you have a partially working site, or a
link to one that is similar, that will make it much easier and will
eliminate the guessing game and wrong assumptions that lead to dead ends and
wasted effort.

Paul
Re: CLP - ON TOPIC! - Need PHP form email help, Please! [message #173158 is a reply to message #173156] Fri, 25 March 2011 03:01 Go to previous messageGo to next message
Denis McMahon is currently offline  Denis McMahon
Messages: 634
Registered: September 2010
Karma: 0
Senior Member
On Thu, 24 Mar 2011 15:26:21 -0500, Tim wrote:

> In article <4d8b8eb6$0$995$bed64819(at)gradwell(dot)net>, Denis McMahon
> <denis(dot)m(dot)f(dot)mcmahon(at)gmail(dot)com> wrote:
>
>> On Thu, 24 Mar 2011 13:16:33 -0500, Tim wrote:
>>
>>> In article <4d8a5c0e$0$23756$14726298(at)news(dot)sunsite(dot)dk>, Jonathan
>>> Stein <jstein(at)image(dot)dk> wrote:
>>>
>>>> On 23-03-2011 19:05, Tim wrote:
>>>>
>>>> > I also find it strange, and very frustrating, that I seem to have
>>>> > to become a php expert just to make this one form page behave the
>>>> > way I want.
>>
>>>> http://www.phpeveryday.com/articles/PHP-Email-Using-Embedded-Images-
in-
>> HTML-Em
>>>> ail-P113.html
>>
>>> I looked at that briefly. I hadn't searched for that exact string so
>>> I suppose that is why I hadn't seen it before.
>>>
>>> It is on the right track, though it would require a lot of
>>> modification to get it to work with my existing code since it uses an
>>> image located on the server and whose name is known.
>>
>> If you don't know what the file name of the image file is, how the heck
>> do you expect to be able to do anything at all with it?
>>
>> Perhaps your questions should start with:
>>
>> "How do I find out where the uploaded file is, and what it was called?"
>>
>> http://uk2.php.net/manual/en/reserved.variables.files.php
>>
>> After you have absorbed that information, perhaps you will then be
>> ready to ask "How do I use PHP to email this uploaded image to someone
>> else?"

> Thanks for the concern, but I already have the form and handler code
> that gets the file's name. I was just pointing out that the example at
> that link was using a pre-existing image file, rather than an uploaded
> one, and hard-coding it into the script.

Yes, and? You simply have to write code that uses your filename wherever
that code uses the hardcoded filename. It's not difficult.

> This is all about getting the data, including the image, to me in the
> desired format so I can print it out without needing to make
> modifications to it such as placing the attached image where I want it.

ok, maybe the second question should have been:

"How do I use PHP to email this uploaded image to someone?"

where "someone" might include yourself.

Here's what happens:

File is uploaded in a form. It gets put in a temporary location. The
$_FILES superglobal contains:

a) original filename from uploading system
b) mime type
c) temporary name
d) status
e) size

(possibly not in that order)

mime type might not be valid, there's a suggestion it's supplied by the
uploader. original filename might also not be valid.

First of all you should use move_uploaded_file to put the file in your
"incoming uploads" directory. At this point, you can also rename it to
whatever you want to call it. You might or might not choose to use some
or all of:

uploading system ip
date and time
original filename

to create a unique name, after all you can't have two files of the same
name in your temp dir. Or you could just number incoming files
sequentially starting at 1. What I'd probably do is make a note of the
original name, uploaders ip, time and date, create an md5 hash from it
and use that as the unique filename, and record the original information
in a log file.

However, as you want to send an email, you could stick that information
in the message body, together with the unique filename that you gave it
in your incoming uploads directory

So once you have the file in your incoming uploads directory, with
whatever filename you choose to give it derived however you decided to
derive it, you can now, by using a slightly modified version of the email
example that you have already been provided with, email it to yourself.

We're not expecting you to become an expert, but please, to make the php
code to do what you want it to, you have to meet it half way and be
prepared to string a few functions and control statements together.

If you're not capable of editing an example of code that uses a hardcoded
filename to use a variable one instead, then maybe you need to spend some
more time getting to grips with the basics of programming concepts and
editing files, and then the variable naming syntaxes etc of php, before
you start working on anything as ambitious as form handling, uploaded
files and sending emails.

Rgds

Denis McMahon
Re: CLP - ON TOPIC! - Need PHP form email help, Please! [message #173192 is a reply to message #173158] Sat, 26 March 2011 22:32 Go to previous messageGo to next message
Tim is currently offline  Tim
Messages: 13
Registered: March 2011
Karma: 0
Junior Member
In article <4d8c058d$0$29403$bed64819(at)gradwell(dot)net>, Denis McMahon
<denis(dot)m(dot)f(dot)mcmahon(at)gmail(dot)com> wrote:

> On Thu, 24 Mar 2011 15:26:21 -0500, Tim wrote:
>
>> In article <4d8b8eb6$0$995$bed64819(at)gradwell(dot)net>, Denis McMahon
>> <denis(dot)m(dot)f(dot)mcmahon(at)gmail(dot)com> wrote:
>>
>>> On Thu, 24 Mar 2011 13:16:33 -0500, Tim wrote:
>>>
>>>> In article <4d8a5c0e$0$23756$14726298(at)news(dot)sunsite(dot)dk>, Jonathan
>>>> Stein <jstein(at)image(dot)dk> wrote:
>>>>
>>>> > On 23-03-2011 19:05, Tim wrote:
>>>> >
>>>> > > I also find it strange, and very frustrating, that I seem to have
>>>> > > to become a php expert just to make this one form page behave the
>>>> > > way I want.
>>>
>>>> > http://www.phpeveryday.com/articles/PHP-Email-Using-Embedded-Images-
> in-
>>> HTML-Em
>>>> > ail-P113.html
>>>
>>>> I looked at that briefly. I hadn't searched for that exact string so
>>>> I suppose that is why I hadn't seen it before.
>>>>
>>>> It is on the right track, though it would require a lot of
>>>> modification to get it to work with my existing code since it uses an
>>>> image located on the server and whose name is known.
>>>
>>> If you don't know what the file name of the image file is, how the heck
>>> do you expect to be able to do anything at all with it?
>>>
>>> Perhaps your questions should start with:
>>>
>>> "How do I find out where the uploaded file is, and what it was called?"
>>>
>>> http://uk2.php.net/manual/en/reserved.variables.files.php
>>>
>>> After you have absorbed that information, perhaps you will then be
>>> ready to ask "How do I use PHP to email this uploaded image to someone
>>> else?"
>
>> Thanks for the concern, but I already have the form and handler code
>> that gets the file's name. I was just pointing out that the example at
>> that link was using a pre-existing image file, rather than an uploaded
>> one, and hard-coding it into the script.
>
> Yes, and? You simply have to write code that uses your filename wherever
> that code uses the hardcoded filename. It's not difficult.
>
>> This is all about getting the data, including the image, to me in the
>> desired format so I can print it out without needing to make
>> modifications to it such as placing the attached image where I want it.
>
> ok, maybe the second question should have been:
>
> "How do I use PHP to email this uploaded image to someone?"
>
> where "someone" might include yourself.
>
> Here's what happens:
>
> File is uploaded in a form. It gets put in a temporary location. The
> $_FILES superglobal contains:
>
> a) original filename from uploading system
> b) mime type
> c) temporary name
> d) status
> e) size
>
> (possibly not in that order)
>
> mime type might not be valid, there's a suggestion it's supplied by the
> uploader. original filename might also not be valid.
>
> First of all you should use move_uploaded_file to put the file in your
> "incoming uploads" directory. At this point, you can also rename it to
> whatever you want to call it. You might or might not choose to use some
> or all of:
>
> uploading system ip
> date and time
> original filename
>
> to create a unique name, after all you can't have two files of the same
> name in your temp dir. Or you could just number incoming files
> sequentially starting at 1. What I'd probably do is make a note of the
> original name, uploaders ip, time and date, create an md5 hash from it
> and use that as the unique filename, and record the original information
> in a log file.
>
> However, as you want to send an email, you could stick that information
> in the message body, together with the unique filename that you gave it
> in your incoming uploads directory
>
> So once you have the file in your incoming uploads directory, with
> whatever filename you choose to give it derived however you decided to
> derive it, you can now, by using a slightly modified version of the email
> example that you have already been provided with, email it to yourself.
>
> We're not expecting you to become an expert, but please, to make the php
> code to do what you want it to, you have to meet it half way and be
> prepared to string a few functions and control statements together.
>
> If you're not capable of editing an example of code that uses a hardcoded
> filename to use a variable one instead, then maybe you need to spend some
> more time getting to grips with the basics of programming concepts and
> editing files, and then the variable naming syntaxes etc of php, before
> you start working on anything as ambitious as form handling, uploaded
> files and sending emails.
>
> Rgds
>
> Denis McMahon
OK. I have some code from the existing form handler page which I copied
and removed everything about sending the email. I added some code for
various things, then tried to test it. Instead of executing the code I
got a redirect to the handler page which was blank.

I am not going to put all the code here to save space, just what I
added or changed since that is what killed it. Oh, yes, I am doing this
on my localhost, and the original handler worked OK.

First there is the validation stuff which checks to see if required
fields are filled in and the image is the correct type. Then the form
entries are placed into variables. Am I right in thinking the $_SERVER
stuff is about uploading the image? This is in the original, but I
included it to ask the question and to show where the variables used
later came from. The original was created with Forms to Go, hence the
$FTG in the variable names.

if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
$clientIP = $_SERVER['HTTP_X_FORWARDED_FOR'];
} else {
$clientIP = $_SERVER['REMOTE_ADDR'];
}

$FTGheadshot = $_FILES['headshot']['name'];
$FTGfirstname = DoStripSlashes( $_POST['firstname'] );
$FTGlastname = DoStripSlashes( $_POST['lastname'] );
$FTGaddress = DoStripSlashes( $_POST['address'] );
$FTGcity = DoStripSlashes( $_POST['city'] );
$FTGstate = DoStripSlashes( $_POST['state'] );
$FTGzip = DoStripSlashes( $_POST['zip'] );
$FTGhomenum = DoStripSlashes( $_POST['homenum'] );
$FTGmaincontact = DoStripSlashes( $_POST['maincontact'] );
$FTGcellnum = DoStripSlashes( $_POST['cellnum'] );
$FTGworknum = DoStripSlashes( $_POST['worknum'] );
$FTGfaxnum = DoStripSlashes( $_POST['faxnum'] );
$FTGemail = DoStripSlashes( $_POST['email'] );

After that I added code that is supposed to save the image to the
directory "profiles/".

# Save image to profiles directory
$path = "profiles/";
$path = $path . basename($FTGheadshot);
if(move_uploaded_file($_FILES['headshot']['tmp_name'], $path)) {
echo "The file ". basename( $_FILES['headshot']['name']).
" has been uploaded";//moves file and notifies if successful
} else{
echo "There was an error uploading the file, please try
again!";//or not
}

This before the validation failure redirect. Should it have been after
that? Should I have the echo if there is no place to display it?

Then comes the validation success line followed by"

$new_profile = $FTGfirstname"_"$FTGlastname".html";
$fh = fopen(profiles/$new_profile, 'w') or die("can't open file");

This should create a new profile html page named
firstname_lastname.html. Did I do that correctly? That is followed with
some fwrite commands to write the html to the file:

fwrite($fh, "<html>\n
<head>\n
<title>"$new_profile"</title>\n
</head>\n
<body>\n");
fwrite($fh, "<table width=\"800\" border=\"1\" cellspacing=\"2\"
cellpadding=\"10\"><tr>\n");
fwrite($fh, "<td>firstname : $FTGfirstname<br />\n
lastname : $FTGlastname<br />\n
address : $FTGaddress<br />\n
city : $FTGcity<br />\n
state : $FTGstate<br />\n
zip : $FTGzip<br />\n
homenum : $FTGhomenum<br />\n
maincontact : $FTGmaincontact<br />\n
cellnum : $FTGcellnum<br />\n
worknum : $FTGworknum<br />\n
faxnum : $FTGfaxnum<br />\n
email : $FTGemail<br /></td>\n");

There is also this line: (inside an fwrite function)

<img
src=\"imgresize.php?w=400&amp;h=500&amp;constrain=1&amp;img=$path\ " />

which is supposed to resize the image to fit the cell using code on an
external page. I know the $path is wrong because it would contain the
name of the image by this point. Should it just be the $FTGheadshot or
$_FILES["headshot"]? Will this work if I don't have sessions enabled? I
just thought of that though nothing was said about it on the site where
I found the code.

After that is the fclose($new_profile). Actually I just noticed I had
put fclose($fh). Then comes:

header("Location: success.php");

followed by the closing } and ?>

Is this enough for someone to see what I did wrong, or do I need to
post the entire page? Or is it just so wrong I need to start over?
Re: CLP - ON TOPIC! - Need PHP form email help, Please! [message #173193 is a reply to message #173192] Sun, 27 March 2011 00:41 Go to previous messageGo to next message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma: 0
Senior Member
On 3/26/2011 6:32 PM, Tim wrote:
> In article<4d8c058d$0$29403$bed64819(at)gradwell(dot)net>, Denis McMahon
> <denis(dot)m(dot)f(dot)mcmahon(at)gmail(dot)com> wrote:
>
>> On Thu, 24 Mar 2011 15:26:21 -0500, Tim wrote:
>>
>>> In article<4d8b8eb6$0$995$bed64819(at)gradwell(dot)net>, Denis McMahon
>>> <denis(dot)m(dot)f(dot)mcmahon(at)gmail(dot)com> wrote:
>>>
>>>> On Thu, 24 Mar 2011 13:16:33 -0500, Tim wrote:
>>>>
>>>> > In article<4d8a5c0e$0$23756$14726298(at)news(dot)sunsite(dot)dk>, Jonathan
>>>> > Stein<jstein(at)image(dot)dk> wrote:
>>>> >
>>>> >> On 23-03-2011 19:05, Tim wrote:
>>>> >>
>>>> >>> I also find it strange, and very frustrating, that I seem to have
>>>> >>> to become a php expert just to make this one form page behave the
>>>> >>> way I want.
>>>>
>>>> >> http://www.phpeveryday.com/articles/PHP-Email-Using-Embedded-Images-
>> in-
>>>> HTML-Em
>>>> >> ail-P113.html
>>>>
>>>> > I looked at that briefly. I hadn't searched for that exact string so
>>>> > I suppose that is why I hadn't seen it before.
>>>> >
>>>> > It is on the right track, though it would require a lot of
>>>> > modification to get it to work with my existing code since it uses an
>>>> > image located on the server and whose name is known.
>>>>
>>>> If you don't know what the file name of the image file is, how the heck
>>>> do you expect to be able to do anything at all with it?
>>>>
>>>> Perhaps your questions should start with:
>>>>
>>>> "How do I find out where the uploaded file is, and what it was called?"
>>>>
>>>> http://uk2.php.net/manual/en/reserved.variables.files.php
>>>>
>>>> After you have absorbed that information, perhaps you will then be
>>>> ready to ask "How do I use PHP to email this uploaded image to someone
>>>> else?"
>>
>>> Thanks for the concern, but I already have the form and handler code
>>> that gets the file's name. I was just pointing out that the example at
>>> that link was using a pre-existing image file, rather than an uploaded
>>> one, and hard-coding it into the script.
>>
>> Yes, and? You simply have to write code that uses your filename wherever
>> that code uses the hardcoded filename. It's not difficult.
>>
>>> This is all about getting the data, including the image, to me in the
>>> desired format so I can print it out without needing to make
>>> modifications to it such as placing the attached image where I want it.
>>
>> ok, maybe the second question should have been:
>>
>> "How do I use PHP to email this uploaded image to someone?"
>>
>> where "someone" might include yourself.
>>
>> Here's what happens:
>>
>> File is uploaded in a form. It gets put in a temporary location. The
>> $_FILES superglobal contains:
>>
>> a) original filename from uploading system
>> b) mime type
>> c) temporary name
>> d) status
>> e) size
>>
>> (possibly not in that order)
>>
>> mime type might not be valid, there's a suggestion it's supplied by the
>> uploader. original filename might also not be valid.
>>
>> First of all you should use move_uploaded_file to put the file in your
>> "incoming uploads" directory. At this point, you can also rename it to
>> whatever you want to call it. You might or might not choose to use some
>> or all of:
>>
>> uploading system ip
>> date and time
>> original filename
>>
>> to create a unique name, after all you can't have two files of the same
>> name in your temp dir. Or you could just number incoming files
>> sequentially starting at 1. What I'd probably do is make a note of the
>> original name, uploaders ip, time and date, create an md5 hash from it
>> and use that as the unique filename, and record the original information
>> in a log file.
>>
>> However, as you want to send an email, you could stick that information
>> in the message body, together with the unique filename that you gave it
>> in your incoming uploads directory
>>
>> So once you have the file in your incoming uploads directory, with
>> whatever filename you choose to give it derived however you decided to
>> derive it, you can now, by using a slightly modified version of the email
>> example that you have already been provided with, email it to yourself.
>>
>> We're not expecting you to become an expert, but please, to make the php
>> code to do what you want it to, you have to meet it half way and be
>> prepared to string a few functions and control statements together.
>>
>> If you're not capable of editing an example of code that uses a hardcoded
>> filename to use a variable one instead, then maybe you need to spend some
>> more time getting to grips with the basics of programming concepts and
>> editing files, and then the variable naming syntaxes etc of php, before
>> you start working on anything as ambitious as form handling, uploaded
>> files and sending emails.
>>
>> Rgds
>>
>> Denis McMahon
> OK. I have some code from the existing form handler page which I copied
> and removed everything about sending the email. I added some code for
> various things, then tried to test it. Instead of executing the code I
> got a redirect to the handler page which was blank.
>
> I am not going to put all the code here to save space, just what I
> added or changed since that is what killed it. Oh, yes, I am doing this
> on my localhost, and the original handler worked OK.
>
> First there is the validation stuff which checks to see if required
> fields are filled in and the image is the correct type. Then the form
> entries are placed into variables. Am I right in thinking the $_SERVER
> stuff is about uploading the image? This is in the original, but I
> included it to ask the question and to show where the variables used
> later came from. The original was created with Forms to Go, hence the
> $FTG in the variable names.
>
> if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
> $clientIP = $_SERVER['HTTP_X_FORWARDED_FOR'];
> } else {
> $clientIP = $_SERVER['REMOTE_ADDR'];
> }
>
> $FTGheadshot = $_FILES['headshot']['name'];
> $FTGfirstname = DoStripSlashes( $_POST['firstname'] );
> $FTGlastname = DoStripSlashes( $_POST['lastname'] );
> $FTGaddress = DoStripSlashes( $_POST['address'] );
> $FTGcity = DoStripSlashes( $_POST['city'] );
> $FTGstate = DoStripSlashes( $_POST['state'] );
> $FTGzip = DoStripSlashes( $_POST['zip'] );
> $FTGhomenum = DoStripSlashes( $_POST['homenum'] );
> $FTGmaincontact = DoStripSlashes( $_POST['maincontact'] );
> $FTGcellnum = DoStripSlashes( $_POST['cellnum'] );
> $FTGworknum = DoStripSlashes( $_POST['worknum'] );
> $FTGfaxnum = DoStripSlashes( $_POST['faxnum'] );
> $FTGemail = DoStripSlashes( $_POST['email'] );
>
> After that I added code that is supposed to save the image to the
> directory "profiles/".
>
> # Save image to profiles directory
> $path = "profiles/";
> $path = $path . basename($FTGheadshot);
> if(move_uploaded_file($_FILES['headshot']['tmp_name'], $path)) {
> echo "The file ". basename( $_FILES['headshot']['name']).
> " has been uploaded";//moves file and notifies if successful
> } else{
> echo "There was an error uploading the file, please try
> again!";//or not
> }
>
> This before the validation failure redirect. Should it have been after
> that? Should I have the echo if there is no place to display it?
>
> Then comes the validation success line followed by"
>
> $new_profile = $FTGfirstname"_"$FTGlastname".html";
> $fh = fopen(profiles/$new_profile, 'w') or die("can't open file");
>
> This should create a new profile html page named
> firstname_lastname.html. Did I do that correctly? That is followed with
> some fwrite commands to write the html to the file:
>
> fwrite($fh, "<html>\n
> <head>\n
> <title>"$new_profile"</title>\n
> </head>\n
> <body>\n");
> fwrite($fh, "<table width=\"800\" border=\"1\" cellspacing=\"2\"
> cellpadding=\"10\"><tr>\n");
> fwrite($fh, "<td>firstname : $FTGfirstname<br />\n
> lastname : $FTGlastname<br />\n
> address : $FTGaddress<br />\n
> city : $FTGcity<br />\n
> state : $FTGstate<br />\n
> zip : $FTGzip<br />\n
> homenum : $FTGhomenum<br />\n
> maincontact : $FTGmaincontact<br />\n
> cellnum : $FTGcellnum<br />\n
> worknum : $FTGworknum<br />\n
> faxnum : $FTGfaxnum<br />\n
> email : $FTGemail<br /></td>\n");
>
> There is also this line: (inside an fwrite function)
>
> <img
> src=\"imgresize.php?w=400&amp;h=500&amp;constrain=1&amp;img=$path\ " />
>
> which is supposed to resize the image to fit the cell using code on an
> external page. I know the $path is wrong because it would contain the
> name of the image by this point. Should it just be the $FTGheadshot or
> $_FILES["headshot"]? Will this work if I don't have sessions enabled? I
> just thought of that though nothing was said about it on the site where
> I found the code.
>
> After that is the fclose($new_profile). Actually I just noticed I had
> put fclose($fh). Then comes:
>
> header("Location: success.php");
>
> followed by the closing } and ?>
>
> Is this enough for someone to see what I did wrong, or do I need to
> post the entire page? Or is it just so wrong I need to start over?

Do you have your code working without any PHP involved? That is, have
you gotten it to work if it's just plain text sent in the email?

As I've told you time and time again - but you refuse to listen. Until
you get your email text working like you want, you're just spinning your
wheels with PHP.

If you would have taken my advice on the 21st when I first sent it,
you'd have this working by now.

As it is, you're no further along than you were when you first asked -
because you're chasing the wrong problem. And if you don't start fixing
the RIGHT problem, you'll still be doing this in another month.

But I know. Some people are just too stoopid to learn. Maybe you need
to explore another line of work.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
Re: CLP - ON TOPIC! - Need PHP form email help, Please! [message #173194 is a reply to message #173192] Sun, 27 March 2011 00:42 Go to previous messageGo to next message
P E Schoen is currently offline  P E Schoen
Messages: 86
Registered: January 2011
Karma: 0
Member
"Tim" wrote in message news:260320111732264412%batwzrd(at)hotmail(dot)com...

> $new_profile = $FTGfirstname"_"$FTGlastname".html";
> $fh = fopen(profiles/$new_profile, 'w') or die("can't open file");

The first argument of fopen() must be a string.

Here is a portion of your code that I ran through an on-line PHP lint:
http://www.icosaedro.it/phplint/phplint-on-line.html

with some corrections and additions:

<?php
#defined dummy function to reduce errors
/*.string.*/ function DoStripSlashes($rawstr) {
return "str"; }

$FTGheadshot = $_FILES['headshot']['name'];
$FTGfirstname = DoStripSlashes( $_POST['firstname'] );
$FTGlastname = DoStripSlashes( $_POST['lastname'] );
$FTGaddress = DoStripSlashes( $_POST['address'] );
$FTGcity = DoStripSlashes( $_POST['city'] );
$FTGstate = DoStripSlashes( $_POST['state'] );
$FTGzip = DoStripSlashes( $_POST['zip'] );
$FTGhomenum = DoStripSlashes( $_POST['homenum'] );
$FTGmaincontact = DoStripSlashes( $_POST['maincontact'] );
$FTGcellnum = DoStripSlashes( $_POST['cellnum'] );
$FTGworknum = DoStripSlashes( $_POST['worknum'] );
$FTGfaxnum = DoStripSlashes( $_POST['faxnum'] );
$FTGemail = DoStripSlashes( $_POST['email'] );

# Save image to profiles directory
$path = "profiles/";
$path = $path . basename($FTGheadshot);
if(move_uploaded_file($_FILES['headshot']['tmp_name'], $path)) {
echo "The file ". basename( $_FILES['headshot']['name']).
" has been uploaded";//moves file and notifies if successful
} else{
echo "There was an error uploading the file, please try again!";//or not
}

# This was very wrong
# $new_profile = $FTGfirstname"_"$FTGlastname".html";

# I'm not sure if this works as desired, but it parses correctly
$new_profile = $FTGfirstname . $FTGlastname . ".html";

$fh = fopen(profiles/$new_profile, 'w') or die("can't open file");
?>

Error report:

$fh = fopen(profiles/$new_profile, 'w') or die("can't open file");
\_ HERE
==== 30: notice: unhandled error(s): E_WARNING

$fh = fopen(profiles/$new_profile, 'w') or die("can't open file");
\_ HERE
==== 30: ERROR: undeclared constant `profiles'

$fh = fopen(profiles/$new_profile, 'w') or die("can't open file");
\_ HERE
==== 30: ERROR: `... / EXPR': found string, expected a number.

$fh = fopen(profiles/$new_profile, 'w') or die("can't open file");
\_ HERE
==== 30: ERROR: `exit()' (aka `die()') isn't a function, it is a statement.
Trying to continue anyway, but probably the result of the expression will be
of the wrong type.

I'm not a PHP expert, but I caught the fopen error without using the lint
utility. And the lint utility gave some very good hints that I did not know,
such as how to declare a function return value as string.

Paul
Re: CLP - ON TOPIC! - Need PHP form email help, Please! [message #173201 is a reply to message #173194] Sun, 27 March 2011 03:13 Go to previous messageGo to next message
Michael Vilain is currently offline  Michael Vilain
Messages: 88
Registered: September 2010
Karma: 0
Member
In article <imm16p$phv$1(at)speranza(dot)aioe(dot)org>,
"PStechPaul" <paul(at)pstech-inc(dot)com> wrote:

> Here is a portion of your code that I ran through an on-line PHP lint:
> http://www.icosaedro.it/phplint/phplint-on-line.html

[draws breath in and moans slightly]

Thanks for this. A very useful resource.

--
DeeDee, don't press that button! DeeDee! NO! Dee...
[I filter all Goggle Groups posts, so any reply may be automatically ignored]
Re: CLP - ON TOPIC! - Need PHP form email help, Please! [message #173202 is a reply to message #173201] Sun, 27 March 2011 03:35 Go to previous messageGo to next message
P E Schoen is currently offline  P E Schoen
Messages: 86
Registered: January 2011
Karma: 0
Member
"Michael Vilain" wrote in message
news:vilain-16411A(dot)20133126032011(at)news(dot)individual(dot)net...

> In article <imm16p$phv$1(at)speranza(dot)aioe(dot)org>,
> "PStechPaul" <paul(at)pstech-inc(dot)com> wrote:

>> Here is a portion of your code that I ran through an on-line PHP lint:
>> http://www.icosaedro.it/phplint/phplint-on-line.html

> [draws breath in and moans slightly]

> Thanks for this. A very useful resource.

Yes, it would have been helpful awhile back, when I was trying to rewrite a
Perl script in PHP. There is also a stand-alone phplint.exe available for
download, and a batch file that can be used to produce a text file with the
parsed and commented results.

I hope the OP makes good use of it.

Paul
Re: CLP - ON TOPIC! - Need PHP form email help, Please! [message #173208 is a reply to message #173193] Sun, 27 March 2011 20:18 Go to previous messageGo to next message
Tim is currently offline  Tim
Messages: 13
Registered: March 2011
Karma: 0
Junior Member
In article <imm148$am5$1(at)dont-email(dot)me>, Jerry Stuckle
<jstucklex(at)attglobal(dot)net> wrote:

> On 3/26/2011 6:32 PM, Tim wrote:
>> In article<4d8c058d$0$29403$bed64819(at)gradwell(dot)net>, Denis McMahon
>> <denis(dot)m(dot)f(dot)mcmahon(at)gmail(dot)com> wrote:
>>
>>> On Thu, 24 Mar 2011 15:26:21 -0500, Tim wrote:
>>>
>>>> In article<4d8b8eb6$0$995$bed64819(at)gradwell(dot)net>, Denis McMahon
>>>> <denis(dot)m(dot)f(dot)mcmahon(at)gmail(dot)com> wrote:
>>>>
>>>> > On Thu, 24 Mar 2011 13:16:33 -0500, Tim wrote:
>>>> >
>>>> >> In article<4d8a5c0e$0$23756$14726298(at)news(dot)sunsite(dot)dk>, Jonathan
>>>> >> Stein<jstein(at)image(dot)dk> wrote:
>>>> >>
>>>> >>> On 23-03-2011 19:05, Tim wrote:
>>>> >>>
>>>> >>>> I also find it strange, and very frustrating, that I seem to have
>>>> >>>> to become a php expert just to make this one form page behave the
>>>> >>>> way I want.
>>>> >
>>>> >>> http://www.phpeveryday.com/articles/PHP-Email-Using-Embedded-Images-
>>> in-
>>>> > HTML-Em
>>>> >>> ail-P113.html
>>>> >
>>>> >> I looked at that briefly. I hadn't searched for that exact string so
>>>> >> I suppose that is why I hadn't seen it before.
>>>> >>
>>>> >> It is on the right track, though it would require a lot of
>>>> >> modification to get it to work with my existing code since it uses an
>>>> >> image located on the server and whose name is known.
>>>> >
>>>> > If you don't know what the file name of the image file is, how the heck
>>>> > do you expect to be able to do anything at all with it?
>>>> >
>>>> > Perhaps your questions should start with:
>>>> >
>>>> > "How do I find out where the uploaded file is, and what it was called?"
>>>> >
>>>> > http://uk2.php.net/manual/en/reserved.variables.files.php
>>>> >
>>>> > After you have absorbed that information, perhaps you will then be
>>>> > ready to ask "How do I use PHP to email this uploaded image to someone
>>>> > else?"
>>>
>>>> Thanks for the concern, but I already have the form and handler code
>>>> that gets the file's name. I was just pointing out that the example at
>>>> that link was using a pre-existing image file, rather than an uploaded
>>>> one, and hard-coding it into the script.
>>>
>>> Yes, and? You simply have to write code that uses your filename wherever
>>> that code uses the hardcoded filename. It's not difficult.
>>>
>>>> This is all about getting the data, including the image, to me in the
>>>> desired format so I can print it out without needing to make
>>>> modifications to it such as placing the attached image where I want it.
>>>
>>> ok, maybe the second question should have been:
>>>
>>> "How do I use PHP to email this uploaded image to someone?"
>>>
>>> where "someone" might include yourself.
>>>
>>> Here's what happens:
>>>
>>> File is uploaded in a form. It gets put in a temporary location. The
>>> $_FILES superglobal contains:
>>>
>>> a) original filename from uploading system
>>> b) mime type
>>> c) temporary name
>>> d) status
>>> e) size
>>>
>>> (possibly not in that order)
>>>
>>> mime type might not be valid, there's a suggestion it's supplied by the
>>> uploader. original filename might also not be valid.
>>>
>>> First of all you should use move_uploaded_file to put the file in your
>>> "incoming uploads" directory. At this point, you can also rename it to
>>> whatever you want to call it. You might or might not choose to use some
>>> or all of:
>>>
>>> uploading system ip
>>> date and time
>>> original filename
>>>
>>> to create a unique name, after all you can't have two files of the same
>>> name in your temp dir. Or you could just number incoming files
>>> sequentially starting at 1. What I'd probably do is make a note of the
>>> original name, uploaders ip, time and date, create an md5 hash from it
>>> and use that as the unique filename, and record the original information
>>> in a log file.
>>>
>>> However, as you want to send an email, you could stick that information
>>> in the message body, together with the unique filename that you gave it
>>> in your incoming uploads directory
>>>
>>> So once you have the file in your incoming uploads directory, with
>>> whatever filename you choose to give it derived however you decided to
>>> derive it, you can now, by using a slightly modified version of the email
>>> example that you have already been provided with, email it to yourself.
>>>
>>> We're not expecting you to become an expert, but please, to make the php
>>> code to do what you want it to, you have to meet it half way and be
>>> prepared to string a few functions and control statements together.
>>>
>>> If you're not capable of editing an example of code that uses a hardcoded
>>> filename to use a variable one instead, then maybe you need to spend some
>>> more time getting to grips with the basics of programming concepts and
>>> editing files, and then the variable naming syntaxes etc of php, before
>>> you start working on anything as ambitious as form handling, uploaded
>>> files and sending emails.
>>>
>>> Rgds
>>>
>>> Denis McMahon
>> OK. I have some code from the existing form handler page which I copied
>> and removed everything about sending the email. I added some code for
>> various things, then tried to test it. Instead of executing the code I
>> got a redirect to the handler page which was blank.
>>
>> I am not going to put all the code here to save space, just what I
>> added or changed since that is what killed it. Oh, yes, I am doing this
>> on my localhost, and the original handler worked OK.
>>
>> First there is the validation stuff which checks to see if required
>> fields are filled in and the image is the correct type. Then the form
>> entries are placed into variables. Am I right in thinking the $_SERVER
>> stuff is about uploading the image? This is in the original, but I
>> included it to ask the question and to show where the variables used
>> later came from. The original was created with Forms to Go, hence the
>> $FTG in the variable names.
>>
>> if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
>> $clientIP = $_SERVER['HTTP_X_FORWARDED_FOR'];
>> } else {
>> $clientIP = $_SERVER['REMOTE_ADDR'];
>> }
>>
>> $FTGheadshot = $_FILES['headshot']['name'];
>> $FTGfirstname = DoStripSlashes( $_POST['firstname'] );
>> $FTGlastname = DoStripSlashes( $_POST['lastname'] );
>> $FTGaddress = DoStripSlashes( $_POST['address'] );
>> $FTGcity = DoStripSlashes( $_POST['city'] );
>> $FTGstate = DoStripSlashes( $_POST['state'] );
>> $FTGzip = DoStripSlashes( $_POST['zip'] );
>> $FTGhomenum = DoStripSlashes( $_POST['homenum'] );
>> $FTGmaincontact = DoStripSlashes( $_POST['maincontact'] );
>> $FTGcellnum = DoStripSlashes( $_POST['cellnum'] );
>> $FTGworknum = DoStripSlashes( $_POST['worknum'] );
>> $FTGfaxnum = DoStripSlashes( $_POST['faxnum'] );
>> $FTGemail = DoStripSlashes( $_POST['email'] );
>>
>> After that I added code that is supposed to save the image to the
>> directory "profiles/".
>>
>> # Save image to profiles directory
>> $path = "profiles/";
>> $path = $path . basename($FTGheadshot);
>> if(move_uploaded_file($_FILES['headshot']['tmp_name'], $path)) {
>> echo "The file ". basename( $_FILES['headshot']['name']).
>> " has been uploaded";//moves file and notifies if successful
>> } else{
>> echo "There was an error uploading the file, please try
>> again!";//or not
>> }
>>
>> This before the validation failure redirect. Should it have been after
>> that? Should I have the echo if there is no place to display it?
>>
>> Then comes the validation success line followed by"
>>
>> $new_profile = $FTGfirstname"_"$FTGlastname".html";
>> $fh = fopen(profiles/$new_profile, 'w') or die("can't open file");
>>
>> This should create a new profile html page named
>> firstname_lastname.html. Did I do that correctly? That is followed with
>> some fwrite commands to write the html to the file:
>>
>> fwrite($fh, "<html>\n
>> <head>\n
>> <title>"$new_profile"</title>\n
>> </head>\n
>> <body>\n");
>> fwrite($fh, "<table width=\"800\" border=\"1\" cellspacing=\"2\"
>> cellpadding=\"10\"><tr>\n");
>> fwrite($fh, "<td>firstname : $FTGfirstname<br />\n
>> lastname : $FTGlastname<br />\n
>> address : $FTGaddress<br />\n
>> city : $FTGcity<br />\n
>> state : $FTGstate<br />\n
>> zip : $FTGzip<br />\n
>> homenum : $FTGhomenum<br />\n
>> maincontact : $FTGmaincontact<br />\n
>> cellnum : $FTGcellnum<br />\n
>> worknum : $FTGworknum<br />\n
>> faxnum : $FTGfaxnum<br />\n
>> email : $FTGemail<br /></td>\n");
>>
>> There is also this line: (inside an fwrite function)
>>
>> <img
>> src=\"imgresize.php?w=400&amp;h=500&amp;constrain=1&amp;img=$path\ " />
>>
>> which is supposed to resize the image to fit the cell using code on an
>> external page. I know the $path is wrong because it would contain the
>> name of the image by this point. Should it just be the $FTGheadshot or
>> $_FILES["headshot"]? Will this work if I don't have sessions enabled? I
>> just thought of that though nothing was said about it on the site where
>> I found the code.
>>
>> After that is the fclose($new_profile). Actually I just noticed I had
>> put fclose($fh). Then comes:
>>
>> header("Location: success.php");
>>
>> followed by the closing } and ?>
>>
>> Is this enough for someone to see what I did wrong, or do I need to
>> post the entire page? Or is it just so wrong I need to start over?
>
> Do you have your code working without any PHP involved? That is, have
> you gotten it to work if it's just plain text sent in the email?
>
> As I've told you time and time again - but you refuse to listen. Until
> you get your email text working like you want, you're just spinning your
> wheels with PHP.
>
> If you would have taken my advice on the 21st when I first sent it,
> you'd have this working by now.
>
> As it is, you're no further along than you were when you first asked -
> because you're chasing the wrong problem. And if you don't start fixing
> the RIGHT problem, you'll still be doing this in another month.
>
> But I know. Some people are just too stoopid to learn. Maybe you need
> to explore another line of work.

Jerry, if you are going to go around calling people "stoopid" maybe you
should at least try to keep up with the conversation. If you had you
would know that your "get your email working without the php" garbage
is not relevant. I stated a couple of postings ago that I was going to
do something different, and if you had actually read my last post you
would have seen that I said in the very first line that I removed all
code having to do with email. (I stated several times, but you refuse
to listen, that the email worked fine in every way other than the
image. That means the text with no php was working from the beginning.
Not that it matters any more.)

And what makes you think this has anything to do with my line of work?
I never said it did. This is just something I thought I might like to
do for a site that is not related to my work in any way, shape, or
form. Your attitude might be a little more understandable if I were
trying to pass myself off as a web developer and leeching off real
coders to get by, but that is not the case and you should not have
jumped to that conclusion without getting more information.

You, sir, are a code-snob. You sit on your throne and look down on
anyone who is not at your level of expertise, as you see it, and tell
them to figure it out on their own. In my case that is like telling me
to become a doctor to get rid of a headache, rather than giving me an
aspirin. I would like this one thing for one page on one site. I have
no aspirations toward becoming a web developer. I am not a threat to
your business. I wouldn't pay someone to do this even if I could afford
to. So your hostility toward me is completely unjustified.
Re: CLP - ON TOPIC! - Need PHP form email help, Please! [message #173209 is a reply to message #173194] Sun, 27 March 2011 20:30 Go to previous messageGo to next message
Tim is currently offline  Tim
Messages: 13
Registered: March 2011
Karma: 0
Junior Member
In article <imm16p$phv$1(at)speranza(dot)aioe(dot)org>, PStechPaul
<paul(at)pstech-inc(dot)com> wrote:

> "Tim" wrote in message news:260320111732264412%batwzrd(at)hotmail(dot)com...
>
>> $new_profile = $FTGfirstname"_"$FTGlastname".html";
>> $fh = fopen(profiles/$new_profile, 'w') or die("can't open file");
>
> The first argument of fopen() must be a string.
>
> Here is a portion of your code that I ran through an on-line PHP lint:
> http://www.icosaedro.it/phplint/phplint-on-line.html
>
> with some corrections and additions:
>
> <?php
> #defined dummy function to reduce errors
> /*.string.*/ function DoStripSlashes($rawstr) {
> return "str"; }
>
> $FTGheadshot = $_FILES['headshot']['name'];
> $FTGfirstname = DoStripSlashes( $_POST['firstname'] );
> $FTGlastname = DoStripSlashes( $_POST['lastname'] );
> $FTGaddress = DoStripSlashes( $_POST['address'] );
> $FTGcity = DoStripSlashes( $_POST['city'] );
> $FTGstate = DoStripSlashes( $_POST['state'] );
> $FTGzip = DoStripSlashes( $_POST['zip'] );
> $FTGhomenum = DoStripSlashes( $_POST['homenum'] );
> $FTGmaincontact = DoStripSlashes( $_POST['maincontact'] );
> $FTGcellnum = DoStripSlashes( $_POST['cellnum'] );
> $FTGworknum = DoStripSlashes( $_POST['worknum'] );
> $FTGfaxnum = DoStripSlashes( $_POST['faxnum'] );
> $FTGemail = DoStripSlashes( $_POST['email'] );
>
> # Save image to profiles directory
> $path = "profiles/";
> $path = $path . basename($FTGheadshot);
> if(move_uploaded_file($_FILES['headshot']['tmp_name'], $path)) {
> echo "The file ". basename( $_FILES['headshot']['name']).
> " has been uploaded";//moves file and notifies if successful
> } else{
> echo "There was an error uploading the file, please try again!";//or not
> }
>
> # This was very wrong
> # $new_profile = $FTGfirstname"_"$FTGlastname".html";
>
> # I'm not sure if this works as desired, but it parses correctly
> $new_profile = $FTGfirstname . $FTGlastname . ".html";
>
> $fh = fopen(profiles/$new_profile, 'w') or die("can't open file");
> ?>
>
> Error report:
>
> $fh = fopen(profiles/$new_profile, 'w') or die("can't open file");
> \_ HERE
> ==== 30: notice: unhandled error(s): E_WARNING
>
> $fh = fopen(profiles/$new_profile, 'w') or die("can't open file");
> \_ HERE
> ==== 30: ERROR: undeclared constant `profiles'
>
> $fh = fopen(profiles/$new_profile, 'w') or die("can't open file");
> \_ HERE
> ==== 30: ERROR: `... / EXPR': found string, expected a number.
>
> $fh = fopen(profiles/$new_profile, 'w') or die("can't open file");
> \_ HERE
> ==== 30: ERROR: `exit()' (aka `die()') isn't a function, it is a statement.
> Trying to continue anyway, but probably the result of the expression will be
> of the wrong type.
>
> I'm not a PHP expert, but I caught the fopen error without using the lint
> utility. And the lint utility gave some very good hints that I did not know,
> such as how to declare a function return value as string.
>
> Paul
>
>
>
Paul, thanks for that link, I will try it out.

Sadly, even I found several errors while cutting and pasting the code
here. Here are some of the changes I have made. I am still working on
it but I think this is closer.

$page_name = $FTGfirstname . $FTGlastname . ".html";

$string1 = "<html>\n
..<head>\n
..<title>$page_name</title>\n
..</head>\n
..<body>\n";
$string2 = "<table width=\"800\" border=\"1\" cellspacing=\"2\"
cellpadding=\"10\"><tr>\n";
$string3 = "<td>firstname : $FTGfirstname<br />\n
..lastname : $FTGlastname<br />\n
..address : $FTGaddress<br />\n
..city : $FTGcity<br />\n
..state : $FTGstate<br />\n
..zip : $FTGzip<br />\n
..homenum : $FTGhomenum<br />\n
..maincontact : $FTGmaincontact<br />\n
..cellnum : $FTGcellnum<br />\n
..worknum : $FTGworknum<br />\n
..faxnum : $FTGfaxnum<br />\n
..email : $FTGemail<br /></td>\n";
$string4 = "<td><img src=$FTGheadshot /><br /></td></tr></table>\n";
$string5 = "<table width=\"800\" border=\"1\" cellspacing=\"2\"
cellpadding=\"10\"><tr><td>\n";

$new_profile = "profiles/$page_name";
$fh = fopen($new_profile, 'w') or die("can't open file");
fwrite($fh, $string1);
fwrite($fh, $string2);
fwrite($fh, $string3);
fwrite($fh, $string4);
fwrite($fh, $string5);

Is this right? $new_profile = "profiles/$page_name";

I've seen it done that way but it just seems wrong. I guess I could put
everything in one string, as the original did, but it seemed so long I
wanted to break it up.
Re: CLP - ON TOPIC! - Need PHP form email help, Please! [message #173210 is a reply to message #173208] Mon, 28 March 2011 01:05 Go to previous messageGo to next message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma: 0
Senior Member
On 3/27/2011 4:18 PM, Tim wrote:

>
> Jerry, if you are going to go around calling people "stoopid" maybe you
> should at least try to keep up with the conversation. If you had you
> would know that your "get your email working without the php" garbage
> is not relevant. I stated a couple of postings ago that I was going to
> do something different, and if you had actually read my last post you
> would have seen that I said in the very first line that I removed all
> code having to do with email. (I stated several times, but you refuse
> to listen, that the email worked fine in every way other than the
> image. That means the text with no php was working from the beginning.
> Not that it matters any more.)
>

I have been keeping up with the conversation. You couldn't get your
original idea working because you were too stoopid to listen to advice
to go to the appropriate newsgroup. So now you're trying to get
something else to work, but failing there too, because you're still
asking in the wrong place.

And you're too stoopid to understand.

And no, the email did not work. "In every other way but the image" was
always your problem - and has EVERYTHING to do with email construction
and NOTHING to do with PHP. But you never listened there, either, and
got it to work from a plain email message.

And no, it doesn't matter to you because you're still not listening, and
still not going to get it to work.

> And what makes you think this has anything to do with my line of work?
> I never said it did. This is just something I thought I might like to
> do for a site that is not related to my work in any way, shape, or
> form. Your attitude might be a little more understandable if I were
> trying to pass myself off as a web developer and leeching off real
> coders to get by, but that is not the case and you should not have
> jumped to that conclusion without getting more information.
>

Then I suggest you let them get somebody competent to do the work for
them and go back to waiting tables or whatever you do.

> You, sir, are a code-snob. You sit on your throne and look down on
> anyone who is not at your level of expertise, as you see it, and tell
> them to figure it out on their own. In my case that is like telling me
> to become a doctor to get rid of a headache, rather than giving me an
> aspirin. I would like this one thing for one page on one site. I have
> no aspirations toward becoming a web developer. I am not a threat to
> your business. I wouldn't pay someone to do this even if I could afford
> to. So your hostility toward me is completely unjustified.

Nope. Unlike you, I KNOW what I'm doing. And I try to help people
where appropriate here, and try to steer them to the appropriate place
when it is not a PHP problem. But there are always idiots like you who
think they know everything and refuse to listen to anyone else.

Here's a clue - YOU have the problem, not ME. I would have had this
fixed within a couple of hours, had it been my job. So would anyone
with any decent competency in html emails. But you're still going to be
screwing around in six months because you won't listen to someone more
knowledgeable than yourself.

Such are stoopid idiots.

Again - my advice - let them get someone HALF-ASSED COMPETENT to do it
for them. That is NOT YOU.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
Re: CLP - ON TOPIC! - Need PHP form email help, Please! [message #173211 is a reply to message #173209] Mon, 28 March 2011 03:08 Go to previous messageGo to next message
P E Schoen is currently offline  P E Schoen
Messages: 86
Registered: January 2011
Karma: 0
Member
"Tim" wrote in message news:270320111530279327%batwzrd(at)hotmail(dot)com...

Paul, thanks for that link, I will try it out.

> Sadly, even I found several errors while cutting and pasting
> the code here. Here are some of the changes I have made.
> I am still working on it but I think this is closer.

> $page_name = $FTGfirstname . $FTGlastname . ".html";

> $string1 = "<html>\n
> .<head>\n
> .<title>$page_name</title>\n
> .</head>\n
> .<body>\n";

[snip]

> $new_profile = "profiles/$page_name";
> $fh = fopen($new_profile, 'w') or die("can't open file");
> fwrite($fh, $string1);

> Is this right? $new_profile = "profiles/$page_name";

> I've seen it done that way but it just seems wrong. I guess
> I could put everything in one string, as the original did, but
> it seemed so long I wanted to break it up.

That seems OK so far, but it is "ugly". A better way is to use a "nowdoc":

$nowdoc = <<<NOWDOC
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>$hTitle</title>
</head>
<body>
<h1>$title</h1>
$msg
</body>
</html>
NOWDOC;

$fh = fopen( "$new_profile", 'w' );
fwrite( $fh, $nowdoc );
fclose($fh);

Also, notice that I have quotes around the $new_profile file name. I'm not
sure that's necessary, but it works. I'm more of a hacker than an expert, so
you will have to use trial and error to get things working. I have also used
a "logfile" which writes certain variables and text messages at key points
in the script.

$fLog = fopen ($logfile, 'w');
// ....
fwrite( $fLog, $new_profile . "\n");
// ....
fclose( $fLog );
exit ;

HTH,

Paul
Re: CLP - ON TOPIC! - Need PHP form email help, Please! [message #173212 is a reply to message #173211] Mon, 28 March 2011 03:38 Go to previous messageGo to previous message
P E Schoen is currently offline  P E Schoen
Messages: 86
Registered: January 2011
Karma: 0
Member
"P E Schoen" wrote in message news:imou4g$4t1$1(at)speranza(dot)aioe(dot)org...

$heredoc = <<<HEREDOC
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>$hTitle</title>
</head>
<body>
<h1>$title</h1>
$msg
</body>
</html>
HEREDOC;

Actually this is a HEREDOC, which expands the variables within the
delimiters. The NOWDOC uses the following syntax:

$value = "Hello World!";
$var = <<<'LABEL'
$value
LABEL;

For more information, see:
http://usrportage.de/archives/884-NOWDOC-+-double-quotes-HEREDOC.html
http://www.electrictoolbox.com/php-nowdoc-string/
http://www.electrictoolbox.com/php-heredoc-string/
http://php.net/manual/en/language.types.string.php

Paul
Pages (2): [1  2    »]  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: ip address of client
Next Topic: Islandnet.com dropping support for PHP4
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Sat Nov 09 08:44:49 GMT 2024

Total time taken to generate the page: 0.03375 seconds