Sephy Posted February 28, 2008 Report Share Posted February 28, 2008 Sveika tauta velviens iesacejs te ;] tatad rekur kods: <?php if($_POST['sent']==1) { $_POST['name']=str_replace('~','',strip_tags(trim($_POST['name']))); $_POST['prof']=str_replace('~','',strip_tags(trim($_POST['prof']))); $_POST['message']=str_replace('~','',strip_tags(trim($_POST['message']))); if(!$_POST['name']){$errmessage="<br>Please enter your name";} if(!$_POST['prof']){$errmessage="<br>Please enter your profession";} if(!$_POST['message']){$errmessage="<br>Please enter your notes";} if($errmessage){$errmessage="<h4><font color=red>".$errmessage."</font></h3>";} else{echo $errmessage="";} } if($_POST['name'] AND $_POST['prof'] AND $_POST['message']) { $t1=chr(10); $t2=chr(13); $_POST['message']=str_replace($t1,'<br>',$_POST['message']); $_POST['message']=str_replace($t2,'<br>',$_POST['message']); if(file_exists('teksts.txt')){$output="\n";} $comment=fopen('teksts.txt','a'); $output.=$_POST['name']."~".$_POST['prof']."~".$_POST['message']; fputs($comment,$output); fclose($comment); $_POST['name']=""; $_POST['prof']=""; $_POST['message']=""; } ?> <html> <head> <title>Viesu gramata</title> </head> <body> <h3>Viesu gramata ;]<h3> <?php echo $errmessage; ?> <form action="<?php echo $_SERVER['PHP_SELF']?>" method="post"> <input type="hidden" name="sent" value="1" > <p>Name:<br> <input type="text" name="name" size="30" value="<?php echo $_POST['name'];?>"> <br> Profession:<br> <input type="text" name="prof" size="30" value="<?php echo $_POST['name'];?>"> <br> Notes:<br> <textarea name="message" rows="5" cols="30" wrap="virtual"> <?php echo $_POST['message']; ?> </textarea> </p> <input type="submit" value="sutit"> </form> </body></html> 1 problema izvadas vot shis ja ir ievaditi visi elementi:Notice: Undefined variable: errmessage in /home/devel/www/test/php_info.php on line 10 2: ja ir vairak nekaa viens neaizpilditi lauki vini parakstas nevis parlec nakamaja rindaa kautgan <br> ir ielikts oO Link to comment Share on other sites More sharing options...
andrisp Posted February 28, 2008 Report Share Posted February 28, 2008 paste.php.lv Link to comment Share on other sites More sharing options...
Sephy Posted February 28, 2008 Author Report Share Posted February 28, 2008 http://paste.php.lv/6924 Link to comment Share on other sites More sharing options...
Aleksejs Posted February 28, 2008 Report Share Posted February 28, 2008 Ja nav kļūdas paziņojuma, tad arī netiek uzstādīts tāds mainīgais $errormessage, tādēļ pārbaude if($errormessage) rada brīdinājumu. Uzstādi jau pašā pirmajā rindiņā $errormessage=''; Otro problēmu pagaidām nesapratu. Link to comment Share on other sites More sharing options...
Sephy Posted February 28, 2008 Author Report Share Posted February 28, 2008 Ja nav kļūdas paziņojuma, tad arī netiek uzstādīts tāds mainīgais $errormessage, tādēļ pārbaude if($errormessage) rada brīdinājumu.Uzstādi jau pašā pirmajā rindiņā $errormessage=''; Otro problēmu pagaidām nesapratu. Ok ty pirmaa stradaa. Ar otro problemu es domaju, ka ja kads no laukiem nav aizpildits, tad tiek izvadits pazinojums(piemeram neko neieraxta pie name tad pie sutishanas izvada:Please enter your name).Problema ir tur ka ja ir vairaki neaizpilditi lauki(piemeram gan name un prof lauks) tad paradas tikai viens(pedejais) pazinojums oO, jo pedejais pazinojums parakstas pari pirmajam ;[ Link to comment Share on other sites More sharing options...
xPtv45z Posted February 28, 2008 Report Share Posted February 28, 2008 Par otro. Tev jau pašam tā ir sataisīts, ka pārraksta. Katru reizi mainīgajam tiek piešķirta jauna vērtība. if(!$_POST['name']){$errmessage="<br>Please enter your name";} if(!$_POST['prof']){$errmessage="<br>Please enter your profession";} if(!$_POST['message']){$errmessage="<br>Please enter your notes";} Link to comment Share on other sites More sharing options...
Sephy Posted February 28, 2008 Author Report Share Posted February 28, 2008 Par otro.Tev jau pašam tā ir sataisīts, ka pārraksta. Katru reizi mainīgajam tiek piešķirta jauna vērtība. if(!$_POST['name']){$errmessage="<br>Please enter your name";} if(!$_POST['prof']){$errmessage="<br>Please enter your profession";} if(!$_POST['message']){$errmessage="<br>Please enter your notes";} hmm. tad jau laikam nekas cits natliek ka taisit katram error message savu maninigo oO Link to comment Share on other sites More sharing options...
Aleksejs Posted February 28, 2008 Report Share Posted February 28, 2008 Nu vispār jau nē... ;) if(!$_POST['name']){$errmessage.="<br>Please enter your name";} if(!$_POST['prof']){$errmessage.="<br>Please enter your profession";} if(!$_POST['message']){$errmessage.="<br>Please enter your notes";} Link to comment Share on other sites More sharing options...
Sephy Posted February 28, 2008 Author Report Share Posted February 28, 2008 Nu vispār jau nē... ;) if(!$_POST['name']){$errmessage.="<br>Please enter your name";} if(!$_POST['prof']){$errmessage.="<br>Please enter your profession";} if(!$_POST['message']){$errmessage.="<br>Please enter your notes";} nice, ty Link to comment Share on other sites More sharing options...
anonīms Posted February 28, 2008 Report Share Posted February 28, 2008 1 problema izvadas vot shis ja ir ievaditi visi elementi:Notice: Undefined variable: errmessage in /home/devel/www/test/php_info.php on line 10 if(isset($errmessage)){$errmessage="<h4><font color=red>".$errmessage."</font></h3>";} Link to comment Share on other sites More sharing options...
Recommended Posts