473,398 Members | 2,403 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

Form to E-Mail Problem

Hi,

I'm in the process of creating a form for the first time.

All appears to be work until I click submit then instead of sending the e-mail it diects you to php script.

I wonder if you coding geniuses could shed any light on this.

my php code look as follows:
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. $emailSubject = 'contactform';
  3. $webMaster = 'info@dinkcreative.co.uk';
  4.  
  5. $email = $_POST['email'];
  6. $name = $_POST['name'];
  7. $comments = $_POST['comments'];
  8.  
  9.  
  10.  
  11. $body = <<<EOD
  12. <br><hr><br>
  13. Name: $name <br>
  14. Email: $email <br>
  15. Comments: $comments <br>
  16. EOD;
  17. $headers = "From: $email\r\n";
  18. $headers .= "Content-type: text/html\r\n";
  19. $success = mail($webMaster, $emailSubject, $body,
  20. $headers);
  21.  
  22. /* Results rendered as HTML */
  23. $theResults = <<<EOD
  24. <html>
  25. <head>
  26. <title>sent message</title>
  27. <meta http-equiv="refresh" content="5;URL=http://www.dinkcreative.co.uk/contact.htm">
  28. <style type="text/css">
  29. <!--
  30. body {
  31. background-color:
  32. font-family: Tahoma, Geneva, sans-serif;
  33. font-size: 20px;
  34. font-style: normal;
  35. line-height: normal;
  36. font-weight: normal;
  37. color: #000;;
  38. text-decoration: none;
  39. padding-top: 200px;
  40. margin-left: 150px;
  41. width: 800px;
  42. }
  43. -->
  44. </style>
  45. </head>
  46. <div align="center">Your message has been sent! We are now dealing with your request will get back to you asap</div>
  47. </div>
  48. </body>
  49. </html>
  50. EOD;
  51. echo "$theResults";
  52. ?>
Jul 5 '11 #1
5 1493
code green
1,726 Expert 1GB
The code you have posted does not contain a form
Jul 5 '11 #2
Hi, thank you for replying.

I think the problem lies with the submission of the form, take a look at the attached form:

Expand|Select|Wrap|Line Numbers
  1. <form action="contactform.php" method="post" name="form1" id="contactform">
  2.             <label for="name">Name: <br/>
  3.                 <input type="text" name="name" id="name" />
  4.             </label><br/><br/>
  5.  
  6.             <label for="name">Email: <br/>
  7.               <input type="text" name="email" id="email" />
  8.             </label><br/><br/>
  9.  
  10.             <label for="name">Subject: <br/>
  11.                 <input type="text" name="subject" id="subject" />
  12.                 <br />
  13.             </label><br/>
  14.  
  15.             <label for="Comments">Comments:</label><br/>
  16.             <textarea name="Comments" cols="45" rows="5" id="Comments"></textarea><br/><br/>
  17.             <label>
  18.             <input name="Submit" type="submit" id="Submit" onclick="MM_validateForm('name','','R','email','','RisEmail','Comments','','R');return document.MM_returnValue" value="Submit" />
  19.             <label>
  20. </form>
Jul 5 '11 #3
any ideas folks? I'm puzzled by this and require your expert help!
Jul 5 '11 #4
nathj
938 Expert 512MB
Hi,

I've just read over the code and can see that when you call the mail function you provide a $body variable. this variable doesn't appear to be defined anywhere. Should it perhaps be $comments?

hope this helps
nathj
Jul 6 '11 #5
ijenk
1
i've tried code like this, and i found error with port smtp email. if you run a code at localhost [not like http://yoursite.com] then code not will success. may be you can sent email use gmail account, but that just the first. coz gmail not allow to open smtp from simple action like you code. so u must run at http://yoursite.com and sent email from email@yoursite.com . this i guess.
Jul 7 '11 #6

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

Similar topics

2
by: Nick | last post by:
Loop to create an array from a dynamic form. I'm having trouble with an application, and I'll try to explain it as clearly as possible: 1. I have a form with two fields, say Apples and...
5
by: Richard Cornford | last post by:
I am interested in hearing opinions on the semantic meaning of FORM (elements) in HTML. I have to start of apologising because this question arose in a context that is not applicable to the...
13
by: genetic.error | last post by:
I'm moving from Vb6 to VB.Net. I have a feeling this has come up before... The VS.Net MSDN file seems to state that the following should work: Form1.Show Form1.Visible = True Form1.Hide...
4
by: Targa | last post by:
Trying to total some price fields in a form but doesnt work when all the referenced form fields dont exisit. This is for an invoice - pulled prom a database and the form doesnt always contain the...
0
by: Pat Patterson | last post by:
I'm having serious issues with a page I'm developing. I just need some simple help, and was hoping someone might be able to help me out in here. I have a form, that consists of 3 pages of...
5
by: RAJ | last post by:
hi plz tell me how to know "how window is going to close"... i have to right code for X button of forms... plz telll me thanks bye
8
by: CJack | last post by:
hy, I have an mdi application, i create a child form and I want to know when a button is pressed while that child form is loaded. I have this code: private void frmTestBaby_KeyUp(object sender,...
6
by: Gary Miller | last post by:
Does anyone know how to detect a modeless form on closing by the form that invoked the modeless form? form.Show();
3
by: User | last post by:
Form A (Main) Text Box 1 Text Box 2 Text Box 3 Form B (Pop-up) Choose a selection for Form A/Text Box 3 Scenario:
14
by: Simon Abolnar | last post by:
I would like to know how to open child form from dialog form. Thanks for help! Simon
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
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
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,...
0
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...

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.