473,670 Members | 2,683 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to create a email feedback form for my existing website?

127 New Member
users fill the feedback form and send mails to us.

i wnat to ue php mail() function. plz help how to use the php script? what are the things i need for that?

i am new to this plz help...
Aug 25 '10 #1
25 2987
londres9b
106 New Member
It's very simple actually.

Expand|Select|Wrap|Line Numbers
  1. <?php
  2. $to      = 'feedback@yoursite.com';
  3. $subject = 'the subject';
  4. $message = 'User Message';
  5. $headers = 'From: $userEmail';
  6.  
  7. mail($to, $subject, $message, $headers);
  8. ?>
  9.  
I suppose you know how how to get the $message, the $userEmail and possibly the $subject from the feedback html form. If not just say so.
Aug 25 '10 #2
impin
127 New Member
simply i can upload the php script to my website?

i want to know other than the html form and php script what else i need?

i upload both the form and script to my website. but the mail is not reciving...

this is my contact form
Expand|Select|Wrap|Line Numbers
  1.  <form id="contacts-form" method="post" action="mail.php" onSubmit="return validateForm(this)">
  2.                                              <fieldset>
  3.                                                 <div class="field"><label>Full Name:</label><input type="text" value="" name="name"/> <font color="#FF0000" size="+1">*</font></div> 
  4.                                                 <div class="field"><label>E-mail:</label><input type="text" value="" name="email"/> <font color="#FF0000" size="+1">*</font></div>
  5.                                                 <div class="field"><label>Phone:</label><input type="text" value="" name="phone"/> <font color="#FF0000" size="+1"></font></div>
  6.                                                 <div class="field"><label>Subject:</label><input type="text" value="" name="subject"/></font></div>
  7.  
  8.                                                 <div class="field"><label>Services:</label><select name="services">
  9.   <option>------------Select------------</option>                                              
  10.   <option>Call Center Services</option>
  11.   <option>Data Entry Services</option>
  12.   <option>KPO Services</option>
  13.   <option>Health Care Services</option>
  14.   <option>Software Development</option>
  15. </select> 
  16.   <font color="#FF0000" size="+1">*</font>
  17. </div>
  18.                                                 <div class="field"><label>Message:</label><textarea name="message" cols="" rows=""></textarea> </div>
  19.  
  20.                                                 <div align="center"><input type="submit" value="SUBMIT"/></font></div>
  21.  
  22.                                                 <!--<div class="alignright"><a href="mail.php" class="button" onclick="document.getElementById('contacts-form').submit()"><em><b>Submit</b></em></a>
  23.                                                 </div>-->
  24.                                              </fieldset>
  25.                                           </form>
  26.  

this is my mail.php script

Expand|Select|Wrap|Line Numbers
  1. <?php
  2. //if(isset($_POST['email'])) {
  3.  
  4.  
  5.     $email_to = "impin@in.com"; //mail id
  6.     $email_subject = "Outsource Projects to India";
  7.  
  8.  
  9.     $name = $_POST['name']; 
  10.     $email = $_POST['email'];
  11.     $phone = $_POST['phone']; 
  12.     $services = $_POST['services'];
  13.     $message = $_POST['message'];
  14.  
  15.  
  16.  
  17.  
  18.     $email_message = "Form details below.\n\n";
  19.  
  20.     function clean_string($string) {
  21.       $bad = array("content-type","bcc:","to:","cc:","href");
  22.       return str_replace($bad,"",$string);
  23.     }
  24.  
  25.     $email_message .= "Name: ".clean_string($name)."\n";
  26.     $email_message .= "Email: ".clean_string($email)."\n";
  27.     $email_message .= "Phone: ".clean_string($phone)."\n";
  28.     $email_message .= "Services: ".clean_string($services)."\n";
  29.     $email_message .= "Message: ".clean_string($message)."\n";
  30.  
  31.  
  32. // create email headers
  33. $headers = 'From: '.$email."\r\n".
  34. 'Reply-To: '.$email."\r\n" .
  35. 'X-Mailer: PHP/' . phpversion();
  36. ini_set("sendmail_from","impin@in.com"); 
  37. mail($email_to, $email_subject, $email_message, $headers);  
  38. ?>
  39.  
is anything wrong in the code? or what else the problem?
Aug 26 '10 #3
impin
127 New Member
now my website is online. but the mails only not going...

Expand|Select|Wrap|Line Numbers
  1. if (mail($email_to, $email_subject, $email_message, $headers))
  2. {
  3.     echo "<h4>Thank you for sending email</h4>";
  4. } else {
  5.   echo "<h4>Can't send email</h4>";
  6. }
  7. ?>
  8.  
i get result as "cant send email".

so what i do?
Aug 26 '10 #4
londres9b
106 New Member
Well before anything let's make sure you realize that you have this on your code:

Expand|Select|Wrap|Line Numbers
  1. //if(isset($_POST['email'])) {
Was that a mistake or what? If that line is commented if means it will never be executed. And so your script will never run.
Aug 26 '10 #5
impin
127 New Member
even if this line is executed, still i wont get mail.

still i get the result as i cant send mail...

