gpt4 book ai didi

php - Controller 不在 phalcon php 中显示消息

转载 作者:搜寻专家 更新时间:2023-10-31 20:38:41 25 4
gpt4 key购买 nike

我试图在 Phalcon PHP 框架中做一个简单的例子,所以我有一个 View ,其中包含两个字段名称和电子邮件以及一个提交按钮。当我单击此按钮时,将调用 Controller 的功能以将名称和电子邮件存储在数据库中。这个 Action 进行得很顺利,问题是我试图在 Action 结束后显示一条消息,但我仍然有包含表单(姓名、电子邮件)的 View 。这是我的代码。

我的结帐 Controller 。

<?php

class CheckoutController extends \Phalcon\Mvc\Controller
{

public function indexAction()
{


}

public function registerAction()
{
$email = new Emails();

//Stocker l'email et vérifier les erreurs
$success = $email->save($this->request->getPost(), array('name', 'email'));

if ($success) {
echo "Thanks for shopping with us!";
} else {
echo "Sorry:";
foreach ($user->getMessages() as $message) {
echo $message->getMessage(), "<br/>";
}
}

}

}

View

<!DOCTYPE html>
<html>
<head>
<title>Yuzu Test</title>
</head>
<body>
<?php use Phalcon\Tag; ?>

<h2>Checkout</h2>

<?php echo Tag::form("checkout/register"); ?>

<td>
<tr>
<label for="name">Name: </label>
<?php echo Tag::textField("name") ?>
</tr>
</td>

<td>
<tr>
<label for="name">E-Mail: </label>
<?php echo Tag::textField("email") ?>
</tr>
</td>

<td>
<tr>
<?php echo Tag::submitButton("Checkout") ?>
</tr>
</td>

</form>

</body>
</html>

最佳答案

您可以使用 Flash Messages ,因此您不必中断应用程序流程。问候

关于php - Controller 不在 phalcon php 中显示消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29013251/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com