Jump to content
php.lv forumi

E-mail form


zzcoolzz

Recommended Posts

Sveiki!

Es ka iesacej daudz nerubiju es gribetu paprasit palidzibu jo esmu strupcela!

Vienkarsi to google ari skatijos bet nevaru laga saprast!

 

Kads varetu pievienot sim scriptam lai varetu vel failu sutit!

Ta ir tikai viena komanda bet ez nevaru to vienk izdarit! (mee big Nooob in php but i lov It)

 

Te bus tas kods!:

 

 

<?php

function show_form()

{

?>

 

<form action="" method="post">

<p align="left"><strong>Your name:</strong>*<br>

<input type="text" name="name" size="40" />

</p>

<p align="left"><strong>Your e-mail:</strong>*<br>

<input type="text" name="email" size="40"></p>

<p align="left"><strong>Your subject:</strong>*<br>

<input type="text" name="title" size="40"></p> <<<<<<<<<Gribetos to funkciju te!

<p align="left"><strong>Your message:</strong>*<br>

<textarea rows="10" name="mess" cols="50"></textarea></p>

 

<p align="left"><input type="submit" value="Send message" name="submit"></p>

</form>

*<strong>Need to be completed!</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 = '

==========Message for Administration==========

 

Sender Name:'.$_POST['name'].'

Sender Mail:'.$_POST['email'].'

Sender Message:'.$_POST['mess'];

 

$to = 'mail@yourmail.com';

 

$from='from@yourmail.com';

mail($to, $_POST['title'], $mess, "From:".$from);

 

echo '<br><strong>Thank you! Your message was sended!</strong>';

echo '<br><strong><meta http-equiv="REFRESH" content="0;URL=http://my url/">

 

<font size=2 face=verdana><b>Please wait: Loading... </strong>';

}

 

function output_err($num)

{

$err[0] = 'Error! Wrong name.';

$err[1] = 'Error! Wrong e-mail.';

$err[2] = 'Error! Wrong message.';

 

echo '<p>'.$err[$num].'</p>';

show_form();

exit();

}

 

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

else show_form();

?>

 

Paldies jau ieprieks!

Tikai nevajag rakstit ej google un ta talak es tur biju un man vina nepalidzeja!

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.

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

Loading...
×
×
  • Create New...