Expand|Select|Wrap|Line Numbers
  1. if(isset($_POST['email'])) {
  2.  
in this code 'email' is what? it is email.php?! or its a keyword? in myacse my php file is mail.php.
so i have to change the code like this?
Expand|Select|Wrap|Line Numbers
  1. if(isset($_POST['mail'])) {
  2.  
or i can use the same code
Expand|Select|Wrap|Line Numbers
  1. if(isset($_POST['email'])) {
  2.  
plz help
Aug 27 '10 #6
londres9b
106 New Member
Expand|Select|Wrap|Line Numbers
  1. if(isset($_POST['email'])) {
That 'email' comes from the form, the field with name='email'.

You use that to to tell the script to run only if the form as been submitted. Normally you'd use $_POST['submit'] but you can use any other form field.

Not sure exactly what the problem was (probably that if in the beginning) but the code now works.

Expand|Select|Wrap|Line Numbers
  1. <?php
  2. if(isset($_POST['email'])) {
  3.  
  4.  
  5.     $email_to = "impin@in.com"; //mail id
  6.     $email_subject = "Outsource Projects to India";
  7.  
  8.  
  9.     $name = $_POST['name']; 
  10.     $email = $_POST['email'];
  11.     $phone = $_POST['phone']; 
  12.     $services = $_POST['services'];
  13.     $message = $_POST['message'];
  14.  
  15.  
  16.  
  17.  
  18.     $email_message = "Form details below.\n\n";
  19.  
  20.     function clean_string($string) {
  21.       $bad = array("content-type","bcc:","to:","cc:","href");
  22.       return str_replace($bad,"",$string);
  23.     }
  24.  
  25.     $email_message .= "Name: ".clean_string($name)."\n";
  26.     $email_message .= "Email: ".clean_string($email)."\n";
  27.     $email_message .= "Phone: ".clean_string($phone)."\n";
  28.     $email_message .= "Services: ".clean_string($services)."\n";
  29.     $email_message .= "Message: ".clean_string($message)."\n";
  30.  
  31.  
  32. // create email headers
  33. $headers = 'From: '.$email."\r\n".
  34. 'Reply-To: '.$email."\r\n" .
  35. 'X-Mailer: PHP/' . phpversion();
  36. ini_set("sendmail_from","impin@in.com"); 
  37.  
  38. if (mail($email_to, $email_subject, $email_message, $headers))
  39. {
  40.     echo "<h4>Thank you for sending email</h4>";
  41. } else {
  42.   echo "<h4>Can't send email</h4>";
  43. }
  44.  
  45. }
  46. else {
  47.  
  48. echo "<h3>Error</h3>";
  49. }
  50. ?>
  51.  
Emails coming from mail() scripts usually go to spam folder, be sure to check it if you're not receiving emails.
Aug 27 '10 #7
impin
127 New Member
really this code works for you?!
for me still not working..
still i get result cant send mail...

my web host provider provides
php 4.3.2 only
Aug 27 '10 #8
londres9b
106 New Member
Oh.. I'm not sure if php 4.3.2 supports mail()..

Can't you get another provider that has php 5 ?
Aug 27 '10 #9
impin
127 New Member
ok thank you
Aug 27 '10 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

5
5109
by: Andrew | last post by:
Where can i find a free feedback form in php script to download it and put it in my website? thanks in advance andreas
2
5215
by: Mindful_Spirit | last post by:
I'm trying to set up a basic email feed back form like this, and was wondering about some basic configuration settings. I have used code from this website. I have it working just fine. I'm running IIS on my home machine. My problem is that I need to upload this stuff to a webhosting place and register a domain and I'm not sure what to put as the smtp mail server value
1
5946
by: Andrew | last post by:
Where can i find a free feedback form in javascript to download it and put it in my website? thanks in advance andreas
6
1663
by: Zagor | last post by:
I have a feedback form in my website with three TextBoxes and a SEND button in a user control. Below is a piece of the code: //On click event for the send LinkButton private void SendClicked(object sender, EventArgs e){ try{ if (Page.IsValid){
1
1442
by: anj | last post by:
Hi:- how to create contact us,feedback form in asp.net.Plz help.
0
1062
by: ak | last post by:
Hi Guys, I have few questions on mobilizing existing website. One of our client has an ecommerce website that shows product catalogue and if you are logged in , shopping cart. It is developed using jsp technologies. What we were asked is to enable the website in a blackberry device (e.g. small browser).
2
1986
by: m.schaeffer | last post by:
Hello, my problem is, that if i create a new website with Visual Studio 2005 and I choose "AJAX enabled Website" everything works fine. But if I try to do the same with an existing Website (AJAX Extesions where installed later) the "AJAX"-functionality fails. Though I have the AJAX Extensions in my Tool-Box and everything seems ok it doesn`t work. I can drag and drop ScriptManager, UpdatePanels, ContentTemplates ... but when I run the...
15
2635
by: nickyspace | last post by:
i have a code wherein it is asking email id and message from the user in the form named as feedback.html HTML CODE AS BELOW<html> <body> <form method="post" action="sendmail.php"> Email: <input name="email" type="text" size="20" /><br /> Message:<br /> <textarea name="message" rows="15" cols="40"> </textarea><br /> <input type="submit" /> </form>
1
2419
max2008mmm
by: max2008mmm | last post by:
I am trying to create a email contact form for our website. I want there to be four fields for a visitor to fill in (name, email address, subject, message). The subject field will be a drop-down box to allow for a variety of purposes for the visitor's message. I know how to do all of this and have the message sent to one address. However, I would like to associate each subject choice to a different email address. I've looked all over the...
0
1419
by: gnawz | last post by:
I have a feedback form code which does email but does not display the correct content. In place of the email address, it displays "+1" And the body message is "1" It works well when I test it on localhost. As in
0
8468
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8901
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8814
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8591
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7415
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4209
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4390
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2041
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1792
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.