Jump to content
php.lv forumi

email no web skripts+forma


Recommended Posts

Neliels skripts epasta sūtīšanai no web lapas, gan jau kādam noderēs :)

function show_form()

<form action="" method="post">
<p align="left"><strong>Vārds</strong>*<br>
 <input type="text" name="name" size="40" />
<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>
*<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']))

if(!preg_match("/[0-9a-z_]+@[0-9a-z_^\.]+\.[a-z]{2,3}/i", $_POST['email']))


$mess = '
Sūtītāja vārds:'.$_POST['name'].'

Sūtītāja e-pasts:'.$_POST['email'].'

$to = 'juusu@mails.lv';

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>';

if (!empty($_POST['submit'])) complete_mail();
else show_form();

Edited by ArmandsK
Link to comment
Share on other sites

  • 1 month later...
  • 1 month later...

Uz manu mailu nemaz neatnāks, jo regex nepareizs.

Šis it kā pareizāks:


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...