Jump to content
StudioWeb Forums

trying to send email through a form - help?


Recommended Posts

this is my form

 

I would like to receive Information about all flight Programs.

 

 

* First Name:

* Last Name:

* Street Address 1:

 

  Street Address 2:

* City:

* State:

* Zip:

* Country:

  Phone:

* E-mail:

 

  Previous Flight Time:

Here is my form_response file.

<?php

$box = $_POST['box'];

$Firstname =$_POST['Firstname'];

$Lastname = $_POST['Lastname'];

$Address1 = $_POST['Address1'];

$Address2 $_POST['Address2'];

$City = $_POST['City'];

$Zip = $_POST['Zip'];

$Country = $_POST['Country'];

$Phone = $_POST['Phone'];

$Email = $_POST['Email'];

$Time = $_POST['Time'];

 

$email_message = "I would like info about all your programs: {$box} all my other info is {$Firstname} , {$Lastname} , {$Address1} , {$Address2} , {$City} , {$Zip} , {$Country} , {$Phone} , {$Email} , {$Time}";

 

$to = "robert.cfi@gmail.com";

$subject = "none";

$message = "$email_message";

$from = "someonelse@example.com";

$headers = "From: $from";

mail($to,$subject,$message,$headers);

echo "Mail Sent.";

?>

 

why does this not work? any help is great help. thanks

Link to post
Share on other sites

Quick questions... does your host support PHP? Does your host support the mail() command? (not all hosts do, for example, GoDaddy blocks it).

 

Roughly looking through your code, it looks like it should work. When you currently try to send mail, what do you get? "Mail sent", but no mail arrives? An error message or some sort?

Link to post
Share on other sites

I don't understand this:-

 

$to = "robert.cfi@gmail.com";

$from = "someonelse@example.com";

$headers = "From: $from";

 

mail($to,$subject,$message,$headers);

echo "Mail Sent.";

 

The viewer is sending the email to you, so $to is your email (OK so far but don't show it forums!)

 

His email is the variable $Email so I think $headers should be

$headers = "From: $Email";

 

and the $from should not be there at all.

 

Check all lower case and upper case I think you are OK but check.

Link to post
Share on other sites
Quick questions... does your host support PHP? Does your host support the mail() command? (not all hosts do, for example, GoDaddy blocks it).

 

Roughly looking through your code, it looks like it should work. When you currently try to send mail, what do you get? "Mail sent", but no mail arrives? An error message or some sort?

 

thank you falkencreative this is my problem. I use godaddy as my host and i guess like u said it blocks the mail() command. So if it blocks it then what do i use?

 

Also i know that some of the "header" and input code my be a little wrong or out of place, i can fix that later. I just need to know about the functionality of my php. Thanks guys

Link to post
Share on other sites
Quick questions... does your host support PHP? Does your host support the mail() command? (not all hosts do, for example, GoDaddy blocks it).

 

Roughly looking through your code, it looks like it should work. When you currently try to send mail, what do you get? "Mail sent", but no mail arrives? An error message or some sort?

 

 

Sorry i didnt answer your questions. When i hit the submit button it would go back to my index.html page and then no email sent. i put it on my localhost and fixed all the error messages except it said something about tryin it in isset()?!? didnt know about that

Link to post
Share on other sites
thank you falkencreative this is my problem. I use godaddy as my host and i guess like u said it blocks the mail() command. So if it blocks it then what do i use?

 

Unfortunately I don't know of a fix for this, with the exception of switching to use ASP (if you are on a Windows account) or switching hosts completely. I don't believe PHP has an alternative for the mail() function.

 

As for the error message, it would be helpful to see the actual error you are getting, though it looks like GoDaddy's hosting is ultimately going to be the problem.

Link to post
Share on other sites

Ah, ok. Your script runs fine, it's just that it has problems because your PHP ini file isn't properly set up on your machine in order to send email. This is an error that you will only get on your local machine, not when you place it on your hosting.

 

Basically, your issue is GoDaddy hosting, not an error in your script.

Link to post
Share on other sites

They block the mail() function because it could be used for spam purposes -- or, that is my guess at least. You'd have to contact GoDaddy directly and ask. You may want to contact them and ask them if they offer any alternatives for mail() -- they may have a premade script that they would prefer you to use, or something similar.

 

If you do end up switching hosts, I've had good experiences with HostGator. It's a matter of personal preference though, so others may have suggestions as well.

Link to post
Share on other sites

Go Daddy is pretty well known and when I first began developing sites, they were the first I went with for hosting, actually the second, but anyway....as I continued to use them I have to say I have always been impressed with their tech help. The have walked me through stuff on the phone that, as a beginner, I didn't know even what I was asking but they were patient and worked with me to help me understand. I really like that on the phone help too instead of only an email available.

As far as creating php forms, you want your hosting set up as Linux instead of windows for your php to work with Go Daddy hosting. If you're using windows then forms need to be written in asp (this is what tech has told me) but it is very easy to move your hosting from one format to the other. Tech can easily help you do this.

If you use GD's php form code, it will include a thankyou.html and if you don't create one of your own called thankyou.html (same as GD's code) but consistent with your own site, then when your user hits 'submit' it will go to an 'oops' (error) page - trying to redirect to GD's thankyou.html which is non-existent - you must create your own. This also helps the visitor to know that something has happened when they submitted a form. Just include a 'back' link on your thank you page.

I'm not sure what so many have against Go Daddy,(I'll probably find out though) but could be because I don't do alot of advanced coding - just basic stuff so never (knock on wood) had any major problems. But, as I said, always been happy with tech support so don't hesitate to call them when you're having a problem or question.

Link to post
Share on other sites

Yes i called tech and talked to them for about 1 minute and the guy was like i have a link to your email on the way. He knew what i was talking about right away. It was very easy to add and you are right. It involved a thankyou.html which i created to return. You could also just put in your index.html file where the thankyou file is which would just return you to the homepage.

I will commit on the windows vs linux. That was my second major problem. I was using a windows server that did not even support php, lol. Although, if you choose to use a windows server then you need to select the IIS 7 instead of IIS 6. When you sign up for a hosting account IIS 6 is auto selected. IIS 6 does not support php while IIS 7 does. Hope this helps and thank you all for all the help you gave me. I am very impressed with this place

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...