Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9136911
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T09:01:03+00:00 2026-06-17T09:01:03+00:00

I started learning Zend so this is the link i followed for the contact

  • 0

I started learning Zend so this is the link i followed for the contact us page –

My Zend Version – Zend Framework v1.11.11

http://www.tutorial-portal.com/tutorial/show/id/27

I created form using command line – zf create form Contact which successfully created folder forms under which Contact.php File. Code in Contact.php is as follows –

<?php

class Application_Form_Contact extends Zend_Form
{

    public function init()
    {
        /* Form Elements & Other Definitions Here ... */
        $this->setmethod('post');
        $this->setName('contact-form');

        $this->addElement('text', 'name', array(
                            'label' => 'Please enter your name',
                            'required' => true,
                         ));


        $this->addElement('text', 'email', array(
                            'label' => 'Please enter email address',
                            'required' => true,
                            'validators' => array('EmailAddress'),
                         ));

        $this->addElement('textarea', 'message', array(
                            'label' => 'Please enter your message',
                            'required' => true,
                            'validators' => array( array('validator' => 'StringLength', 'options' => array(0, 20) )
                         ));

        $this->addElement('captcha', 'captcha', array(
                            'label'      => 'Please enter the 5 letters displayed below:',
                            'required'   => true,
                            'captcha'    => array('captcha' => 'Figlet','wordLen' => 5,'timeout' => 300 )
                        ));                                      

        $this->addElement('submit', 'submit', array(
                            'ignore'   => true,
                            'label'    => 'Send Message',
                        ));

        $this->addElement('hash', 'csrf', array(
                            'ignore' => true,
                        ));
    }               
}

Now I created a controller ContactController.php under C:\xampp\htdocs\projectone\application\controllers. Code in this controller goes like this –

<?php

class ContactController extends Zend_Controller_Action
{

    public function init()
    {
        /* Initialize action controller here */
        //$form  = new Application_Form_Contact();
        //$this->view->form = $form;

    }

    public function indexAction()
    {
        // action body
        // Create form instance
        $form = new Application_Form_Contact();

        /**
         * Get request
         */
        $request = $this->getRequest();
        $post = $request->getPost(); // This contains the POST params

        /**
         * Check if form was sent
         */
        if ($request->isPost()) {
            /**
             * Check if form is valid
             */
            if ($form->isValid($post)) {
                // build message
                $message = 'From: ' . $post['name'] . chr(10) . 'Email: ' . $post['email'] . chr(10) . 'Message: ' . $post['message'];
                // send mail
                mail('contact@yourwebsite.com', 'contact: ' . $post['subject'], $message);
            }
        }

        // give form to view (needed in index.phtml file)
        $this->view->form = $form;

    }

}

Code in index.phtml under the folder structure C:\xampp\htdocs\projectone\application\views\scripts\contact goes like this – echoing the code in php tags – echo $this->form

But this is not working at all 🙁 really unable to locate what i am doing wrong.

Its only showing a blank page, and nothing even simple html content.

This is the URL im using, although rest controllers working fine –

http://localhost/projectone/public/contact

PS– Since I am a starter in Zend, I dont know where & how to look for Zend errors, let me know this also 🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T09:01:03+00:00Added an answer on June 17, 2026 at 9:01 am

    After performing various heuristics, and checking the code at various levels I am able to debug my code. Problem actually was in this LOC –

    BUG –

        $this->addElement('textarea', 'message', array(
                            'label' => 'Please enter your message',
                            'required' => true,
                            'validators' => array( array('validator' => 'StringLength', 'options' => array(0, 20) )
                         ));
    

    REMOVE

    'validators' => array( array('validator' => 'StringLength', 'options' => array(0, 20) )
    

    and all goes well like a charm.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I started learning Jquery mobile, I followed this http://dev.jtsage.com/jQM-SimpleDialog/demos/string.html . Nothing happens when I
I have started learning zend framework. I am using version 1.12. I am using
I started learning today 3D drawing, following this tut: http://www.riemers.net/eng/Tutorials/XNA/Csharp/Series1/The_first_triangle.php There is the file
I'm new to PHP and I recently started learning Zend Framework. What DAL are
I have started learning Zend Framework, Now I have created few almost 6 projects
i have learned MVC Architecture from Zend Framework, and i just started learning in
I just started learning the zend framework and what im wondering is , is
I have just started learning python version 3 and trying to create a file
I've just started learning ruby, so this question is simple. I created @subject in
Started learning Rails, so may this question is obsolete but yet I want to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.