Topic: Contact Us form not working properly
maw

Noob
Noob
Posts: 5

Posted:
May 05, 2006

I'm hoping someone can help me. I'm a newbie with PostNuke and not a programmer.

I'm using the ContactUs module. By default three fields are given; name, email, message. I need to add four more fields (address, city, state, zip) which I did in the global.php file. I copied the line of code for "Your Name" and then edited the "name part" to be "Your Address" etc. It displays as I like it to on the web site: http://www.gerrirussell.com Click the Contact Us link at the bottom of the page.

When I fill in the fields and click the submit button, an error comes up telling me I need to fill in the Zip Code field. And the zip field is filled in. Needless to say, I can't get past this page and no Thank you message is given. I've gone back to the global.php file and reentered the code but it still isn't working properly.

Any help would be appreciated.Here's the code from the global.php file and below that the code from my index.php file.
Code
  1. <?php
  2.  
  3. /*---FORM-TEXT----------------------------------------------------------*/
  4. define("_MODTITLE", "Feedback Form");   //Title for page
  5. define("_FBFORMMESS", "<b>Feedback | Inquiry Form</b><br>Please enter your name, email, and message below. If your message requires a response we will answer your inquiry as soon as humanly possible. Thank you.");
  6. define("_MODNAME", "Your Name:");
  7. define("_MODADDRESS", "Your Address:");
  8. define("_MODCITY", "Your City:");
  9. define("_MODSTATE", "Your State:");
  10. define("_MODZIP", "Your Zip:");
  11. define("_MODEMAIL", "Your E-mail:");
  12. define("_MODPHONE", "Your Phone:");
  13. define("_MODMESSAGE", "Your message:");
  14. define("_MODSENDFORM", "Send Request");
  15. /*---END-FORM-TEXT------------------------------------------------------*/
  16. /*---ERROR-TEXT---------------------------------------------------------*/
  17. define("_MODPLEASENAME", "Please enter your name!");
  18. define("_MODPLEASEADDRESS", "Please enter your address!");
  19. define("_MODPLEASECITY", "Please enter your city!");
  20. define("_MODPLEASESTATE", "Please enter your state!");
  21. define("_MODPLEASEZIP", "Please enter your zip!");
  22. define("_MODPLEASEEMAIL", "Please enter your e-mail address!");
  23. define("_MODPLEASEMESSAGE", "Please enter a message!");
  24. /*---END-ERROR-TEXT-----------------------------------------------------*/
  25. /*---SENT-TEXT----------------------------------------------------------*/
  26. define("_MODSENT", "Your message has been sent.");
  27. define("_MODTHANK", "We will respond to your request as quickly as possible.");
  28. /*---END-SENT-TEXT------------------------------------------------------*/
  29. define("_CONTACTINFO", "");
  30. ?>


