PDA

Arată versiune īntreagă : Script de Contact PHP



Geani
10.01.2011, 00:28
Salutare...Va voi arata un script de contact pentru: un site, blog sau forum... etc.

Avem nevoie de urmatoarele pagini:
index.php, in care vom scrie asta:

<!-- Script Contact -->
<?php
$ipi = getenv("REMOTE_ADDR");
$httprefi = getenv ("HTTP_REFERER");
$httpagenti = getenv ("HTTP_USER_AGENT");
?>

<input type="hidden" name="ip" value="<?php echo $ipi ?>" />
<input type="hidden" name="httpref" value="<?php echo $httprefi ?>" />
<input type="hidden" name="httpagent" value="<?php echo $httpagenti ?>" />


Nume: <br />
<input type="text" name="visitor" size="35" />
<br />
Email:<br />
<input type="text" name="visitormail" size="35" />
<br /> <br />
<br />
Subiect:<br />
<select name="attn" size="1">
<option value=" Sales n Billing ">Optiunea 1</option>
<option value=" General Support ">Optiunea 2</option>
<option value=" Technical Support ">Optiunea 3 </option>
<option value=" Webmaster ">Optiunea 4 </option>
</select>
<br /><br />
Message:
<br />
<textarea name="notes" rows="4" cols="40"></textarea>
<br />
<input type="submit" value="Trimite" />Si....trimite.php in car vom scrie:


<?php

$ip = $_POST['ip'];
$httpref = $_POST['httpref'];
$httpagent = $_POST['httpagent'];
$visitor = $_POST['visitor'];
$visitormail = $_POST['visitormail'];
$notes = $_POST['notes'];
$attn = $_POST['attn'];


if (eregi ('http:', $notes)) {
die ("Do NOT try that! ! ");
}
if(!$visitormail == "" && (!strstr($visitormail,"@") || !strstr($visitormail,".")))
{
echo "<h2>Introdu un email valid.</h2>\n";
$badinput = "<h2>Feedback was NOT submitted</h2>\n";
echo $badinput;
die ("Go back! ! ");
}

if(empty($visitor) || empty($visitormail) || empty($notes )) {
echo "<h2>Va rugam completati toate campurile.</h2>\n";
die ("Use back! ! ");
}

$todayis = date("l, F j, Y, g:i a") ;

$attn = $attn ;
$subject = $attn;

$notes = stripcslashes($notes);

$message = " $todayis [EST] \n
Attention: $attn \n
Message: $notes \n
From: $visitor ($visitormail)\n
Additional Info : IP = $ip \n
Browser Info: $httpagent \n
Referral : $httpref \n
";

$from = "From: $visitormail\r\n";


mail ("aiciemail@domeniu.com", $subject, $message, $from);

?>

<p align="center">
Data: <?php echo $todayis ?>
<br />
Expeditor: <?php echo $visitor ?> ( <?php echo $visitormail ?> )
<br />

Subiect: <?php echo $attn ?>
<br />
Mesaj:<br />
<?php $notesout = str_replace("\r", "<br/>", $notes);
echo $notesout; ?>
<br />
<?php echo $ip ?>
<br /><br />
<
a href="index.php"> Inapoi </a>
</p>Inlocuiti aiciemail@domeniu.com cu emailul dvs.
Demo: http://energi-alternative.uv.ro/contact.php

netul
10.01.2011, 06:05
http://www.ibdhost.com/contact/

Daca tot copiati tutoriale de pe net, macar explicati ce face fiecare rand, fiecare instructiune, etc... Ca la copy / paste suntem toti buni.
De asemenea, nu ar strica si o filtrare a variabilelor introduse, pentru a preveni eventualele atacuri.

bozy12v
12.01.2011, 14:36
http://scriptgenerator.net/71/HTML%7B47%7DPHP-Contact-Form-Mailer-Generator/ - Generator de formular si cu verificare anti spam.

emibraila
03.02.2011, 12:43
Foarte util generatorul de formulare de mai sus! Multumesc!

bozy12v
12.03.2011, 17:49
acum e valabila si versiunea 2-a a generatorului (validare jquey si php a campurilor, captcha imbunatatit, fara refresh, mai multe optiuni).
http://scriptgenerator.net/78/HTML-PHP-jQuery-ContactForm-v2/

Jowebart
14.03.2011, 16:05
Interesant bozy :)

thanks for sharing .