Need Contact Us form using PHP Script

Thread Solved

Join Date: Apr 2009
Posts: 13
Reputation: sohoit is an unknown quantity at this point 
Solved Threads: 0
sohoit sohoit is offline Offline
Newbie Poster

Need Contact Us form using PHP Script

 
0
  #1
Jun 4th, 2009
Hi,

I have just inherited a website with an existing contact us form. however, it isn't doing what is should and I can't work out why.

Does anyone know of a simple script with 4 fields (Name, Phone, Email and Comments) which I can simply insert into the existing contact us page.

i can post the existing code is neccessary.

regards
Reply With Quote Quick reply to this message  
Join Date: Apr 2009
Posts: 134
Reputation: HITMANOF44th is an unknown quantity at this point 
Solved Threads: 19
HITMANOF44th HITMANOF44th is offline Offline
Junior Poster

Re: Need Contact Us form using PHP Script

 
0
  #2
Jun 4th, 2009
need alittle bit more info does it email or save to a database / and do you have a linux server ? and do you have pear installed >?
Reply With Quote Quick reply to this message  
Join Date: Mar 2008
Posts: 7
Reputation: saadsaidi is an unknown quantity at this point 
Solved Threads: 1
saadsaidi saadsaidi is offline Offline
Newbie Poster

Re: Need Contact Us form using PHP Script

 
0
  #3
Jun 4th, 2009
I would like to know what kind of database you are using, and where to is the message is sent.
you have several choices, depending on the storage method you intend to use ex: database, file, email to address....etc.
Last edited by saadsaidi; Jun 4th, 2009 at 9:53 am. Reason: spell
Reply With Quote Quick reply to this message  
Join Date: Apr 2009
Posts: 13
Reputation: sohoit is an unknown quantity at this point 
Solved Threads: 0
sohoit sohoit is offline Offline
Newbie Poster

Re: Need Contact Us form using PHP Script

 
0
  #4
Jun 4th, 2009
Originally Posted by saadsaidi View Post
I would like to know what kind of database you are using, and where to is the message is sent.
you have several choices, depending on the storage method you intend to use ex: database, file, email to address....etc.
No Database. webserver is running linux with PHP v5 and. All I want is for the form to send an email to a particular email address.
Reply With Quote Quick reply to this message  
Join Date: Oct 2007
Posts: 9
Reputation: woozy is an unknown quantity at this point 
Solved Threads: 1
woozy woozy is offline Offline
Newbie Poster

Re: Need Contact Us form using PHP Script

 
0
  #5
Jun 4th, 2009
Consult this but need some refining (it uses tables in html), php part works but it might need more security improvement, and encoding things, etc.

Here is the link:
http://www.phpeasystep.com/phptu/8.html
Last edited by woozy; Jun 4th, 2009 at 10:03 am.
Reply With Quote Quick reply to this message  
Join Date: Apr 2009
Posts: 134
Reputation: HITMANOF44th is an unknown quantity at this point 
Solved Threads: 19
HITMANOF44th HITMANOF44th is offline Offline
Junior Poster

Re: Need Contact Us form using PHP Script

 
0
  #6
