Jump to content

contact us form


Ricklord

Recommended Posts

Hi peeps,

I don't usually ask questions in forums, but this one has been bugging me for the last few hours and ive read so many tutorials on how to do the contact us form but it just isnt working properly.

please view my html side at: http://www.creativecogs.co.uk/testform/contact_us.html

The script is available at: http://www.creativecogs.co.uk/testform/contact.phps

I dont know why but this form just wont work it was working at the strt when i tested it but as i have put it into my actual site and added a few check boxes it doesnt work.

When the form is submitted it just goes to the error text i have put into the php script.

Im not a coder so please go easy on me. Ive tried to put different parts out of different scripts into one which is why it might not be working.

If anyone can help i would be most grateful

Cheers

Rick
Link to comment
Share on other sites

This is because you havn't given your submit button a name.
Change:
[code]<input value="Submit Comments" type="submit"> [/code]
to
[code]<input value="Submit Comments" name="submit" type="submit">[/code]

Also I would recommend you to validate user input (your post variables). As your email script will be prone to spam! Malicous users will be able to send multiple emails in one go! Also you font validate for valid email addresses.
Link to comment
Share on other sites

sweet!!! thanks!!!

i did look at the but becuase it was going through to the contact.php page thought the submit button was working fine and assumed it was a problem with the php script.

added <<<<how do you mean vaildate the email address, is this a few lines of code i need to add?>>>>>>

But thanks, its working now.

How do i get the email address entered to come up as the sender in my inbox, it just says the email is from creativecogs.co.uk???

and finally how do i get it to go to a thankyou.html page after the script is executed instead of the echo command???

thanks again for spotting that submit error and so quickly.

Rick :):):):)
Link to comment
Share on other sites

You'll be best of searching for form validation tutorials. For your setup I would recommend you to do javascript form validation and possibaly PHP form validation too just incase the user has javascript turned off. SO fi you search for form validation tutorials with google you'll get a ton of results.
Link to comment
Share on other sites

Ok will do a search for the validator.

Any idea on how to forward onto a html page rather than the echo command i am using? I have searched for this but had no look, dont even know if im typing the right thing into google.

Also having the email address entered come through as the sender in my inbox?

Cheers
Link to comment
Share on other sites

I would recommend always doing validation via PHP and don't depend on Javascript.  Spambots that will try to use your form for malicious activity will not use your form, but will send data directly to your processing script, thereby negating any Javascript validation being done on the client side.

Ken
Link to comment
Share on other sites

Use header:
[code]header("Location: thanx.html");[/code]
Make sure there is no output before the use of this function.

To show who sent the email you'll want to send additional headers (4th parameter for mail function). A bit like this:
[code]$header = "From: {$name}<{$email_field}>";

    mail($to, $subject, $body, $header);[/code]
This where your validation is most important! As your contact form is now prone to spam! Now you are using custom headers!
Link to comment
Share on other sites

slightly off topic, but are the exploits of mail scripts only possible if you place user input into the header?  Personally I don't put the users email address as From:.  I just put our website so that we know it was submitted from the web and then the users email is listed in the body.
Link to comment
Share on other sites

Hi Again,

got the header in the right place and now forwarding on to a html page so thanks.

With the from field it is just coming up blank now any suggestions? or do i need to incorporate a validator before it will work?

this is my script now

[code]<?php
header("Location: http://www.creativecogs.co.uk/thankyou.html");

if(isset($_POST['submit'])) {

$to = "rick@creativecogs.co.uk";
$subject = "Web Design Online enquiry";


$header = "From: {$name}<{$email_field}>";
$name_field = $_POST['name'];
$email_field = $_POST['email'];
$telephone_field = $_POST['telephone'];
$message = $_POST['message'];

 
foreach($_POST['check'] as $value) {
$check_msg .= "Checked: $value\n";
}
 
$body = "From: $name_field\n E-Mail: $email_field\n Telephone: $telephone_field\n $check_msg Option: $option\n Message: $message";
 
echo "Data has been submitted to $to!";
mail($to, $subject, $body, $header);
 
} else {
echo "failed please try again";
}
?> [/code]

Cheers

Rick
Link to comment
Share on other sites

just read the other 2 posts about having the from field as the email address or setting it to show the web address.

Reason i want it to show me the email address is so i can have an autoresponder going from my webserver. dont know if this is possible with php but just thought if i can get the email address to show up then my auto responder on my web server can do this for me.

Rick
Link to comment
Share on other sites

ok sorry if im being 100% thick which i probably am but ive added the

[code]$header = "From: {$name}<{$email_field}>";[/code]

it might be in the worng place though????

does it need to be above the $to and $subject or do i need to change these to

[code]$header = "To: rick@creativecogs.co.uk>"
$header = "Subject: rick@creativecogs.co.uk>"
[/code]

I don't understand php that well so thats probably wrong. could you let me know where im going wrong?

Rick

Thanks again
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  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.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.