如何将错误数组$errors从registrator.php
传递给registracija.php
。我想在页面registracija.php
顶部显示所有错误
registrator.php
<?php
$errors = array();
$ime=trim($_POST['ime']);
$strLen = mb_strlen($ime, 'utf8');
// Check stripped string
if( $strLen < 1 )
{
$errors[] = 'Niste uneli ime.';
}
$prezime=trim($_POST['prezime']);
$strLen = mb_strlen($prezime, 'utf8');
if( $strLen < 1 )
{
$errors[] = 'Niste uneli prezime.';
}
?>
registracija.php
<form action="php/registrator.php" method="post" id="regforma" name="regforma">
<table>
<tr>
<td>Prezime</td>
<td><input class="inputKontrole" name="prezime" onKeyPress="samoSlova(event, 'prezime', '40')" placeholder="prezime" type="text"></td>
</tr>
<tr>
<td>Ime</td>
<td><input class="inputKontrole" name="ime" onKeyPress="samoSlova(event, 'ime', '40')" placeholder="ime" type="text"></td>
</tr>
<tr>
<table>
</form>
发布于 2014-05-30 19:21:23
你应该使用数据库。将数据从一个php文件保存到数据库,并将数据库数据加载到另一个php文件中。在加载不同的页面之间,php代码中的所有数据都丢失了。
您也可以在浏览器中使用cookie。将cookie保存在一个页面中,然后将它们加载到另一个页面。
如果在第一页之后加载了第二页,则可以更改链接以包括要在链接中发送的数据。例如,如果数组很大,应该使用POST请求,而不是使用javascript或表单。
https://stackoverflow.com/questions/23961826
复制相似问题