Jump to content

Contact Form


gh05

Recommended Posts

Hi,  I'm trying to create a basic contact form in php and the code below this post is giving me the following error when i complete the form: "Error using mail() - sendmail_from not set in php.ini or custom From: missing"

 

Can someone advise me why I'm getting this error.

 

I'm using a windows server and my host says i don't have a php.ini file.

 

Also, for some reason when i put in the code: set_ini(sendmail_from, "[email protected]") then the form sends a blank email from [email protected] but obviously i want the user to be able to enter their own from address and the emails shouldn't be blank.

 

Code attached here:  Many Thanks.

 

 

<?php

#recipient email address
$to = "myemailaddress.com";

#subject of message
$re = "Site Feedback";

#message from feedback form
$msg=$comments;

#users email address
$header=$useraddr;

#Send email now...
mail($to,$re,$msg, $header);
?>

<html>
<head>
<title>Message Received</title>
</head>
<body>
<h3>Thanks for your comments</h3>
Message received from <?php echo($username); ?><br>
Reply to <?php echo($header); ?>
</body>
</html>

 

and this is the form code:

 

<FORM method=post action=contact.php>
<P>Name <BR><INPUT size=30 name=username> <BR><BR>
<P>Email: *<BR><INPUT size=30 name=useraddr AUTOCOMPLETE="OFF"> 
<P><BR><TEXTAREA rows=7 cols=35 name=comments> </TEXTAREA><BR>
<P><INPUT value="Send Email" type=submit name=Submit> </FORM>

Link to comment
https://forums.phpfreaks.com/topic/164272-contact-form/
Share on other sites

Thanks for the reply cunoodle2.

 

The following echos (if that's what you mean) don't display the $username or $header.

 

Message received from <?php echo($username); ?><br>

Reply to <?php echo($header); ?>

 

Why does it look like globals are on?  (I'll ask my host asap) and why would this be so insecure?  Is there no error in my code?

 

Thanks.

Link to comment
https://forums.phpfreaks.com/topic/164272-contact-form/#findComment-866592
Share on other sites

humm you should have a php.ini file lol unless they dont have php intalled on the server...  try running this

 

<?php
phpinfo();
?>

 

can you locate the php.ini file under /usr/local/lib/php.ini usually... but the above code should find it... this would be the start to solving the solution... if you php.ini file is not there, then this is your problem.

 

 

Also whenever you change the php.ini file, you must also

reset the web server. Then all of the PHP variables that you set will

be seen by the server

Link to comment
https://forums.phpfreaks.com/topic/164272-contact-form/#findComment-866678
Share on other sites

Ok cheers. I got my host to turn register_globals off (they say i can't access it myself) but still I am getting the same error in the contact form. 

 

Someone mentioned resetting the server?  I'm not sure my host would like that since i probably share with other websites.  If i just use new variable names is it likely to work then?

 

Thanks.

Link to comment
https://forums.phpfreaks.com/topic/164272-contact-form/#findComment-866745
Share on other sites

First of all you need to make sure your host allows you the mail function (if youre paying for it then they should).

 

If they do, you need to check if you can send the form to any email (yahoo, hotmail etc), or just to the one that you have with your host ([email protected]).

 

If all of that is under control, you have an excellent contact form tutorial on kirupa website (kirupa.com or smth ,google it).

 

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/164272-contact-form/#findComment-866750
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.