PHP mailform

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

Moderator: General Moderators

User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

What are the errors?

Mac
Bjarnat
Forum Newbie
Posts: 22
Joined: Wed Jan 22, 2003 8:21 am

Post by Bjarnat »

Hi Mac,

If you don't mind please visit the followin url

http://ski.voices-of-europe.de/checkout.php

once you finish the form just click at the "missing" image directly under the "comments"

Thanks for your help again!
Bjarnat
Forum Newbie
Posts: 22
Joined: Wed Jan 22, 2003 8:21 am

Post by Bjarnat »

Sorry!

The link to the page should be as follows:

http://ski.voices-of-europe.de/checkouten.htm
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

Have you created a header and footer and put the paths to these in $header and $footer, ie, here:

Code: Select all

$header = "header.html"; 
$footer = "footer.html";
Mac
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

Actually having looked at the code again there doesn't seem to be any passing of these variables, for example, this function:

Code: Select all

function doFormError($errString) { 

include($header); 

echo "<FONT SIZE=+2>The form you submitted was not complete.<BR><BR></FONT>"; 
echo "$errString<BR><BR>\n"; 
echo "<INPUT TYPE=BUTTON ONCLICK='history.back()' VALUE=' Return to the checkout page '><HR>"; 

include($footer); 

exit; 
}
should have an additional line added underneath the function definition:

Code: Select all

function doFormError($errString) {
    global $header, $footer; // without this the function can't use these variables
The same problem occurs in the doError function too.

Mac
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

Finally, try adding the following:

Code: Select all

extract($_POST);
above this line:

Code: Select all

if (($b_first == "") || ($b_last == "") || ($b_addr == "") ||
 ($b_city == "") || ($b_state == "") || ($b_zip == "") || 
($b_phone == "") || ($b_email == "")) {
Mac
Bjarnat
Forum Newbie
Posts: 22
Joined: Wed Jan 22, 2003 8:21 am

Post by Bjarnat »

Hi Mac,

Thanks for your time.

I did includ the first piece of code

global $header, $footer;

and now I am only getting the that my form was incomplete, although I filled in everything!?

As per the other code that you suggested I should include, can you tell me where in the code these should go?

Thanks!!!
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

Put it above the line I indicated beneath the big block of comments that looks like this:

Code: Select all

//############################################################## 
//############################################################## 
//### MAIN ### 
//############################################################## 
//##############################################################
Mac
Bjarnat
Forum Newbie
Posts: 22
Joined: Wed Jan 22, 2003 8:21 am

Post by Bjarnat »

Yes, I did that and now I get the following

Parse error: parse error, unexpected $ in /home/www/voices-of-europe.de/subs/ski/htdocs/checkout.php on line 393


????
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

Could you post the 5 lines of code above and below the line you added (as well as the line of course).

Mac
Bjarnat
Forum Newbie
Posts: 22
Joined: Wed Jan 22, 2003 8:21 am

Post by Bjarnat »

Hi Mac

below you'll find complete lines

Thanks!
Bjarnat
Forum Newbie
Posts: 22
Joined: Wed Jan 22, 2003 8:21 am

Post by Bjarnat »

function doFormError($errString) {

global $header, $footer;


include($header);

echo "<FONT SIZE=+2>The form you submitted was not complete.<BR><BR></FONT>";
echo "$errString<BR><BR>\n";
echo "<INPUT TYPE=BUTTON ONCLICK='history.back()' VALUE=' Return to the checkout page '><HR>";

include($footer);

exit;
}
Bjarnat
Forum Newbie
Posts: 22
Joined: Wed Jan 22, 2003 8:21 am

Post by Bjarnat »

if (($b_first == "") || ($b_last == "") || ($b_addr == "") ||
($b_city == "") || ($b_state == "") || ($b_zip == "") ||
($b_phone == "") || ($b_email == "")) {


extract($_POST);




if (($b_first == "") || ($b_last == "") || ($b_addr == "") || ($b_city == "") || ($b_state == "") || ($b_zip == "") || ($b_phone == "") || ($b_email == "")) {
doFormError("I'm sorry, but it appears that you forgot to fill in a required field. Please go <A HREF='Javascript:history.go(-1);'>back</A> and correct the error.");
exit;
}

//# checks for valid email address
if( !(ereg("^(.+)@(.+)\\.(.+)$",$b_email)) ) {
doFormError("You submitted an invalid email address. Please go <A HREF='Javascript:history.go(-1);'>back</A> and correct the error.");
exit;
}
Bjarnat
Forum Newbie
Posts: 22
Joined: Wed Jan 22, 2003 8:21 am

Post by Bjarnat »

Just a question. Would this have anything to do with the following:


in my checkout form I have a postal code first where a state is

and a coutry where a zip is

in php form ???
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

You need to remove this:

Code: Select all

if (($b_first == "") || ($b_last == "") || ($b_addr == "") || 
($b_city == "") || ($b_state == "") || ($b_zip == "") || 
($b_phone == "") || ($b_email == "")) {
from above

Code: Select all

extract($_POST);
sorry that was the line from your code I was trying to indicate that the extract() line should be placed above.

Mac
Post Reply