Forums
This topic is locked
PHP-FormMail Edition - No mail
Posted 24 May 2002 13:55:21
1
has voted
24 May 2002 13:55:21 Ken Carter posted:
I am trying to debug the problems I'm having with PHP FormMail Edition and have created a simple page that has but one form, one text field, and a submit button. The code fromt hat page follows this message.After creating this page I uploaded it and the include file to the server using Dreamweavers publishing function. When asked if I wanted to send all dependent files I responded yes. It then propmpted me for an over write of the existing include file on the server, to which I responded yes.
I loaded the page from the server and filed in some text. Then hit the submit button. Result was that this page does the same thing as the page that I am having problems with, absolutly nothing.
I'm putting the code below in hopes that you might be able to tell me what I am doing to mess this up as I know that this extenion worked like a dream before.
Thanks,
Ken...
Code from test.php
<?php
# PHP Mailer - Form Mailer Edition v1.0
# Copyright 2001. Tim Green. All rights reserved.
# Developed in collaboration with Kenny.
if (isset($PHP_MAIL_FORM)) {
include("classes/tgMailClass.php"
$tgFormMail=new phpMailer();
$mailto= " ";
$subject="test message";
$from=" ";
$tgFormMail_sent ="";
if ($from ==""{
$lol =$HTTP_HOST;
$a = str_replace ("www.","",$lol);
$replaced = "webmaster@$a";
$from = $replaced;
}
if($subject ==""{
$subject ="Server Generated Email";
}
$i=0;
$arr = array($HTTP_POST_VARS);
while(list($key, $val) = each($HTTP_POST_VARS)) {
$mex = $mex."$key: $val\n";
}
$tgFormMail->AddSender($from,$HTTP_HOST);
$tgFormMail->AddAddress($mailto,$mailto);
$tgFormMail->SetSubject($subject);
$tgFormMail->AddBody($mex);
$tgFormMail->Send();
if($tgFormMail_sent != ""{
header("Location: $tgFormMail_sent"
}
}
?>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<form name="form1" method="post" action="">
<input type="text" name="textfield">
<input type="submit" name="Submit" value="View Results">
<input type="hidden" name="PHP_MAIL_FORM" value="true">
</form>
</body>
</html>
Replies
Replied 24 May 2002 15:27:03
24 May 2002 15:27:03 Ken Carter replied:
I've determined by testing the same code on a different domain that this is NOT a code problem and is related to the configuration of the server it runs on.
I've compaired the two domains extensively and the only thing that I can see that is different is that user scripting is turned off on the domain that this script fails to work on.
I've sent a message to the admin for the web hosting company that hosts both the test domain and the client domain that this script is being used for and am waiting for them to get back to me on it.
Sorry for all the messages related to this. I felt that I must have broken the script at some point and was bound and determined to fix the problem that I had created; only it turns out that the problem was caused by the provider of the web hosing.
Thanks again for all the the help. I will post a follow up message when I have some information as to what broke this script on the server side.
Regards,
Ken...
I've compaired the two domains extensively and the only thing that I can see that is different is that user scripting is turned off on the domain that this script fails to work on.
I've sent a message to the admin for the web hosting company that hosts both the test domain and the client domain that this script is being used for and am waiting for them to get back to me on it.
Sorry for all the messages related to this. I felt that I must have broken the script at some point and was bound and determined to fix the problem that I had created; only it turns out that the problem was caused by the provider of the web hosing.
Thanks again for all the the help. I will post a follow up message when I have some information as to what broke this script on the server side.
Regards,
Ken...
Replied 25 May 2002 01:36:08
25 May 2002 01:36:08 Tim Green replied:
No worries Ken. Thanks for keeping us posted.
I hope the hosting company sort out your problem with expediency <img src=../images/dmxzone/forum/icon_smile_wink.gif border=0 align=middle>
Cheers!
Tim Green
Extension & PHP TalkZone Manager
<font size=1>-------------------------------------------
<i>Please read the Forum FAQ before posting
a question to this TalkZone.</i>
-------------------------------------------
www.UDzone.com : A dynamic Dreamweaver,
Ultradev and Fireworks site for developers
by developers.
-------------------------------------------</font id=size1>
I hope the hosting company sort out your problem with expediency <img src=../images/dmxzone/forum/icon_smile_wink.gif border=0 align=middle>
Cheers!
Tim Green
Extension & PHP TalkZone Manager
<font size=1>-------------------------------------------
<i>Please read the Forum FAQ before posting
a question to this TalkZone.</i>
-------------------------------------------
www.UDzone.com : A dynamic Dreamweaver,
Ultradev and Fireworks site for developers
by developers.
-------------------------------------------</font id=size1>
Replied 25 May 2002 02:18:24
25 May 2002 02:18:24 Ken Carter replied:
Well nothing as of yet. The hosting administrator is telling me that everything is just fine on their side! <img src=../images/dmxzone/forum/icon_smile_angry.gif border=0 align=middle>
I thought perhaps it was the directory/file permissions on the include file and opened that up a little further to make sure that that didn't happer the processing of the script.
The two domains are setting on the same server with the same everything. Admin claims all is the same on thier end and I can't see anything differernt on my side. Even after checking and checking it over and over.
Sad part is that it cost me 4 days of work, and the client missed a deadline for a newspaper ad to run this weekend for the site (a holiday weekend here in the US). Some days you could just scream!
Thanks Tim, I'll update here as I have more news. Are there specific dependencies that I should be looking at for this?
Thanks again,
Ken...
I thought perhaps it was the directory/file permissions on the include file and opened that up a little further to make sure that that didn't happer the processing of the script.
The two domains are setting on the same server with the same everything. Admin claims all is the same on thier end and I can't see anything differernt on my side. Even after checking and checking it over and over.
Sad part is that it cost me 4 days of work, and the client missed a deadline for a newspaper ad to run this weekend for the site (a holiday weekend here in the US). Some days you could just scream!
Thanks Tim, I'll update here as I have more news. Are there specific dependencies that I should be looking at for this?
Thanks again,
Ken...
Replied 25 May 2002 04:25:43
25 May 2002 04:25:43 Ken Carter replied:
Tim,
It is back in my court and I am just stymied at this point. Working with the system admin on the web host we finally got the problems resolved. However, now I've confirmed that all my tweaking has broken the code I had in place prior to the server glitch.
I can make the form send the email by removing redirect code from the form tag. ie:
Changing:
<form name="form1" method="post" action="result.php">
To:
<form name="form1" method="post" action="">
This will result in the form content being emailed as it should with some minor errors (I'll go over that seperately later in this message).
The problem is that either way you are redirected to result.php, however if the action= is not populated then result.php will be loaded without the post information that is provide by the action= being set.
If I change it back to:
<form name="form1" method="post" action="result.php">
I then get the results in the result.php code but no email is sent by the script.
So the delema is that I can produce mail or I can display results but not both, wheich was the intent of this in the first place.
Is there some way that I can format the header statement to post information from this form to result.php?
Minor Error:
With each succesfful email sent I am seeing 4 error message in imp mail. All are identical The error messages read.
Warning: Unexpected characters at end of address: (errflg=3) in Unknown on line 0
This is more of an anoyance than anything else. My big concern is to get the mail sending and the result.php the post information it needs to complete its work.
Thanks,
Ken...
It is back in my court and I am just stymied at this point. Working with the system admin on the web host we finally got the problems resolved. However, now I've confirmed that all my tweaking has broken the code I had in place prior to the server glitch.
I can make the form send the email by removing redirect code from the form tag. ie:
Changing:
<form name="form1" method="post" action="result.php">
To:
<form name="form1" method="post" action="">
This will result in the form content being emailed as it should with some minor errors (I'll go over that seperately later in this message).
The problem is that either way you are redirected to result.php, however if the action= is not populated then result.php will be loaded without the post information that is provide by the action= being set.
If I change it back to:
<form name="form1" method="post" action="result.php">
I then get the results in the result.php code but no email is sent by the script.
So the delema is that I can produce mail or I can display results but not both, wheich was the intent of this in the first place.
Is there some way that I can format the header statement to post information from this form to result.php?
Minor Error:
With each succesfful email sent I am seeing 4 error message in imp mail. All are identical The error messages read.
Warning: Unexpected characters at end of address: (errflg=3) in Unknown on line 0
This is more of an anoyance than anything else. My big concern is to get the mail sending and the result.php the post information it needs to complete its work.
Thanks,
Ken...
Replied 25 May 2002 23:30:25
25 May 2002 23:30:25 Tim Green replied:
Ken,
Setting the action of the form to anything other than <?php echo $PHP_SELF; ?> will result in the email not being sent.
This is because the extension posts the PHP code to the beginning of the page, and it is only activated when the form is submitted to itself.
I suspect if you put <?php echo $PHP_SELF; ?> as the action of the form this will resolve your isse as far as the redirect is concerned.
To then send redirect to the success page you need to change the line:-
$tgFormMail_sent ="";
to:-
$tgFormMail_sent = "result.php";
If you need to preserve the submitted forms contents for sending to that page then before this line add some code similar to the following:-
$preserve = array();
while (list($key,$value) = $HTTP_POST_VARS) {
$preserve[] = $key . "=" . $value;
}
$preservedVals = implode("&",$preserve);
and then you need to change:-
$tgFormMail_sent = "result.php";
to:-
$tgFormMail_sent = "result.php?" . $preservedVals;
This should give you the functionality you require.
I hope this helps.
Tim Green
Extension & PHP TalkZone Manager
<font size=1>-------------------------------------------
<i>Please read the Forum FAQ before posting
a question to this TalkZone.</i>
-------------------------------------------
www.UDzone.com : A dynamic Dreamweaver,
Ultradev and Fireworks site for developers
by developers.
-------------------------------------------</font id=size1>
Edited by - rawveg on 26 May 2002 00:23:05
Setting the action of the form to anything other than <?php echo $PHP_SELF; ?> will result in the email not being sent.
This is because the extension posts the PHP code to the beginning of the page, and it is only activated when the form is submitted to itself.
I suspect if you put <?php echo $PHP_SELF; ?> as the action of the form this will resolve your isse as far as the redirect is concerned.
To then send redirect to the success page you need to change the line:-
$tgFormMail_sent ="";
to:-
$tgFormMail_sent = "result.php";
If you need to preserve the submitted forms contents for sending to that page then before this line add some code similar to the following:-
$preserve = array();
while (list($key,$value) = $HTTP_POST_VARS) {
$preserve[] = $key . "=" . $value;
}
$preservedVals = implode("&",$preserve);
and then you need to change:-
$tgFormMail_sent = "result.php";
to:-
$tgFormMail_sent = "result.php?" . $preservedVals;
This should give you the functionality you require.
I hope this helps.
Tim Green
Extension & PHP TalkZone Manager
<font size=1>-------------------------------------------
<i>Please read the Forum FAQ before posting
a question to this TalkZone.</i>
-------------------------------------------
www.UDzone.com : A dynamic Dreamweaver,
Ultradev and Fireworks site for developers
by developers.
-------------------------------------------</font id=size1>
Edited by - rawveg on 26 May 2002 00:23:05
Replied 28 May 2002 01:45:24
28 May 2002 01:45:24 Ken Carter replied:
Tim,
Thanks! Time to close this thread. I looked over your suggestions and then thought about my design for this paticular solution. Another idea hit me so I did some heavy mods to the two pages and built my own mail function into the script without using the extension. This is working perfectly.
A lot of my problems in this case is that I was trying to take the extension and do something different from its design. This is a lesson I have never fully learned.
I wanted to let you know what I did to accomplish my goals with this set of pages, but at the same time wanted to reinforce for anyone reading this tread that your extesnions have always proven to be solid tools from the experience that I have had with them today. And this case was not a problem with your code. Great stuff! I just tend to push the envelope more than I should at times.
Well I'm done with this part of the site. I'm working on the cart now so I'll see you over in the support forum for that on rawveg if I need any assistance. (actually have a stupid question to post there when I get done here. )
Thanks for all the great help Tim!
Regards,
Ken...
Thanks! Time to close this thread. I looked over your suggestions and then thought about my design for this paticular solution. Another idea hit me so I did some heavy mods to the two pages and built my own mail function into the script without using the extension. This is working perfectly.
A lot of my problems in this case is that I was trying to take the extension and do something different from its design. This is a lesson I have never fully learned.
I wanted to let you know what I did to accomplish my goals with this set of pages, but at the same time wanted to reinforce for anyone reading this tread that your extesnions have always proven to be solid tools from the experience that I have had with them today. And this case was not a problem with your code. Great stuff! I just tend to push the envelope more than I should at times.
Well I'm done with this part of the site. I'm working on the cart now so I'll see you over in the support forum for that on rawveg if I need any assistance. (actually have a stupid question to post there when I get done here. )
Thanks for all the great help Tim!
Regards,
Ken...