Jump to content
php.lv forumi

kludas izdruka


Recommended Posts

if ($_POST){
$error = "";
if($_POST['a1']  == ""){
$error ="nr1 FALSE<br />";
if($_POST['a2'] == ""){
$error ="nr2 FALSE<br />";
if($_POST['a3'] == ""){
$error ="nr3 FALSE<br />";
if ($error != ""){
echo "$error";
}else {
echo $_POST['a1'];
echo $_POST['a2'];
echo $_POST['a3'];
<form method="POST" action="/index.php">
a1<input type="text" name="a1" /><br />
a2<input type="text" name="a2" /><br />
a3<input type="text" name="a3" /><br />
<input type="submit" name="submit" />
<?php } ?>

Velos lai $error izdruka visas kludas, nevis tikai vienu!

Pemeram ja netiek aizpildiits a1 un a2. Gribu lao mainigais $error izdruka kludu par abiem.

Ka to panakt, nepieskirot katrai kludas izdrukai savu mainigo!?

Edited by didy
Link to comment
Share on other sites

Virknes beigās liek katru jaunu kļūdu:

$errors = '';
$errors .= 'abc';
$errors .= '123';
echo $errors;  // abc123

Kļūdas liek masīvā:

$errors = array();
$errors[] = 'abc';
$errors[] = '123'; // array('abc', '123')
foreach($errors as $error) {
  echo $error;


Ja lietosi <br /> tad liec virknē, ja gribi izvadīt kā sarakstu <ul><li></li></ul> vai ko vairāk ar tām kļūdām darīt, vari lietot masīvu.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...