Form not working

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • sunny152
    Sergeant First Class

    • Jan 2007
    • 52

    Form not working

    I have created simple form using name,email,comments and i created seperate web pages as
    name_error.html,email_error.html,comments_error,co nfirmationpage.html

    The code inserted in processingpage.php as

    <?PHP
    // Receiving variables
    @$name = addslashes($_POST['name']);
    @$email = addslashes($_POST['email']);
    @$comments = addslashes($_POST['comments']);
    // error checking
    if (strlen($name) == 0 )
    {
    header("Location: name_error.html");
    exit;
    }
    if (strlen($email) == 0 )
    {
    header("Location: email_error.html");
    exit;
    }
    if (! ereg('[A-Za-z0-9_-]+\@[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+', $email))
    {
    header("Location: email_error.html");
    exit;
    }
    if (substr_count($comments, '@') > "2")
    {
    header("Location: comments_error.html");
    exit;
    }
    //Sending Email to form owner
    $mailto = "sunny152s@rediffmail.com";
    $mailsubj = "FEEDBACK";
    $mailhead = "From: $email\n";
    reset ($HTTP_POST_VARS);
    $mailbody = "Values from my website form:\n";
    while (list ($key, $val) = each ($HTTP_POST_VARS))
    {
    if ($key!="submit")
    {
    $mailbody .= "$key : $val\n";
    }
    }
    mail($mailto, $mailsubj, $mailbody, $mailhead);
    // Autoresponder
    $mailto = $email;
    $mailsubj = "Copy of the info you Submitted";
    $mailhead = "From: website form\n";
    mail($mailto, $mailsubj, $mailbody, $mailhead);
    header("Location: confirmationpage.html");
    ?>

    Now,the email error,name error and comments error messages are working well but when the visitor types his name,email,comments and press submit button,then the error message getting is

    PHP Warning: reset() [function.reset]: Passed variable is not an array or object in H:\Websites\LocalUser\wesleychurch\processingpage. php on line 31 PHP Warning: Variable passed to each() is not an array or object in H:\Websites\LocalUser\wesleychurch\processingpage. php on line 33 PHP Warning: mail() [function.mail]: SMTP server response: 551 This mail server requires authentication before sending mail from a locally hosted domain. Please reconfigure your mail client to authenticate before sending mail. in H:\Websites\LocalUser\wesleychurch\processingpage. php on line 40 PHP Warning: mail() [function.mail]: SMTP server response: 551 This mail server requires authentication before sending mail from a locally hosted domain. Please reconfigure your mail client to authenticate before sending mail. in H:\Websites\LocalUser\wesleychurch\processingpage. php on line 45

    Please help.

    Thanks,
    Sunny
    Last edited by sunny152; 01-04-2008, 06:45 PM. Reason: typing mistake
  • navaldesign
    General & Forum Moderator

    • Oct 2005
    • 12080

    #2
    Re: Form not working

    Hm...

    You have two problems.

    1. Seems like your php version doesn't recognoze the $HTTP_POST_VARS as an array. Try replacing it with $_REQUEST . Which version of php do you run ?

    2. The second is a bigger problem (maybe). Your server (local computer?) is set to require SMTP authentication. The only way to overcome this is to use a specific script that supports SMTP authentication, like php mailer or Zend Mailer. If you don't have coding experience, this might prove a bit problematic.
    Navaldesign
    Logger Lite: Low Cost, Customizable, multifeatured Login script
    Instant Download Cart: a Powerfull, Customized, in site, DB driven, e-products Cart
    DBTechnosystems.com Forms, Databases, Shopping Carts, Instant Download Carts, Loggin Systems and more....
    Advanced BlueVoda Form Processor : No coding form processor! Just install and use! Now with built in CAPTCHA!

    Comment

    • sunny152
      Sergeant First Class

      • Jan 2007
      • 52

      #3
      Re: Form not working

      I tried replacing the code,but still not working.Any solution to this problem?
      Sunny

      Comment

      • navaldesign
        General & Forum Moderator

        • Oct 2005
        • 12080

        #4
        Re: Form not working

        Is this a published webpage ? or are you running it locally in your computer ?

        If published, please provide a link.
        Navaldesign
        Logger Lite: Low Cost, Customizable, multifeatured Login script
        Instant Download Cart: a Powerfull, Customized, in site, DB driven, e-products Cart
        DBTechnosystems.com Forms, Databases, Shopping Carts, Instant Download Carts, Loggin Systems and more....
        Advanced BlueVoda Form Processor : No coding form processor! Just install and use! Now with built in CAPTCHA!

        Comment

        • sunny152
          Sergeant First Class

          • Jan 2007
          • 52

          #5
          Re: Form not working

          Here is the link,



          The modified PHP code is

          <?PHP
          // Receiving variables
          @$name = addslashes($_POST['name']);
          @$email = addslashes($_POST['email']);
          @$comments = addslashes($_POST['comments']);
          // error checking
          if (strlen($name) == 0 )
          {
          header("Location: name_error.html");
          exit;
          }
          if (strlen($email) == 0 )
          {
          header("Location: email_error.html");
          exit;
          }
          if (! ereg('[A-Za-z0-9_-]+\@[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+', $email))
          {
          header("Location: email_error.html");
          exit;
          }
          if (substr_count($comments, '@') > "2")
          {
          header("Location: comments_error.html");
          exit;
          }
          //Sending Email to form owner
          $mailto = "sunny152s@rediffmail.com";
          $mailsubj = "FEEDBACK";
          $mailhead = "From: $email\n";
          reset ($HTTP_POST_VARS);
          $mailbody = "Values from my website form:\n";
          while (list ($key, $val) = each ($_REQUEST ))
          {
          if ($key!="submit")
          {
          $mailbody .= "$key : $val\n";
          }
          }
          mail($mailto, $mailsubj, $mailbody, $mailhead);
          // Autoresponder
          $mailto = $email;
          $mailsubj = "Copy of the info you Submitted";
          $mailhead = "From: website form\n";
          mail($mailto, $mailsubj, $mailbody, $mailhead);
          header("Location: confirmationpage.html");
          ?>

          Comment

          • Watdaflip
            Major General

            • Sep 2005
            • 2116

            #6
            Re: Form not working

            Naval was saying to replace $HTTP_POST_VARS in this line

            reset ($HTTP_POST_VARS);

            Not in this line

            while (list ($key, $val) = each ($HTTP_POST_VARS))

            Anyway, are the variables being posted, the only reason I can think of that it would toss up that error is if nothing was posted and it was just empty, but even then it still should have had the array defined.

            Register/Login Script
            Do you use a Password Protected Directory? Need a way to allow users to make their own account, try my .htaccess Login Script

            Comment

            • navaldesign
              General & Forum Moderator

              • Oct 2005
              • 12080

              #7
              Re: Form not working

              From what i see on your site, replacing $HTTP_POST_VARS in one line has solved part of the problem (You no longer have the second error message:

              PHP Warning: Variable passed to each() is not an array or object in H:\Websites\LocalUser\wesleychurch\processingpage. php on line 33

              So I suggest that you also do the same for the other line:

              reset ($_REQUEST); instead of reset ($HTTP_POST_VARS);


              However, even if this solves this part, the main problem, that of the SMTP authentication still remains and i believe that it will be your main problem.

              My only guess about the array problem is that you are running a particular php version that doesn't have (recognize) the $HTTP_POST_VARS global.
              Navaldesign
              Logger Lite: Low Cost, Customizable, multifeatured Login script
              Instant Download Cart: a Powerfull, Customized, in site, DB driven, e-products Cart
              DBTechnosystems.com Forms, Databases, Shopping Carts, Instant Download Carts, Loggin Systems and more....
              Advanced BlueVoda Form Processor : No coding form processor! Just install and use! Now with built in CAPTCHA!

              Comment

              • sunny152
                Sergeant First Class

                • Jan 2007
                • 52

                #8
                Re: Form not working

                My server upgraded PHP from version 4.4.7 to 5.2.5.So can anybody please modify this PHP code to 5.2.5 version,Here is the PHP code-


                <?PHP
                // Receiving variables
                @$name = addslashes($_POST['name']);
                @$email = addslashes($_POST['email']);
                @$comments = addslashes($_POST['comments']);
                // error checking
                if (strlen($name) == 0 )
                {
                header("Location: name_error.html");
                exit;
                }
                if (strlen($email) == 0 )
                {
                header("Location: email_error.html");
                exit;
                }
                if (! ereg('[A-Za-z0-9_-]+\@[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+', $email))
                {
                header("Location: email_error.html");
                exit;
                }
                if (substr_count($comments, '@') > "2")
                {
                header("Location: comments_error.html");
                exit;
                }
                //Sending Email to form owner
                $mailto = "sunny152s@rediffmail.com";
                $mailsubj = "Feedback from my website form";
                $mailhead = "From: $email\n";
                reset ($HTTP_POST_VARS);
                $mailbody = "Values from my website form:\n";
                while (list ($key, $val) = each ($HTTP_POST_VARS))
                {
                if ($key!="submit")
                {
                $mailbody .= "$key : $val\n";
                }
                }
                mail($mailto, $mailsubj, $mailbody, $mailhead);
                // Autoresponder
                $mailto = $email;
                $mailsubj = "Copy of the info you Submitted";
                $mailhead = "From: website form\n";
                mail($mailto, $mailsubj, $mailbody, $mailhead);
                header("Location: confirmationpage.html");

                Comment

                • navaldesign
                  General & Forum Moderator

                  • Oct 2005
                  • 12080

                  #9
                  Re: Form not working

                  This code SHOULD work with php v 5. If it doesn't then there is some further problem. Anyway, as i said, this script will NOT work in any case, because your hosting company requires SMTP authentication. Please read above, you will need a specialized script with a mailer class that provides SMTP authentication. If you can't make it this way, ask support from your hosting company, to provide you with instructions on how to use sendmail or any other script they have in cgi bin that provides this functionality.
                  Navaldesign
                  Logger Lite: Low Cost, Customizable, multifeatured Login script
                  Instant Download Cart: a Powerfull, Customized, in site, DB driven, e-products Cart
                  DBTechnosystems.com Forms, Databases, Shopping Carts, Instant Download Carts, Loggin Systems and more....
                  Advanced BlueVoda Form Processor : No coding form processor! Just install and use! Now with built in CAPTCHA!

                  Comment

                  • roadwarrior
                    Private

                    • Feb 2008
                    • 3

                    #10
                    Re: Form not working

                    I have the same problem with the same hosting. I'm trying to use a e-mail form and a newsletter script and neither of them work, I always get the error:

                    "PHP Warning: mail() [<a href='function.mail'>function.mail</a>]: SMTP server response: 551 This mail server requires authentication before sending mail from a locally hosted domain. Please reconfigure your mail client to authenticate before sending mail. in H:\Domains\DOMAIN\wwwroot\test\admin\SMLmailer.cla ss.php on line 165"

                    Anyone knows how to fix it?

                    Comment

                    • navaldesign
                      General & Forum Moderator

                      • Oct 2005
                      • 12080

                      #11
                      Re: Form not working

                      You need to use a SMTP supporting class. Try phpmailer . Google it.
                      Navaldesign
                      Logger Lite: Low Cost, Customizable, multifeatured Login script
                      Instant Download Cart: a Powerfull, Customized, in site, DB driven, e-products Cart
                      DBTechnosystems.com Forms, Databases, Shopping Carts, Instant Download Carts, Loggin Systems and more....
                      Advanced BlueVoda Form Processor : No coding form processor! Just install and use! Now with built in CAPTCHA!

                      Comment

                      • roadwarrior
                        Private

                        • Feb 2008
                        • 3

                        #12
                        Re: Form not working

                        I dont understand some stuff in the installation (Im not a pro in this)

                        this are the instructions:

                        "Copy class.phpmailer.php into your php.ini include_path. If you are
                        using the SMTP mailer then place class.smtp.php in your path as well.
                        In the language directory you will find several files like
                        phpmailer.lang-en.php. If you look right before the .php extension
                        that there are two letters. These represent the language type of the
                        translation file. For instance "en" is the English file and "br" is
                        the Portuguese file. Chose the file that best fits with your language
                        and place it in the PHP include path. If your language is English
                        then you have nothing more to do. If it is a different language then
                        you must point PHPMailer to the correct translation."

                        where is (or what is) the php.ini include_path? cause its not in my wwwroot or anywhere inside of it.

                        Comment

                        Working...
                        X