Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > HTML > Re: PHP Send mail problems.

Reply
Thread Tools

Re: PHP Send mail problems.

 
 
Doug Miller
Guest
Posts: n/a
 
      08-03-2010
In article <>, "" <> wrote:
>On Tue, 03 Aug 2010 13:42:57 GMT, (Doug Miller)
>wrote:
>
>>In article <>, ""

> <> wrote:
>>>
>>>>> >
>>>>> >Nothing _at all_? Do you mean that the PHP script that is the form action
>>> is
>>>>> >never invoked?
>>>>>
>>>>> Probably not. Nothing apears to happen. No email arrives.
>>>>>
>>>>
>>>>It does invoke the script. However what happens after that is anyone's
>>>>guess as we can't see your php. If you leave all fields blank with
>>>>Chrome you get the error message, 'text field is empty', which is
>>>>generated by send_dj.php.
>>>
>>>
>>>I didn't get ANY error message.

>>
>>Then turn error reporting on, either in php.ini or in the script itself, so
>>you can see what's going wrong. Put some echo commands into the script at
>>various points so you can verify its progress.

>
>How do I turn on error reporting in the script?


http://lmgtfy.com/?q=turn+on+error+reporting+in+php

>And when you say an
>echo command, you mean it would put a message on screen? TIA.


Yes, of course. Alternatively, you could write to the error log.
 
Reply With Quote
 
 
 
 
Jonathan N. Little
Guest
Posts: n/a
 
      08-03-2010
ing wrote:
>
>>>>
>>>> Nothing _at all_? Do you mean that the PHP script that is the form action is
>>>> never invoked?
>>>
>>> Probably not. Nothing apears to happen. No email arrives.
>>>

>>
>> It does invoke the script. However what happens after that is anyone's
>> guess as we can't see your php. If you leave all fields blank with
>> Chrome you get the error message, 'text field is empty', which is
>> generated by send_dj.php.


That is because the only error handling the OP is doing is making the
script die. I listed what he needed to do in post:

<http://groups.google.com/group/alt.html/msg/e88015a2452e2288>


