ArmandsK Posted January 26, 2010 Report Share Posted January 26, 2010 (edited) Neliels skripts epasta sūtīšanai no web lapas, gan jau kādam noderēs :) <?php function show_form() { ?> <form action="" method="post"> <p align="left"><strong>Vārds</strong>*<br> <input type="text" name="name" size="40" /> </p> <p align="left"><strong>Jūsu e-pasts</strong>*<br> <input type="text" name="email" size="40"></p> <p align="left"><strong>Tēma</strong><br> <input type="text" name="title" size="40"></p> <p align="left"><strong>Ziņojums</strong>*<br> <textarea rows="10" name="mess" cols="50"></textarea></p> <p align="left"><input type="submit" value="Sūtīt" name="submit"></p> </form> *<strong>obligāti aizpildāmie lauki </strong> <? } function complete_mail() { $_POST['title'] = substr(htmlspecialchars(trim($_POST['title'])), 0, 1000); $_POST['mess'] = substr(htmlspecialchars(trim($_POST['mess'])), 0, 1000000); $_POST['name'] = substr(htmlspecialchars(trim($_POST['name'])), 0, 30); $_POST['email'] = substr(htmlspecialchars(trim($_POST['email'])), 0, 50); if (empty($_POST['name'])) output_err(0); if(!preg_match("/[0-9a-z_]+@[0-9a-z_^\.]+\.[a-z]{2,3}/i", $_POST['email'])) output_err(1); if(empty($_POST['mess'])) output_err(2); $mess = ' Sūtītāja vārds:'.$_POST['name'].' Sūtītāja e-pasts:'.$_POST['email'].' Ziņojums:'.$_POST['mess']; $to = 'juusu@mails.lv'; $from='juus'; mail($to, $_POST['title'], $mess, "From:".$from); echo '<br><strong>Paldies! Jūsu vēstule nosūtīta.</strong>'; } function output_err($num) { $err[0] = 'kļūda! Nepareizs vārds.'; $err[1] = 'kļūda! Nepareizs e-pasts.'; $err[2] = 'kļūda! Nepareizs ziņojums.'; echo '<p>'.$err[$num].'</p>'; show_form(); exit(); } if (!empty($_POST['submit'])) complete_mail(); else show_form(); ?> Edited January 26, 2010 by ArmandsK Quote Link to comment Share on other sites More sharing options...
KEPKE Posted March 22, 2010 Report Share Posted March 22, 2010 Un kas ir ar drošību? Skatījos pats kaut kādus captchas, bet gribās ko vienkāršāku. Quote Link to comment Share on other sites More sharing options...
Pentiums Posted March 22, 2010 Report Share Posted March 22, 2010 nu tad ja gribās vienkāršāku un triviālāku tad 1+1 = <input type="text" name="mansTrivialaisBullshits" /> Quote Link to comment Share on other sites More sharing options...
Pentiums Posted March 22, 2010 Report Share Posted March 22, 2010 tikai tas neies cauri tiem kas nemāk matemātiku :DD Quote Link to comment Share on other sites More sharing options...
2easy Posted March 22, 2010 Report Share Posted March 22, 2010 nu jā, tas jau kas kuram skaitās triviāls ;) Quote Link to comment Share on other sites More sharing options...
Martins Zemitis Posted May 6, 2010 Report Share Posted May 6, 2010 nenosutas uz emaiu kautkas tur ir nepareizi Quote Link to comment Share on other sites More sharing options...
Леший Posted May 6, 2010 Report Share Posted May 6, 2010 Uz manu mailu nemaz neatnāks, jo regex nepareizs. Šis it kā pareizāks: [a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+(?:[a-zA-Z]{2}|com|org|net|edu|gov|mil|int|biz|info|mobi|name|aero|asia|jobs|museum)\b Quote Link to comment Share on other sites More sharing options...
briedis Posted May 6, 2010 Report Share Posted May 6, 2010 Varbūt der izmantot filter_var() http://www.php.net/manual/en/filter.filters.validate.php Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.