TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 03-11-2008, 11:54 AM   #1 (permalink)
The Visitor
 
Join Date: Mar 2008
Posts: 4
Thanks: 2
krum is on a distinguished road
Default POST Metod in Zend Framework

Can you show me some example how to get variables with POST Method.
krum is offline  
Reply With Quote
Old 03-11-2008, 12:05 PM   #2 (permalink)
Alan @ CIT
Member of the Month
The Frequenter
Member of the Month Top Contributor 
 
Alan @ CIT's Avatar
 
Join Date: Apr 2005
Location: South UK
Posts: 483
Thanks: 51
Alan @ CIT is on a distinguished road
Default

Hi Krum,

Here is a small example:

PHP Code:
<?php
class IndexController extends Zend_Controller_Action
{
    public function 
indexAction()
    {
        
// Our post array: ['name'] => 'Alan', ['country'] => 'UK'
        
        // Check for a POST request
        
if ($this->_request->isPost())
        {
            
// Get the 'name' and 'country' values from the $_POST array
            
$name $this->_request->getPost('name');
            
$country $this->_request->getPost('country');
            
            echo 
'Hello ' $name ' from ' $country '!';            
        }

    }
}
Edit: (and Welcome to TalkPHP )

Alan
Send a message via MSN to Alan @ CIT
Alan @ CIT is offline  
Reply With Quote
The Following User Says Thank You to Alan @ CIT For This Useful Post:
krum (03-11-2008)
Old 03-11-2008, 12:13 PM   #3 (permalink)
The Visitor
 
Join Date: Mar 2008
Posts: 4
Thanks: 2
krum is on a distinguished road
Default

Thanks Alan, I work on mail form, so my problem is how to connect controller with view index page.
krum is offline  
Reply With Quote
Old 03-11-2008, 12:23 PM   #4 (permalink)
Alan @ CIT
Member of the Month
The Frequenter
Member of the Month Top Contributor 
 
Alan @ CIT's Avatar
 
Join Date: Apr 2005
Location: South UK
Posts: 483
Thanks: 51
Alan @ CIT is on a distinguished road
Default

Hi Krum,

I'm not sure what you mean. Are you trying to include the output from your mail controller in your index view?

If so, take a look at the ActionStack helper. This should do what you need.

Alan
Send a message via MSN to Alan @ CIT
Alan @ CIT is offline  
Reply With Quote
The Following User Says Thank You to Alan @ CIT For This Useful Post:
krum (03-11-2008)
Old 03-11-2008, 12:37 PM   #5 (permalink)
The Visitor
 
Join Date: Mar 2008
Posts: 4
Thanks: 2
krum is on a distinguished road
Default

Thanks Alan, I have mail form, where user will send mail to me,(mail, name, subjet, body...). So I want to take data with post method in controller and send email. I will send code that I want to use with Zend Framework.
<html>
<body>

Code:
<?php
if (isset($_REQUEST['email']))
//if "email" is filled out, send email
  {
  //send email
  $email = $_REQUEST['email'] ;
  $subject = $_REQUEST['subject'] ;
  $message = $_REQUEST['message'] ;
  mail( "krum@example.com", "Subject: $subject",
  $message, "From: $email" );
  echo "Your email is send";
  }
else
//if "email" is not filled out, display the form
  {
  echo "<form method='post' action='mailform.php'>
  Email: <input name='email' type='text' /><br />
  Subject: <input name='subject' type='text' /><br />
  Message:<br />
  <textarea name='message' rows='15' cols='40'>
  </textarea><br />
  <input type='submit' />
  </form>";
  }
?>

</body>
</html>

Last edited by Wildhoney : 03-11-2008 at 03:13 PM.
krum is offline  
Reply With Quote
Old 03-11-2008, 03:17 PM   #6 (permalink)
The Visitor
 
Join Date: Mar 2008
Posts: 4
Thanks: 2
krum is on a distinguished road
Default

Thanks Alan, it help me a lot.

Quote:
Originally Posted by Alan @ CIT View Post
Hi Krum,

Here is a small example:

PHP Code:
<?php
class IndexController extends Zend_Controller_Action
{
    public function 
indexAction()
    {
        
// Our post array: ['name'] => 'Alan', ['country'] => 'UK'
        
        // Check for a POST request
        
if ($this->_request->isPost())
        {
            
// Get the 'name' and 'country' values from the $_POST array
            
$name $this->_request->getPost('name');
            
$country $this->_request->getPost('country');
            
            echo 
'Hello ' $name ' from ' $country '!';            
        }

    }
}
Edit: (and Welcome to TalkPHP )

Alan
krum is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 03:49 AM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design