Jump to content

php contact form error


frankmill

Recommended Posts

Hello All,

 

 

I'm hoping someone can help me with this....

 

Have just been through the php videos in the webdesigners course.

 

 

I'm trying to apply the php stuff by making the contact form on my website usable.

 

I pointed the form (eg when a user clicks on "send" on the webpage) to a page called contactprocess.php, with this code on it:

 

<?php

//Contact form processing code

 

 

$yourname = $_POST['name'];

$youremail = $_POST['email'];

$yoursubject = $_POST['subject'];

$yourmessage = $_POST['message'];

 

$emailmessage = "yourname: {$yourname} with an email of: {$youremail} and message of: {$yourmessage}";

 

print "Your message has been sent";

 

mail('info@logbookcarloan.org.uk', $yoursubject, $emailmessage);

 

 

?>

 

When I input the contact_us.php page (pointing to contactprocess.php) from localhost I get the following erro:

 

Your message has been sent

Warning: mail() [function.mail]: "sendmail_from" not set in php.ini or custom "From:" header missing in C:\xampp\htdocs\contactprocess.php on line 21

 

 

Line 21 is this one here:

 

mail('info@logbookcarloan.org.uk', $yoursubject, $emailmessage);

 

 

What do I need to do to get this to work?

 

 

Kind regards

 

 

Frank

Link to comment
Share on other sites

Can not help you with your problem. But I am responding to help you with a problem you might have in the future. When naming files you should use camel casing or a dash not an underscore. Why is because sometime you might need to underline something. What is I find mostly used is the camel casing. This is starting your first word in lowercase and each word following with uppercase like this camelCasing.

There are times like your $_POST when you need to use the underscore because that is how the variable was wrote for you.

  • Upvote 1
Link to comment
Share on other sites

When I input the contact_us.php page (pointing to contactprocess.php) from localhost I get the following erro:

 

Your message has been sent

Warning: mail() [function.mail]: "sendmail_from" not set in php.ini or custom "From:" header missing in C:\xampp\htdocs\contactprocess.php on line 21

 

It's much better to test from an online page where the email PHP code will be processed by your host's server.

 

If you want to test sending an email from localhost on your pc you will have to edit the php.ini file in WampServer or XAMPP as follows:-

http://roshanbh.com.np/2007/12/sending-e-mail-from-localhost-in-php-in-windows-environment.html

and also use Apache Server in one of those installations. Set the smtp server name of your ISP where the example has SMTP = smtp.wlink.com.np the smtp.wlink.com.np might be smtp.supanet.com or smtp.your-isp.com

and edit smtp_port = 25

The php.ini file may take some finding in all the files WampServer or XAMPP give you and then the php.ini file has a lot of content and you have to find the correct places to edit.

 

Make sure you add the $headers = ‘MIME-Version: 1.0′ . “\r\n”;

$headers .= ‘Content-type: text/html; charset=iso-8859-1′ . “\r\n”;

in your process file.

Edited by Wickham
  • Upvote 1
Link to comment
Share on other sites

Most excellent, thanks Wickham. I uploaded the file to the server and it works fine.

 

In the end I included a webpage to make it look much nicer:

 

<?php

//Contact form processing code

 

 

$yourname = $_POST['name'];

$youremail = $_POST['email'];

$yoursubject = $_POST['subject'];

$yourmessage = $_POST['message'];

 

$emailmessage = "yourname: {$yourname} with an email of: {$youremail} and message of: {$yourmessage}";

 

include("messagesent.php");

 

mail('info@logbookcarloan.org.uk', $yoursubject, $emailmessage);

 

?>

 

 

 

Also thanks for the tip grabenair! Will bear that in mind for the future.

 

 

Regards

 

 

Frank

Link to comment
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...