gh05 Posted June 30, 2009 Share Posted June 30, 2009 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 More sharing options...
cunoodle2 Posted June 30, 2009 Share Posted June 30, 2009 What happens when you echo all the values to the screen? Are they even there? PLEASE don't tell me your hosting company has register globals turned on (cause that is what it looks like). If they do cancel immediately and move to a more secure hosting environment. Link to comment https://forums.phpfreaks.com/topic/164272-contact-form/#findComment-866585 Share on other sites More sharing options...
gh05 Posted June 30, 2009 Author Share Posted June 30, 2009 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 More sharing options...
gh05 Posted June 30, 2009 Author Share Posted June 30, 2009 Oh and i just checked and register globals is turned on. Can someone let me know what i can do now? I really don't want to have to change hosts but i do want a secure site with a good contact form! Thanks. Link to comment https://forums.phpfreaks.com/topic/164272-contact-form/#findComment-866602 Share on other sites More sharing options...
runnerjp Posted June 30, 2009 Share Posted June 30, 2009 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 More sharing options...
gh05 Posted June 30, 2009 Author Share Posted June 30, 2009 Ok cheers I've done that and here is the ini file. It means nothing to me btw! Where do you suggest I go from here? Thanks for your help. Link to comment https://forums.phpfreaks.com/topic/164272-contact-form/#findComment-866700 Share on other sites More sharing options...
xcoderx Posted June 30, 2009 Share Posted June 30, 2009 Go nowhere just open ini file and find register globals and if its written on then delete that and type off save and instal it bk simple. Bt strange my emails are sent even wit reg glbs on. Link to comment https://forums.phpfreaks.com/topic/164272-contact-form/#findComment-866716 Share on other sites More sharing options...
gh05 Posted June 30, 2009 Author Share Posted June 30, 2009 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 More sharing options...
xgd Posted June 30, 2009 Share Posted June 30, 2009 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 More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.