Here's the code from the index.php file
Code
  1. <?
  2. // $Id: index.php,v 1.1.1.1 2001/11/13 01:45:45 acm3 Exp $ $Name:  $
  3.  
  4. $index = "0";
  5. $subject = "Web Site Inquiry";
  6. $mls = false;
  7. if ( isset( $_GET['mls'] ) )
  8. {
  9.     if ( $_GET['mls'] != "" ) $mls = $_GET['mls'];
  10. }
  11. else if ( isset( $_POST['mls'] ) )
  12. {
  13.     if ( $_POST['mls'] != "" ) $mls = $_POST['mls'];
  14. }
  15.  
  16. if ( $mls ) $subject .= ": MLS# " . $mls;
  17.  
  18.   if (!eregi("modules.php", $PHP_SELF)) {
  19.          die ("You can't access this file directly...");
  20.   }
  21.     if(!isset($mainfile)) { include("mainfile.php"); }
  22.     $ModName = basename( dirname( __file__ ) );
  23.    
  24.     if (file_exists("modules/$ModName/lang/$currentlang/global.php"))
  25.      {
  26.       include "modules/$ModName/lang/$currentlang/global.php";
  27.      } else {
  28.         include "modules/$ModName/lang/eng/global.php";
  29.      }
  30.    
  31.     //header
  32.     include("header.php");
  33.    
  34.     echo "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"550\">"
  35.         ."<tr><td align=\"right\" valign=\"top\"><font class=\"pn-logo\">CONTACT US</font></td></tr>"
  36.         ."<tr><td height=\"1\" bgcolor=\"#FFCC00\"><img src=\"images/transparent.gif\" width=\"100%\" height=\"1\"></td></tr>"
  37.         ."<tr><td><br><p><font class=\"pn-normal\">If you have questions about our properties, need to sell yours, or would like to speak to us about the area, please give us a call at the numbers listed below. Or use the contact forum below. We will return your inquiry as soon as possible. You may also use this direct ";
  38.  
  39.  
  40. ?>
  41.  
  42.  
  43. var _u   = 'gerri';
  44. var _d = 'gerrirussell.com';
  45. var _l   = _u + \@\ + _d;
  46. var _m = 'e-mail address';
  47. document.write('<a href=\"mailto:'+_l+'\">'+_m+'</a>');
  48.  
  49.  
  50. <?
  51.  
  52.     echo " if you have any issues using this contact form. Thanks.</font><p><p><font class=\"pn-normal\">Office: <b>434-951-5162</b><br>Toll-Free:<b> 1-800-205-4779</b><br>Mobile: <b>434-531-9581</b></font></p>";
  53.  
  54. $form_block = "
  55. <table width=\"500\" border=\"0\" cellspacing=\"0\" cellpadding=\"10\"><tr><td>
  56. <FORM METHOD=\"post\" ACTION=\"modules.php?op=modload&name=".$ModName."&file=index\">
  57. <INPUT type=\"checkbox\" NAME=\"reloPackage\" VALUE=\"YES\">
  58.       Check here to order your FREE Relocation Package
  59. <P><font class=\"pn-logo-small\">"._MODNAME."</font><br>
  60. <INPUT type=\"text\" NAME=\"sender_name\" VALUE=\"$sender_name\" SIZE=40></p>
  61. <P><font class=\"pn-logo-small\">"._MODADDRESS."</font><br>
  62. <INPUT type=\"text\" NAME=\"sender_address\" VALUE=\"$sender_address\" SIZE=40></p>
  63. <P><font class=\"pn-logo-small\">"._MODCITY."</font><br>
  64. <INPUT type=\"text\" NAME=\"sender_city\" VALUE=\"$sender_city\" SIZE=40></p>
  65. <P><font class=\"pn-logo-small\">"._MODSTATE."</font><br>
  66. <INPUT type=\"text\" NAME=\"sender_state\" VALUE=\"$sender_state\" SIZE=40></p>
  67. <P><font class=\"pn-logo-small\">"._MODZIP."</font><br>
  68. <INPUT type=\"text\" NAME=\"sender_ZIP\" VALUE=\"$sender_ZIP\" SIZE=40></p>
  69. <P><font class=\"pn-logo-small\">"._MODPHONE."</font><br>
  70. <INPUT type=\"text\" NAME=\"sender_phone\" VALUE=\"$sender_phone\" SIZE=40></p>
  71. <P><font class=\"pn-logo-small\">"._MODEMAIL."</font><br>
  72. <INPUT type=\"text\" NAME=\"sender_email\"  VALUE=\"$sender_email\" SIZE=40></p>
  73. <P><font class=\"pn-logo-small\">"._MODMESSAGE."</font><br>
  74. <TEXTAREA NAME=\"message\" COLS=60 ROWS=10 WRAP=virtual>$message</TEXTAREA></p>
  75. <INPUT type=\"hidden\" name=\"opi\" value=\"ds\">
  76. <P><INPUT CLASS=\"pn-button\" TYPE=\"submit\" NAME=\"submit\" VALUE=\""._MODSENDFORM."\"></p>
  77. </td></tr><input type=\"hidden\" name=\"mls\" value=\"".$mls."\"></FORM></table>";
  78.  
  79. if ($opi != "ds")
  80. {
  81.     echo "$form_block";
  82. }
  83.  
  84. else if ($opi == "ds")
  85. {
  86.     if ($sender_name == "")
  87.     {
  88.         $name_err = "<font class=\"pn-normal\">"._MODPLEASENAME."</font><br>";
  89.         $send = "no";
  90.     }
  91.     if ($sender_address == "")
  92.     {
  93.         $name_err = "<font class=\"pn-normal\">"._MODPLEASEADDRESS."</font><br>";
  94.         $send = "no";
  95.     }
  96.    
  97.     if ($sender_city == "")
  98.     {
  99.         $name_err = "<font class=\"pn-normal\">"._MODPLEASECITY."</font><br>";
  100.         $send = "no";
  101.     }
  102.     if ($sender_state == "")
  103.     {
  104.         $name_err = "<font class=\"pn-normal\">"._MODPLEASESTATE."</font><br>";
  105.         $send = "no";
  106.     }
  107.     if ($sender_zip == "")
  108.     {
  109.         $name_err = "<font class=\"pn-normal\">"._MODPLEASEZIP."</font><br>";
  110.         $send = "no";
  111.     }
  112.     if ($sender_email == "")
  113.     {
  114.         $email_err = "<font class=\"pn-normal\">"._MODPLEASEEMAIL."</font><br>";
  115.         $send = "no";
  116.     }
  117.     if ($message == "")
  118.     {
  119.         $message_err = "<font class=\"pn-normal\">"._MODPLEASEMESSAGE."</font><br>";
  120.         $send = "no";
  121.     }
  122. if ($send != "no")
  123.      {
  124.           $msg = "$sitename\n";
  125.           $msg .= "Sender's Name:    $sender_name\n";
  126.           $msg .= "Sender's Address:    $sender_address\n";
  127.           $msg .= "Sender's City:    $sender_city\n";
  128.           $msg .= "Sender's State:    $sender_state\n";
  129.           $msg .= "Sender's Zip:    $sender_zip\n";
  130.           $msg .= "Sender's Phone:    $sender_phone\n";
  131.           $msg .= "Sender's E-Mail:  $sender_email\n";
  132.           // Add the request for a free relocation package.
  133.        $msg .= 'Relocation Package requested: ' . ((isset($_POST['reloPackage']) && ($_POST['reloPackage'] == 'YES')) ? 'Yes' : 'No') . "\n";
  134.  
  135.           $msg .= "Message:          $message\n\n";
  136.        
  137.           $email = "gerri@gerrirussell.com";
  138.           $from = "$sender_email";
  139.           mail($email,$subject,$msg,"From: $from\nReply-To: $from\n");
  140.           echo "<font class=\"pn-normal\"><b>"._MODSENT." </b></font>";
  141.           echo "<font class=\"pn-normal\">"._MODTHANK."</font>";
  142.      }  else if ($send == "no")
  143.     {
  144.         echo "$name_err";
  145.         echo "$email_err";
  146.         echo "$message_err";
  147.         echo "$form_block"
  148.     }
  149. }
  150. ?>
  151.     <p><font class="pn-normal"><?php echo""._CONTACTINFO."" ?></font></p>
  152.     </td></tr></table>
  153.    
  154.     <?
  155.     //end of html insertion
  156.     include("footer.php");
  157. ?>