Jun 4th, 2009
  1. <?php
  2. //==========================================================================================================
  3. // post variables (get the data)
  4. //==========================================================================================================
  5. $name1 = $_POST['name'];
  6. $phone1 = $_POST['phone'];
  7. $email1 = $_POST['email'];
  8. $comment1 = $_POST['comment'];
  9.  
  10. //==========================================================================================================
  11. // if name one is not empty make an email and send it
  12. //==========================================================================================================
  13.  
  14. if ($name1) {
  15. //==========================================================================================================
  16. // need to have pear installed
  17. //==========================================================================================================
  18. require_once "Mail.php";
  19.  
  20.  
  21. $from = "Admin <addyitcomefrom@yourwebsite.com>";
  22. $to = "youremail@yourwebsite.com";
  23. $subject = "subject goes here";
  24. $body = "name: $name \n\n phone: $phone \n\n email: $email \n\n comment: $comment \\n";
  25.  
  26. $host = "mail.mailserver.com";
  27. $username = "username";
  28. $password = "password";
  29.  
  30. $headers = array ('From' => $from,
  31. 'To' => $to,
  32. 'Subject' => $subject);
  33. $smtp = Mail::factory('smtp',
  34. array ('host' => $host,
  35. 'auth' => true,
  36. 'username' => $username,
  37. 'password' => $password));
  38.  
  39. $mail = $smtp->send($to, $headers, $body);
  40.  
  41. if (PEAR::isError($mail)) {
  42. echo("<p>" . $mail->getMessage() . "</p>");
  43. } else {
  44. echo("<p>Message successfully sent!</p>");
  45. }
  46.  
  47. }
  48.  
  49.  
  50. //==========================================================================================================
  51. // make table / form and such
  52. //==========================================================================================================
  53.  
  54. echo "<form name='input' action='form.php' method='post'>
  55. <p align='center'><table>
  56. <tr>
  57. <td>NAME:</td>
  58. <td><input name='name' type='text' /></td>
  59. </tr>
  60. <tr>
  61. <td>PHONE:</td>
  62. <td><input name='phone' type='text' /></td>
  63. </tr>
  64. <tr>
  65. <td>EMAIL:</td>
  66. <td><input name='email' type='text' /></td>
  67. </tr>
  68. <tr>
  69. <td>COMMENTS:</td>
  70. <td><textarea name='comment' cols='10' rows='10' wrap='ON'></textarea></td>
  71. </tr>
  72. </table></p>
  73. <p align='center'><input type='submit' /></p>
  74. </form>";
  75. ?>
Last edited by HITMANOF44th; Jun 4th, 2009 at 10:04 am.
Reply With Quote Quick reply to this message  
Join Date: Apr 2009
Posts: 134
Reputation: HITMANOF44th is an unknown quantity at this point 
Solved Threads: 19
HITMANOF44th HITMANOF44th is offline Offline
Junior Poster

Re: Need Contact Us form using PHP Script

 
0
  #7
Jun 4th, 2009
most linux systems do have pear installed if that doesnt work for you let me know and i will change it around
Reply With Quote Quick reply to this message  
Join Date: Oct 2007
Posts: 9
Reputation: woozy is an unknown quantity at this point 
Solved Threads: 1
woozy woozy is offline Offline
Newbie Poster

Re: Need Contact Us form using PHP Script

 
0
  #8
Jun 4th, 2009
Yep, PEAR provides much more robust solution. But the native solution is as easy as this:

  1. <?php
  2. // Contact subject
  3. $subject ="$subject";
  4. // Details
  5. $message="$detail";
  6.  
  7. // Mail of sender
  8. $mail_from="$customer_mail";
  9. // From
  10. $header="from: $name <$mail_from>";
  11.  
  12. // Enter your email address
  13. $to ='someone@somewhere.com';
  14.  
  15. $send_contact=mail($to,$subject,$message,$header);
  16.  
  17. // Check, if message sent to your email
  18. // display message "We've recived your information"
  19. if($send_contact){
  20. echo "We've recived your contact information";
  21. }
  22. else {
  23. echo "ERROR";
  24. }
  25. ?>
Last edited by woozy; Jun 4th, 2009 at 10:09 am.
Reply With Quote Quick reply to this message  
Join Date: Mar 2008
Posts: 7
Reputation: saadsaidi is an unknown quantity at this point 
Solved Threads: 1
saadsaidi saadsaidi is offline Offline
Newbie Poster

Re: Need Contact Us form using PHP Script

 
0
  #9
Jun 4th, 2009
Do you have access to php.ini file to set SMTP server?
Reply With Quote Quick reply to this message  
Join Date: Apr 2009
Posts: 134
Reputation: HITMANOF44th is an unknown quantity at this point 
Solved Threads: 19
HITMANOF44th HITMANOF44th is offline Offline
Junior Poster

Re: Need Contact Us form using PHP Script

 
0
  #10
Jun 4th, 2009
i am aware but i had some issuse with the most simplest getting stuck on spam filters no idea why so when i made this one it auth to your email and goes with no problems
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC