Salut, am dat pe net de un tutorial (în eng) despre crearea unui formular de contact, în php, ok, am editat eu ce era de editat, însă am rămas cam prost când am văzut că nu sunt detaliile despre mail-ul unde se trimit mesajele. Uitaţi aici tutorialul (pag3) şi uitaţi şi mai jos formularul php modificat după ce îmi trebuie mie.
<?php
// Function to display form
function showForm($errorNume=false,$errorEmail=false,$errorNumtel=false,$errorCodprod=fal se,$errorCantitate=false,$errorMesg=false){
if ($errorNume) $errorTextNume = "Please enter your name!";
if ($errorEmail) $errorTextEmail = "Please enter a valid email address!";
if ($errorNumtel) $errorTextNumtel = "Please enter a valid number telephone!";
if ($errorCodprod) $errorTextCodprod = "Please enter a valid cod prod!";
if ($errorCantitate) $errorTextCantitate = "Please enter a valid cantitate!";
if ($errorMesg) $errorTextMesg = "Please leave a longer message!";
echo '<form action="form.php" method="POST"><table>';
// Display name field an error if needed
echo '<tr><td>Numele complet:</td><td><input type="text" name="nume"></td></tr>';
if ($errorNume) echo "<tr><td colspan='2'>$errorTextNume</td></tr>";
// Display email field an error if needed
echo '<tr><td>Email:</td><td><input type="text" name="email"></td></tr>';
if ($errorEmail) echo "<tr><td colspan='2'>$errorTextEmail</td></tr>";
// Display number field an error if needed
echo '<tr><td>Numar telefon:</td><td><input type="text" name="numtel"></td></tr>';
if ($errorNumtel) echo "<tr><td colspan='2'>$errorTextNumtel</td></tr>";
// Display number field an error if needed
echo '<tr><td>Cod produs:</td><td><input type="text" name="codprod"></td></tr>';
if ($errorCodprod) echo "<tr><td colspan='2'>$errorTextCodprod</td></tr>";
// Display number field an error if needed
echo '<tr><td>Cantitate:</td><td><input type="text" name="cantitate"></td></tr>';
if ($errorCantitate) echo "<tr><td colspan='2'>$errorTextCantitate</td></tr>";
// Display message field an error if needed
echo '<tr><td>Message:</td><td><textarea name="mesg"></textarea></td></tr>';
if ($errorMesg) echo "<tr><td colspan='2'>$errorTextMesg</td></tr>";
echo '<tr><td><input type="submit" name="SubmitForm" value="Send"></td></tr>';
echo '<form>';
}
if (!isset($_POST['SubmitForm'])) {
showForm();
} else {
//Init error variables
$errorNume = false;
$errorEmail = false;
$errorNumtel = false;
$errorCodprod = false;
$errorCantitate = false;
$errorMesg = false;
$name = isset($_POST['nume']) ? trim($_POST['nume']) : '';
$email = isset($_POST['email']) ? trim($_POST['email']) : '';
$name = isset($_POST['numtel']) ? trim($_POST['numtel']) : '';
$name = isset($_POST['codprod']) ? trim($_POST['codprod']) : '';
$name = isset($_POST['cantitate']) ? trim($_POST['cantitate']) : '';
$mesg = isset($_POST['mesg']) ? trim($_POST['mesg']) : '';
if (!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email)) $errorEmail = true;
if (strlen($nume)<3) $errorNume = true;
if (strlen($numtel)<3) $errorNumtel = true;
if (strlen($codprod)<3) $errorCodprod = true;
if (strlen($cantitate)<3) $errorCantitate = true;
if (strlen($mesg)<10) $errorMesg = true;
// Display the form again as there was an error
if ($errorNume || $errorEmail || $errorNumtel || $errorCodprod || $errorCantitate || $errorMesg) {
showForm($errorNume,$errorEmail,$errorNumtel,$errorCodprod,$errorCantitate,$erro rMesg);
} else {
echo 'Submission was success!';
}
}
?>
$recipient = "nume@domeniu.com";
$subject = "Mesaj contact";
$mailheaders = "From: Formular domeniu.com <hhromanesc@yahoo.com> \n";
$mailheaders .= "De la: $_POST[email]";