function aform(&$post, $resno, $admin = "") { require_once CORE_DIR . "/postform.php"; $postform = new PostForm(); $post .= "<div id='adminForm' style='display:none; align:center;' />" . $postform->format($resno, $admin) . "</div>"; echo $post; }
public function validationForm($table, $value) { $message = ""; switch ($table) { case 'poste': # code... $message = PostForm::validation($value); break; case 'guard': # code... $message = GuardForm::validation($value); break; case 'guardtours': # code... $message = GuardToursForm::validation($value); break; case 'admin': # code... $message = UserForm::validation($value); break; case 'tours': # code... $message = array('error' => 0); break; default: # code... break; } return $message; }
/** * @param PostForm $form */ public function formSubmitted(PostForm $form) { $values = $form->getValues(); $values->category = $this->categoryFacade->getOne($values->category); $tags = array(); if (count($values->tags)) { foreach ($values->tags as $tagId) { $tags[] = $this->tagFacade->getOne($tagId); } } $values->tags = $tags; try { $this->postManager->update($values); $form->presenter->flashMessage('Post management was successful', 'success'); } catch (\Nette\InvalidArgumentException $ex) { $form->addError($ex->getMessage()); } }
/** * 保存修改 */ function actionSave() { $form = new PostForm($this->_url('save', array('id' => $this->context->id))); try { $data = $form->setValue($this->context)->getValue(); if ($this->context->id) { $post = Post::find('post_id = ?', $this->context->id)->query(); } else { $post = new Post(); } $post->setProps($data); $post->save(); } catch (QValidator_ValidateFailedException $ex) { $this->app->setFlashMessage('下列数据验证失败:' . $ex->__toString()); return $this->_forward('/edit', $form); } $this->app->setFlashMessage('保存成功'); return $this->_redirect($this->_url()); }
/** * Constructor of the class. * @param string $formId * @param string $formName * @param string $uidLabel * @param string $pwdLabel * @param string $moduleName * @param string $formDecoration * @param string $loginMsgId * @param string $formAction */ public function __construct($formId = null, $formName = null, $uidLabel = null, $pwdLabel = null, $moduleName = null, $formDecoration = null, $loginMsgId = null, $formAction = null) { $this->_formId = is_null($formId) ? self::DEFAULT_LOGIN_FORM_ID : $formId; $formName = is_null($formName) ? $this->_formId : $formName; $this->_loginMsgId = is_null($loginMsgId) ? self::DEFAULT_LOEGIN_MESSAGE_ID : $loginMsgId; parent::__construct($formId); $moduleName = !is_null($moduleName) ? $moduleName : MvcReg::getModuleName(); $signInActionName = Authentication::getSignInAction($moduleName); $loginControllerName = Authentication::getLoginController($moduleName); $formAction = is_null($formAction) ? PathService::getFormActionURL($moduleName, $loginControllerName, $signInActionName) : $formAction; if (is_null($uidLabel) || $uidLabel == "") { $uidLabel = self::DEFAULT_UID; } if (is_null($pwdLabel) || $pwdLabel == "") { $pwdLabel = self::DEFAULT_PWD; } $this->_formDecoration = $formDecoration; $this->createForm($formAction, $this->_formId, $formName, $uidLabel, $pwdLabel, $moduleName, $this->_loginMsgId); }
function generate($type, $no, $inIndex = false) { require_once CORE_DIR . "/postform.php"; $dat = '<form name= "delform" action="' . PHP_SELF_ABS . '" method="post">'; $foot = '<table align="right"><tr><td class="delsettings" nowrap="nowrap" align="center"> <input type="hidden" name="mode" value="usrdel" />' . S_REPDEL . '[<input type="checkbox" name="onlyimgdel" value="on" />' . S_DELPICONLY . '] ' . S_DELKEY . '<input type="password" name="pwd" size="8" maxlength="8" value="" /> <input type="submit" value="' . S_DELETE . '" /><input type="button" value="Report" onclick="var o=document.getElementsByTagName(\'INPUT\');for(var i=0;i<o.length;i++)if(o[i].type==\'checkbox\' && o[i].checked && o[i].value==\'delete\') return reppop(\'' . PHP_SELF_ABS . '?mode=report&no=\'+o[i].name+\'\');"></tr></td></form><script>document.delform.pwd.value=l(' . SITE_ROOT . '_pass");</script></td></tr></table>'; if ($type == "index") { return PostForm::format() . $dat . $this->generate_index($no, $inIndex) . $foot; } elseif ($type == "thread") { return PostForm::format($no) . $dat . $this->generate_thread($no, $inIndex) . $foot; } }
display: inline-block; overflow: hidden; } .left, .right{ width: 100%; } .left_coment{ background: blue; display: inline-block; } </style> </head> <body> <form action="index.php" method="POST"> <label for="userName"><p>Введите своё имя</p></label> <input type="text" name="userName" id="userName"> <label for="userMessage"><p>Оставьте своё сообщение</p></label> <textarea name="userMessage" id="userMessage" placeholder="...здесь..." cols=20 rows=5></textarea> <input type="submit" name="submit" value="submit"> </form> <?php echo "<pre>"; $user = new Comments(); $user->userName = $_POST['userName']; $user->userMessage = $_POST['userMessage']; $messages = $user->getMessages(); $messages = $user->addMessage($messages); PostForm::showMessage($messages); ?> </body> </html>
/** * This add a new reply to an existing thread */ public function actionNewReply($id) { $thread = Thread::model()->findByPk($id); if (null == $thread) { throw new CHttpException(404, 'Thread not found.'); } if (!Yii::app()->user->isForumAdmin() && $thread->is_locked) { throw new CHttpException(403, 'Thread is locked.'); } $model = new PostForm(); if (isset($_POST['PostForm'])) { if (!isset($_POST['YII_CSRF_TOKEN']) || $_POST['YII_CSRF_TOKEN'] != Yii::app()->getRequest()->getCsrfToken()) { throw new CHttpException(400, 'Invalid request. Please do not repeat this request again.'); } $model->attributes = $_POST['PostForm']; if ($model->validate()) { $post = new Post(); $post->author_id = Yii::app()->user->id; $post->thread_id = $thread->id; $post->content = $model->content; $post->save(false); $thread->lastPost_user_id = Yii::app()->user->id; $thread->lastPost_time = time(); if (Yii::app()->user->isForumAdmin() && $thread->is_locked != $model->lockthread) { $thread->is_locked = $model->lockthread; } $thread->save(false); $this->redirect($thread->url); } } $this->render('postform', array('thread' => $thread, 'model' => $model)); }
public function actionCreate() { $this->channel = 'contribute'; $form = new PostForm(); if (request()->getIsPostRequest() && isset($_POST['PostForm'])) { $form->attributes = $_POST['PostForm']; if ($form->validate()) { $post = $form->save(); if (!$post->hasErrors()) { user()->setFlash('success_post_id', $post->id); $this->redirect(url('post/success')); exit(0); } } } else { $key = param('sess_post_create_token'); if (!app()->session->contains($key) || empty(app()->session[$key])) { app()->session->add($key, uniqid('beta', true)); } else { $token = app()->session[$key]; $tempPictures = Upload::model()->findAllByAttributes(array('token' => $token)); } } $captchaWidget = $form->hasErrors('captcha') ? $this->widget('BetaCaptcha', array(), true) : $this->widget('BetaCaptcha', array('skin' => 'defaultLazy'), true); $captchaClass = $form->hasErrors('captcha') ? 'error' : 'hide'; $this->setSiteTitle(t('contribute_post')); cs()->registerMetaTag('noindex, follow', 'robots'); $this->render('create', array('form' => $form, 'captchaClass' => $captchaClass, 'captchaWidget' => $captchaWidget, 'tempPictures' => $tempPictures)); }
<?php require 'vendor/autoload.php'; require_once "postform.php"; require_once "datamatriximg.php"; $pf = new PostForm(); if ($pf->validateForm()) { $data = $pf->getPostData(); $dmimg = "d1.png"; //require_once("datamatriximg.php"); $dmImg = new DatamatrixImage(); if ($dmImg->getDatamatrixImg($data, 'img/' . $dmimg, 3)) { header('Location: postblank.php?datamatrix=' . 'img/' . $dmimg); } else { header('Location: err.php'); } exit; } else { ?> <!DOCTYPE html> <html lang="ru"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" type="text/css" href="css/bootstrap.min.css" /> <link rel="stylesheet" type="text/css" href="css/site.css" /> <title>Форма почтового отправления</title> </head>