Chestnut
avatar
Site Admin
Posts: 1320

Posted:
May 05, 2006

Hi Maw...

First, this module looks so old I find it quite incredible that it work on today's PostNuke.

My first suggestion would be to try Formicula http://noc.postnuke.com/projects/formicula/

If you still want to use this one, you should contact the author about the issue you are having. From what I can see, the send_zip is checked to see if it is empty but is never filled before being checked.

A very quick fix (and very temporary I'd say) would be to add after (or almost anywhere in the top of the file) this line :
Code
  1. include("header.php");


This line :
Code
  1. $sender_zip = pnVarCleanFromInput('sender_zip');


That should fix your zip problem... but not necessarily the other potential problems (mostly security). That is why I strongly suggest using formicula instead.

Have fun ! icon_wink

Chestnut ! Cool
Site Admin
maw

Noob
Noob
Posts: 5

Posted:
May 05, 2006

I put this in the global.php but I was told it wasn't supposed to be there because it was already on line 44 of index.php.
include("header.php");
__________________________________
$sender_zip = pnVarCleanFromInput('sender_zip');
I wasn't sure where to put this line of code so this is where I put it.

}
if ($sender_zip == "")
$sender_zip = pnVarCleanFromInput('sender_zip');

{
When I checked it on the site and filled in the fields and hit submit, I still received the error that I needed to fill in the zip field.

Hopefully, it you tell me where it should be positioned in the code, that will be the answer. I must have it in the wrong place in the code.

Your helping me is greatly appreciated.
Mary Ann
Chestnut
avatar
Site Admin
Posts: 1320

Posted:
May 05, 2006

Hi Mary Ann

Well... I must be completly blind because I don't anything at line 44 or even around that is telling the $sender_zip to get its value from the form. In fact, what I can see is that this module won't work anymore in many actual PHP environments because it relies on catching the values that are not necessarily set.

If you still want to use this particular module instead of Formicular, don't be too surprise about what I will tell you to do...

First, revert back your change on the sender_zip to what it was before, you can check your first post to see how it was before.

Next:

Remove all this part:
Code
  1. if ( isset( $_GET['mls'] ) )
  2. {
  3.     if ( $_GET['mls'] != "" ) $mls = $_GET['mls'];
  4. }
  5. else if ( isset( $_POST['mls'] ) )
  6. {
  7.     if ( $_POST['mls'] != "" ) $mls = $_POST['mls'];
  8. }


It's kind of dangerous anyway. (Watch out not to remove more than this).

The part you just remove, replace it with this:
Code
  1. $mls            = pnVarCleanFromInput('mls');
  2. $opi            = pnVarCleanFromInput('opi');
  3. $sender_name    = pnVarCleanFromInput('sender_name');
  4. $sender_address = pnVarCleanFromInput('sender_address');
  5. $sender_city    = pnVarCleanFromInput('sender_city');
  6. $sender_state   = pnVarCleanFromInput('sender_state');
  7. $sender_zip     = pnVarCleanFromInput('sender_zip');
  8. $sender_email   = pnVarCleanFromInput('sender_email');
  9. $message        = pnVarCleanFromInput('message');
  10. $sitename       = pnConfigGetVar('sitename');


Best would still be to try Formicula. icon_wink The module you are trying to use was probably made for PostNuke 0.6x or 0.71x and is incompatible with todays releases.
Hope it helps...


Chestnut ! Cool
Site Admin
maw

Noob
Noob
Posts: 5

Posted:
May 05, 2006

Chestnut,
It still is saying no zip has been input into the field.

I was asked to take over the maintenance of this site because the original programmer didn't have time to work on it. Site was built in 2002.

I went out to Formicula and started to download but then got a little scared. Since I don't know anything about this PostNuke, I didn't know how Formicula would react with PostNuke and would I be in more trouble than I'm in now.

I use Dreamweaver MX 2004 for my other web sites. I did make a Contact Us form in DWMX and thought about uploading it but not into the Modules folder and use a CGI script from Matt's Archives.

Sorry about giving the incorrect info on the line for //header
include("header.php");
It's on line 34 - not 44.

So now, I'm in a quandry and not sure how to proceed.

Mary Ann
Chestnut
avatar
Site Admin
Posts: 1320

Posted:
May 05, 2006

maw
Sorry about giving the incorrect info on the line for //header
include("header.php");
It's on line 34 - not 44.


That line won't give the zip anyway...

Houla... went to your site and I can see that formicula wouldn't work anyway. Your PostNuke is very very old and I also can understand why the zip is always empty even with the modifications I gave you...

Well, one possible last change could be to replace the part I gave you last time by this :

Code
  1. $mls            = $_POST['mls'];
  2. $opi            = $_POST['opi'];
  3. $sender_name    = $_POST['sender_name'];
  4. $sender_address = $_POST['sender_address'];
  5. $sender_city    = $_POST['sender_city'];
  6. $sender_state   = $_POST['sender_state'];
  7. $sender_zip     = $_POST['sender_zip'];
  8. $sender_email   = $_POST['sender_email'];
  9. $message        = $_POST['message'];
  10. $sitename       = pnConfigGetVar('sitename');


It might work...

But one priority would be to upgrade PostNuke as soon as you are familiar with it.

Official site where you'll probably get more help than I can give you. icon_wink
http://www.postnuke.com
http://community.postnuke.com (Support forum)

P.S. : The site reminds me of something, it's not the first time I've seen it.


Chestnut ! Cool
Site Admin
maw

Noob
Noob
Posts: 5

Posted:
May 05, 2006

I'm sorry but that didn't work either. I'll paste my code just to make sure I haven't corrupted the code. Thank you for letting me know that Formulica isn't compatible with this archaic version of PostNuke.

If I've corrupted the code, could you please direct me how to correct it. Do you think I need to paste the code for global.php? I don't believe that code is controlling the zip field. It looks to me as if it's controlling the look of the form and the sending of the form and telling me my errors.

I've taken too much of your time and I do appreciate the direction you've given me. If this doesn't work with the current code, then I've decided to just use the Dreamweaver MX04 code and say I've given up with PostNuke.
Here's the code for index.php
Code
  1. <?
  2. // $Id: index.php,v 1.1.1.1 2001/11/13 01:45:45 acm3 Exp $ $Name:  $
  3.  
  4. $index = "0";
  5. $subject = "Web Site Inquiry";
  6. $mls = false;
  7. $mls            = $_POST['mls'];
  8. $opi            = $_POST['opi'];
  9. $sender_name    = $_POST['sender_name'];
  10. $sender_address = $_POST['sender_address'];
  11. $sender_city    = $_POST['sender_city'];
  12. $sender_state   = $_POST['sender_state'];
  13. $sender_zip     = $_POST['sender_zip'];
  14. $sender_email   = $_POST['sender_email'];
  15. $message        = $_POST['message'];
  16. $sitename       = pnConfigGetVar('sitename')
  17.  
  18. if ( $mls ) $subject .= ": MLS# " . $mls;
  19.  
  20.   if (!eregi("modules.php", $PHP_SELF)) {
  21.          die ("You can't access this file directly...");
  22.   }
  23.     if(!isset($mainfile)) { include("mainfile.php"); }
  24.     $ModName = basename( dirname( __file__ ) );
  25.    
  26.     if (file_exists("modules/$ModName/lang/$currentlang/global.php"))
  27.      {
  28.       include "modules/$ModName/lang/$currentlang/global.php";
  29.      } else {
  30.         include "modules/$ModName/lang/eng/global.php";
  31.      }
  32.    
  33.     //header
  34.     include("header.php");
  35.    
  36.     echo "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"550\">"
  37.         ."<tr><td align=\"right\" valign=\"top\"><font class=\"pn-logo\">CONTACT US</font></td></tr>"
  38.         ."<tr><td height=\"1\" bgcolor=\"#FFCC00\"><img src=\"images/transparent.gif\" width=\"100%\" height=\"1\"></td></tr>"
  39.         ."<tr><td><br><p><font class=\"pn-normal\">If you have questions about our properties, need to sell yours, or would like to speak to us about the area, please give us a call at the numbers listed below. Or use the contact forum below. We will return your inquiry as soon as possible. You may also use this direct ";
  40.  
  41.  
  42. ?>
  43.  
  44.  
  45. var _u   = 'gerri';
  46. var _d = 'gerrirussell.com';
  47. var _l   = _u + \@\ + _d;
  48. var _m = 'e-mail address';
  49. document.write('<a href=\"mailto:'+_l+'\">'+_m+'</a>');
  50.  
  51.  
  52. <?
  53.  
  54.     echo " if you have any issues using this contact form. Thanks.</font><p><p><font class=\"pn-normal\">Office: <b>434-951-5162</b><br>Toll-Free:<b> 1-800-205-4779</b><br>Mobile: <b>434-531-9581</b></font></p>";
  55.  
  56. $form_block = "
  57. <table width=\"500\" border=\"0\" cellspacing=\"0\" cellpadding=\"10\"><tr><td>
  58. <FORM METHOD=\"post\" ACTION=\"modules.php?op=modload&name=".$ModName."&file=index\">
  59. <INPUT type=\"checkbox\" NAME=\"reloPackage\" VALUE=\"YES\">
  60.       Check here to order your FREE Relocation Package
  61. <P><font class=\"pn-logo-small\">"._MODNAME."</font><br>
  62. <INPUT type=\"text\" NAME=\"sender_name\" VALUE=\"$sender_name\" SIZE=40></p>
  63. <P><font class=\"pn-logo-small\">"._MODADDRESS."</font><br>
  64. <INPUT type=\"text\" NAME=\"sender_address\" VALUE=\"$sender_address\" SIZE=40></p>
  65. <P><font class=\"pn-logo-small\">"._MODCITY."</font><br>
  66. <INPUT type=\"text\" NAME=\"sender_city\" VALUE=\"$sender_city\" SIZE=40></p>
  67. <P><font class=\"pn-logo-small\">"._MODSTATE."</font><br>
  68. <INPUT type=\"text\" NAME=\"sender_state\" VALUE=\"$sender_state\" SIZE=40></p>
  69. <P><font class=\"pn-logo-small\">"._MODZIP."</font><br>
  70. <INPUT type=\"text\" NAME=\"sender_ZIP\" VALUE=\"$sender_ZIP\" SIZE=40></p>
  71. <P><font class=\"pn-logo-small\">"._MODPHONE."</font><br>
  72. <INPUT type=\"text\" NAME=\"sender_phone\" VALUE=\"$sender_phone\" SIZE=40></p>
  73. <P><font class=\"pn-logo-small\">"._MODEMAIL."</font><br>
  74. <INPUT type=\"text\" NAME=\"sender_email\"  VALUE=\"$sender_email\" SIZE=40></p>
  75. <P><font class=\"pn-logo-small\">"._MODMESSAGE."</font><br>
  76. <TEXTAREA NAME=\"message\" COLS=60 ROWS=10 WRAP=virtual>$message</TEXTAREA></p>
  77. <INPUT type=\"hidden\" name=\"opi\" value=\"ds\">
  78. <P><INPUT CLASS=\"pn-button\" TYPE=\"submit\" NAME=\"submit\" VALUE=\""._MODSENDFORM."\"></p>
  79. </td></tr><input type=\"hidden\" name=\"mls\" value=\"".$mls."\"></FORM></table>";
  80.  
  81. if ($opi != "ds")
  82. {
  83.     echo "$form_block";
  84. }
  85.  
  86. else if ($opi == "ds")
  87. {
  88.     if ($sender_name == "")
  89.     {
  90.         $name_err = "<font class=\"pn-normal\">"._MODPLEASENAME."</font><br>";
  91.         $send = "no";
  92.     }
  93.     if ($sender_address == "")
  94.     {
  95.         $name_err = "<font class=\"pn-normal\">"._MODPLEASEADDRESS."</font><br>";
  96.         $send = "no";
  97.     }
  98.    
  99.     if ($sender_city == "")
  100.     {
  101.         $name_err = "<font class=\"pn-normal\">"._MODPLEASECITY."</font><br>";
  102.         $send = "no";
  103.     }
  104.     if ($sender_state == ""