473,511 Members | 11,345 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 2974
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
impin
127 New Member
sorry. its php 4.2.3.

i will contact the web host provider.
Aug 27 '10 #11
impin
127 New Member
this code works for you. right?
Aug 28 '10 #12
londres9b
106 New Member
yes.. why? it isn't working for you?
Aug 28 '10 #13
impin
127 New Member
yes. its not working for me. i developed the script using php version 5.3.
i also tried in 4.2.3 version.

in both versions the mail function is not working. the web host provider provides php 4.2.3 version only.
Aug 30 '10 #14
impin
127 New Member
i get this error

Warning: Failed to connect to mailserver, verify your "SMTP" setting in php.ini in E:\Program Files\Ensim\WEBppliance\SiteData\Domains\outsource projectstoindia.com\ROOT\Inetpub\wwwroot\mail.php on line 11
Mail Not Sent.
Aug 30 '10 #15
londres9b
106 New Member
That seems to be an error of php.ini, which can only be corrected by the hosting company. I suggest you contact them again and report that error.
Aug 30 '10 #16
impin
127 New Member
ok thank you
Aug 31 '10 #17
impin
127 New Member
for smtp authentication php mail(), i have write a different script?

simple mail() doesnt work for smtp authentication mail()?

the simple mail() and smtp authenticated mail() both have different codes?! or are they same?
Aug 31 '10 #18
pradeepkr13
43 New Member
try using sockets.
Aug 31 '10 #19
londres9b
106 New Member
You're supposed to be able to send emails from the hosting provider's server, you don't need smtp authentication as far as I know..
what did the hosting company said??
Aug 31 '10 #20
impin
127 New Member
they are saying, we need an smtp authentication to send mail...
Sep 6 '10 #21
londres9b
106 New Member
Well, I and all the other people can send mails using just the mail() function so the problem is really of your hosting provider.

If you can, I strongly recommend you change to another hosting provider (One who has php latest version for a start).
Sep 6 '10 #22
kovik
1,044 Recognized Expert Top Contributor
Any host that forces you to use an external SMTP authentication to send e-mails isn't a host meant for developers. Hosts that distrust their clients aren't the kind that I'd be comfortable being a client of, since they've probably had issues on their servers before.

I'd find a developer-friendly host.
Sep 6 '10 #23
impin
127 New Member
the hosts having some problem with php and they ask me to change the code in asp. i changed the mail script into asp and now its working...
thanks for your help...
Sep 8 '10 #24
londres9b
106 New Member
Glad to hear it.
Sep 8 '10 #25
nakvisa
1 New Member
hy if you want understand feedback visit this site:
http://bandomas.site88.net/1.html
Mar 6 '11 #26

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

Similar topics

5
5101
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
5190
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...
1
5939
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
1646
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...
1
1435
by: anj | last post by:
Hi:- how to create contact us,feedback form in asp.net.Plz help.
0
1053
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...
2
1975
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...
15
2611
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:...
1
2412
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...
0
1412
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...
0
7251
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,...
0
7148
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7367
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,...
0
7430
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...
0
7517
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
5072
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3230
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...
1
790
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
451
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...

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.