tutoriale photoshop, brushes, patterns, gradient
Site afiliat proiectului Wtricks.com
   
   
  REGULAMENT | Search | Members | Calendar | Help  
 


Post Reply  Post Thread 
Formular contact (php)
Author Message
cristi
Membru
**


Posts: 29
Group: Registered
Joined: Feb 2008
Status: Offline
Reputation: 0
Lei: 171.25
Post: #1
Formular contact (php)

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.

Code:
<?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!';
   }

}
?>



Dacă includ şi

Code:
$recipient = "nume@domeniu.com";
$subject = "Mesaj contact";
$mailheaders = "From: Formular domeniu.com <hhromanesc@yahoo.com> \n";
$mailheaders .= "De la: $_POST[email]";


mail-ul mi se trimite cu succes, însă dacă vreau să văd aşa zisul mail, nu văd nimic, doar de la cine a fost trimis, atât . Mulţumesc!


HHROMANESC.RO - Sustinem Miscarea!

This post was last modified: 08-04-2008 10:55 PM by cristi.

08-04-2008 10:47 PM
Visit this users website Find all posts by this user Quote this message in a reply
alexfisher
Membru
**


Posts: 47
Group: Registered
Joined: Aug 2008
Status: Offline
Reputation: 0
Lei: 102.8
Post: #2
RE: Formular contact (php)

Pai nu ai o variabila care sa introduca in mail messajul pe care cineva ti`l trimite.

CEl mai bine ti`as recomanda sa studiezi scriptul Acesta

08-29-2008 12:59 AM
Visit this users website Find all posts by this user Quote this message in a reply
DarK4EveR
Super Moderator
******


Posts: 646
Group: Super Moderators
Joined: Aug 2007
Status: Offline
Reputation: 12
Lei: 2395.34
Post: #3
RE: Formular contact (php)

Sau poti mai simplu sa citesti threadul acesta si vei gasi acolo mai multe variante de a face un formular de contact, inclusiv pentru a trimite fisiere ca atasament.


Adrian Sandu
Administrator IT
AdrianSWebS.CoM - Pseudo Blogging
08-29-2008 04:48 AM
Visit this users website Find all posts by this user Quote this message in a reply
Post Reply  Post Thread 

View a Printable Version
Send this Thread to a Friend
Subscribe to this Thread | Add Thread to Favorites

Forum Jump:

 

 Invatam Net
Esti nou pe aici? Vorbeste-ne despre tine.
Citeste articole si tutoriale unice.
Ai un site? Iti putem oferi un review.

  Parteneri

  


-->