Jump to content

Search the Community

Showing results for tags 'contact form'.



More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (Dreamweaver, Zend, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

Found 2 results

  1. Hello all, It's my first time here, I hope you will be indulgent. I am trying to create a contact form in php, using something that a former employee at my company has written for another website. Please note that I have no knowledge whatsoever of php (except what I've learned while creating it...). Here is the code I am working with. Can you go through and let me know if see anything that seems off to you? Thank you very much! <?php /* ******************************************************************************************** CONFIGURATION ******************************************************************************************** */ // destinataire est votre adresse mail. Pour envoyer à plusieurs à la fois, séparez-les par une virgule $destinataire = 'myemail'; // copie ? (envoie une copie au visiteur) $copie = 'oui'; // Action du formulaire (si votre page a des paramètres dans l'URL) // si cette page est index.php?page=contact alors mettez index.php?page=contact // sinon, laissez vide $form_action = ''; // Messages de confirmation du mail $message_envoye = "Votre message nous est bien parvenu. Merci !"; $message_non_envoye = "L'envoi du mail a échoué, veuillez réessayer SVP."; // Message d'erreur du formulaire $message_formulaire_invalide = "Vérifiez que tous les champs soient bien remplis et qu'il n'y ait pas d'erreur dans votre adresse courriel."; /* ******************************************************************************************** FIN DE LA CONFIGURATION ******************************************************************************************** */ /* * cette fonction sert à nettoyer et enregistrer un texte */ function Rec($text) { $text = htmlspecialchars(trim($text), ENT_QUOTES); if (1 === get_magic_quotes_gpc()) { $text = stripslashes($text); } $text = nl2br($text); return $text; }; /* * Cette fonction sert à vérifier la syntaxe d'un email */ function IsEmail($email) { $value = preg_match('/^(?:[\w\!\#\$\%\&\'\*\+\-\/\=\?\^\`\{\|\}\~]+\.)*[\w\!\#\$\%\&\'\*\+\-\/\=\?\^\`\{\|\}\~]+@(??:(?:[a-zA-Z0-9_](?:[a-zA-Z0-9_\-](?!\.)){0,61}[a-zA-Z0-9_-]?\.)+[a-zA-Z0-9_](?:[a-zA-Z0-9_\-](?!$)){0,61}[a-zA-Z0-9_]?)|(?:\[(??:[01]?\d{1,2}|2[0-4]\d|25[0-5])\.){3}(?:[01]?\d{1,2}|2[0-4]\d|25[0-5])\]))$/', $email); return (($value === 0) || ($value === false)) ? false : true; } // formulaire envoyé, on récupère tous les champs. $name = (isset($_POST['name'])) ? Rec($_POST['name']) : ''; $email = (isset($_POST['email'])) ? Rec($_POST['email']) : ''; $tel = (isset($_POST['tel'])) ? Rec($_POST['tel']) : ''; $sujet = (isset($_POST['sujet'])) ? Rec($_POST['sujet']) : ''; $message = (isset($_POST['message'])) ? Rec($_POST['message']) : ''; // On va vérifier les variables et l'email ... $email = (IsEmail($email)) ? $email : ''; // soit l'email est vide si erroné, soit il vaut l'email entré $err_formulaire = false; // sert pour remplir le formulaire en cas d'erreur si besoin if (isset($_POST['envoi'])) { if (($name != '') && ($tel != '')) { // les 4 variables sont remplies, on génère puis envoie le mail //$headers = 'From:'.$name.' <'.$email.'>' . "\r\n"; //$headers .= 'Reply-To: '.$email. "\r\n" ; //$headers .= 'X-Mailer:PHP/'.phpversion(); $headers = "From: " . $name . "\r\n"; $headers .= "Reply-To: ". $email . "\r\n"; $headers .= "MIME-Version: 1.0\r\n"; $headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n"; // envoyer une copie au visiteur ? if ($copie == 'oui') { $cible = $destinataire.';'.$email; } else { $cible = $destinataire; }; // Remplacement de certains caractères spéciaux $message = str_replace("'","'",$message); $message = str_replace("’","'",$message); $message = str_replace(""",'"',$message); $message = str_replace('<br>','',$message); $message = str_replace('<br />','',$message); $message = str_replace("<","<",$message); $message = str_replace(">",">",$message); $message = str_replace("&","&",$message); // Envoi du mail $num_emails = 0; $tmp = explode(';', $cible); foreach($tmp as $email_destinataire) { $msg = '<html><body>'; $msg .= '<h1>Vous avez reçu une soumission</h1>'; $msg .= '</body></html>'; $msg = '<html><body>'; $msg = '<h3>Formulaire : </h3>'; $msg .= "<tr><td><strong>Prénom Nom : </strong> </td><td>" . $name . "</td></tr>"; $msg .= "<tr><td><strong>Courriel : </strong> </td><td>" . $email . "</td></tr>"; $msg .= "<tr><td><strong>Téléphone : </strong> </td><td>" . $tel . "</td></tr>"; $msg .= "<tr><td><strong>Sujet : </strong> </td><td>" . $sujet . "</td></tr>"; $msg .= "<tr><td><strong>Message :</strong> </td><td>" . $message . "</td></tr>"; } $msg .= "</table>"; $msg .= "</body></html>"; //$msg = $name.'</br>'.$email.'</br>'.$tel.'</br>'.$sujet.'</br>'.$message; if (mail($email_destinataire, $name, $msg, $headers)) $num_emails++; } } ?>
  2. Hi I am a newbie with PHP. I created a contact form following a tutorial online and have uploaded the index.html and contact-form.php form to a server with php enabled. I am getting an error message Warning! Please fill all the fields. ”; } else { mail($to,$subject,$msg,”From:”.$email); echo “ I am wondering if anyone can advise me? The PHP: <?php $to="calming1@yahoo.co.uk";/*Your Email*/ $subject="Message from the website"; $date=date("l, F jS, Y"); $time=date("h:i A"); $name=$_REQUEST['name']; $email=$_REQUEST['email']; $message=$_REQUEST['message']; $msg=" Message sent from website form on date $date, hour: $time.\n Name: $name\n Email: $email\n Message: $message\n "; if($email=="") { echo "<div class='alert alert-danger'> <a class='close' data-dismiss='alert'>×</a> <strong>Warning!</strong> Please fill all the fields. </div>"; } else { mail($to,$subject,$msg,"From:".$email); echo "<div class='alert alert-success'> <a class='close' data-dismiss='alert'>×</a> <strong>Thank you for your message!</strong> </div>"; } ?> HTML <form id="contact" class="form-inline" action="contact-form.php" method="post" accept-charset="utf-8"> <div class="form-group pull-left"> <label class="sr-only" for="name">Name</label> <input type="text" class="form-control" id="name" placeholder="Name" name="name"> </div> <div class="form-group pull-right"> <label class="sr-only" for="email">Email</label> <input type="email" class="form-control" id="email" placeholder="Email" name="email"> </div> <textarea class="form-control pull-left" rows="8" placeholder="Message" name="message"></textarea> <button type="submit" class="btn pull-right">Send email</button> </form>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.