>
>
> I didn't get ANY error message. And my PHP script was in the original
> posting. I have duplicated below. Thanks.
>
> <?php
> //--------------------------Set these
> paramaters--------------------------
>
> // Subject of email sent to you.
> $subject = 'DJ';
>
> // Your email address. This is where the form information will be
> sent.
> $emailadd = '';
>
> // Where to redirect after form is processed.
> $url = 'Thank you.htm';
>
> // Makes all fields required. If set to '1' no field can not be empty.
> If set to '0' any or all fields can be empty.
> $req = '1';
>
> // --------------------------Do not edit below this
> line--------------------------
> $text = "Results from form:\n\n";
> $space = ' ';
> $line = '
> ';
> foreach ($_POST as $key => $value)
> {
> if ($req == '1')
> {
> if ($value == '')
> {echo "$key is empty";die;}


This is NOT effective error handling in a production script.

> }
> $j = strlen($key);
> if ($j>= 20)
> {echo "Name of form element $key cannot be longer than 20
> characters";die;}
> $j = 20 - $j;
> for ($i = 1; $i<= $j; $i++)
> {$space .= ' ';}
> $value = str_replace('\n', "$line", $value);
> $conc = "{$key}:$space{$value}$line";
> $text .= $conc;
> $space = ' ';
> }
> mail($emailadd, $subject, $text, 'From: '.$emailadd.'');
> echo '<META HTTP-EQUIV=Refresh CONTENT="0; URL='.$url.'">';
> ?>
>
> The last line has since been replaced as per Jonathon's suggestion.


Then why are you show that meta tag hack instead of the header command
that I showed you?

header("Location: $url");

--
Take care,

Jonathan
-------------------
LITTLE WORKS STUDIO
http://www.LittleWorksStudio.com
 
Reply With Quote
 
 
 
 
Jonathan N. Little
Guest
Posts: n/a
 
      08-03-2010
ing wrote:
> On Tue, 03 Aug 2010 13:42:57 GMT, (Doug Miller)
> wrote:
>
>> In article< >, ""<> wrote:


<snip>

>>>
>>> I didn't get ANY error message.

>>
>> Then turn error reporting on, either in php.ini or in the script itself, so
>> you can see what's going wrong. Put some echo commands into the script at
>> various points so you can verify its progress.

>
> How do I turn on error reporting in the script? And when you say an
> echo command, you mean it would put a message on screen? TIA.


Again I posted complete references on how to do this?

<http://groups.google.com/group/alt.html/msg/35770c5805905fe9>

Did you not read any of this?

--
Take care,

Jonathan
-------------------
LITTLE WORKS STUDIO
http://www.LittleWorksStudio.com
 
Reply With Quote
 
Peter
Guest
Posts: n/a
 
      08-04-2010
In article <>,
ing says...
>
> >> >
> >> >Nothing _at all_? Do you mean that the PHP script that is the form action is
> >> >never invoked?
> >>
> >> Probably not. Nothing apears to happen. No email arrives.
> >>

> >
> >It does invoke the script. However what happens after that is anyone's
> >guess as we can't see your php. If you leave all fields blank with
> >Chrome you get the error message, 'text field is empty', which is
> >generated by send_dj.php.

>
>
> I didn't get ANY error message. And my PHP script was in the original
> posting. I have duplicated below. Thanks.
>
> <?php
> //--------------------------Set these
> paramaters--------------------------
>
> // Subject of email sent to you.
> $subject = 'DJ';
>
> // Your email address. This is where the form information will be
> sent.
> $emailadd = '';
>
> // Where to redirect after form is processed.
> $url = 'Thank you.htm';
>
> // Makes all fields required. If set to '1' no field can not be empty.
> If set to '0' any or all fields can be empty.
> $req = '1';
>
> // --------------------------Do not edit below this
> line--------------------------
> $text = "Results from form:\n\n";
> $space = ' ';
> $line = '
> ';
> foreach ($_POST as $key => $value)
> {
> if ($req == '1')
> {
> if ($value == '')
> {echo "$key is empty";die;}
> }
> $j = strlen($key);
> if ($j >= 20)
> {echo "Name of form element $key cannot be longer than 20
> characters";die;}
> $j = 20 - $j;
> for ($i = 1; $i <= $j; $i++)
> {$space .= ' ';}
> $value = str_replace('\n', "$line", $value);
> $conc = "{$key}:$space{$value}$line";
> $text .= $conc;
> $space = ' ';
> }
> mail($emailadd, $subject, $text, 'From: '.$emailadd.'');


Personally I would change that header part of the mail to

$headers = 'From: '.$emailadd;

mail($emailadd, $subject, $text, $headers);

> echo '<META HTTP-EQUIV=Refresh CONTENT="0; URL='.$url.'">';
> ?>
>
> The last line has since been replaced as per Jonathon's suggestion.
>


--
Pete Ives
Remove All_stRESS before sending me an email
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: HELP: PHP Send mail problems. Doug Miller HTML 9 08-04-2010 09:55 PM
Re: HELP: PHP Send mail problems. Jonathan N. Little HTML 2 08-02-2010 03:53 PM
PHP Training Institute In Delhi, Live Projects on PHP. Short TermPHP Courses, PHP Scripts, PHP Training with Live Projects. Rajive Narain Java 0 09-18-2009 10:47 AM
Send mail using System.Web.Mail fails w/ m.BodyFormat=MailFormat.H =?Utf-8?B?Unlhbg==?= ASP .Net 2 02-28-2006 01:50 AM
Mail.SmtpMail.Send won't send to one of my addresses Nathan Sokalski ASP .Net 3 11-23-2005 09:25 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57