php - 创建通知并将输入列表存储在框中
问题描述
<?php
session_start();
function submitform()
{
if(isset($_POST['submit']))
{
notify('positive','hello'.$_POST['name']);
}
}
function notify($type = 'neutral', $message = 'Hello')
{
$_SESSION['notify']['type'] = $type;
$_SESSION['notify']['message'] = $message;
}
function notifcation()
{
if(isset($_SESSION['notify']))
{
$type = $_SESSION['notify']['type'];
$message = $_SESSION['notify']['message'];
$html = '<div class="notify'.$type.'">'.$message.'</div>';
echo $html;
}
}
?>
测试.php
<?php require 'functions.php' ?>
<html>
<head>
<title>Notification bar</title>
<link rel="stylesheet" href="" />
</head>
<body>
<div id="container">
<?php notification(); ?> //error
<h1>Test</h1>
<h2>Notifcation</h2>
<form action="<?php submitForm(); ?>" method="post">
<label for="name">Name</label>
<input type="text" name="name" id="name" />
<input type="submit" name="submit" id="submit" value="Send" />
</form>
</div>
</body>
</html>
我正在为我的服装网站创建通知,如果管理员帐户创建新产品,它将显示在新实体的框(主页)中。所以我创建了一个输入,它将输出表单中写入的内容,但是为了在我的主页中显示它,我将如何创建一个包含添加产品历史的存储框,因为我现在的输出只显示何时我输入了一个文本并按下回车键,只有在插入另一个文本之后。
解决方案
推荐阅读
- swift - 在表格视图中搜索 CNContacts
- c - C:如何找出某个字符串中任意序列中存在一定数量的字符?
- jmeter - 使用 jmeter 负载测试应用程序
- javascript - OpenLayers 将图层存储在 cookie 中
- java - 通过 AWS SES + Spring Boot 发送邮件时检查邮件地址是否存在
- apache-spark - 获取 spark-submit 参数的值:num-executors、executor-cores 和 executor-memory
- segmentation-fault - 编译 LLVM IR 时出现 clang 段错误
- canvas - Canvas 无法在“CanvasRenderingContext2D”上执行“getImageData”:源宽度为 0
- python - 在具有空列的 Pandas DataFrame 上使用多级总和时出现 ValueError
- java - 为什么 PitchDetection 更适用于吹口哨?