Tam_Zeb Posted August 23, 2014 Share Posted August 23, 2014 Hey Guy's I need a quick fix to solve an urgent problem.. I used to do some coding years ago but the old grey matter is not so responsive these days and I have been up all night trying to resolve a problem. I have built a website for my daughters and created a simple web form but I have come unstuck. All those skills I once took for granted are gone. So here's where I am at. I've created an input form_mail.html, a contact.php and a reply.html page uploaded them to the Server and hit an error when I tried to send a message. The problem it seems is with the PHP.ini File. In short I don't have one Duh! Yes I know I should go back and study and that much I intend to do I am currently installing xxampp, MySQL and php on my new laptop. But in the meantime I need your help urgently.. What code do I need in the php.ini file to make the Form Mail work? Is there somewhere on the web where I can see a simple code, I am just too tired to wade through heavy docs right now. Your help would be much appreciated at this time. Sincerely Tam Quote Link to comment Share on other sites More sharing options...
CroNiX Posted August 23, 2014 Share Posted August 23, 2014 What makes you think the problem is with php.ini? That gets installed/created when you install php, so it should be there. Do you get an error message or something? Quote Link to comment Share on other sites More sharing options...
QuickOldCar Posted August 23, 2014 Share Posted August 23, 2014 Post your code here for those files, can assist better. Quote Link to comment Share on other sites More sharing options...
Tam_Zeb Posted August 23, 2014 Author Share Posted August 23, 2014 Hi Guy's Thanks for your prompt responses.. How do I know it's the php.ini - I don't have a php.ini on my server side I did a quick test to see what message I got and the message I got back made reference to the php.ini. When I checked the Server no php.ini This is the sample code I am using for the contact.php I have removed the email address at the top of the page Opps for some reason the site won't let me paste anything Quote Link to comment Share on other sites More sharing options...
Ch0cu3r Posted August 23, 2014 Share Posted August 23, 2014 (edited) Opps for some reason the site won't let me paste anythingThere shouldnt be any issued pasting code. Although please do wrap your code in tags, either type those tags manually or click the <> (code) button in the editor to paste your code. If you continue to have issues, then either attach your php files to your post or post a link to your code at pastebin,com Edited August 23, 2014 by Ch0cu3r Quote Link to comment Share on other sites More sharing options...
Tam_Zeb Posted August 23, 2014 Author Share Posted August 23, 2014 <?php /* Set e-mail recipient */ $myemail = "MY GOES EMAIL HERE"; /* Check all form inputs using check_input function */ $yourname = check_input($_POST['yourname'], "Enter your name"); $subject = check_input($_POST['subject'], "Write a subject"); $email = check_input($_POST['email']); $comments = check_input($_POST['comments'], "Write your comments"); /* If e-mail is not valid show error message */ if (!preg_match("/([\w\-]+\@[\w\-]+\.[\w\-]+)/", $email)) { show_error("E-mail address not valid"); } /* Let's prepare the message for the e-mail */ $message = "Hello! Your contact form has been submitted by: Name: $yourname E-mail: $email Comments: $comments End of message "; /* Send the message using mail() function */ mail($myemail, $subject, $message); /* Redirect visitor to the thank you page */ header('Location: thanks.html'); exit(); /* Functions we used */ function check_input($data, $problem='') { $data = trim($data); $data = stripslashes($data); $data = htmlspecialchars($data); if ($problem && strlen($data) == 0) { show_error($problem); } return $data; } function show_error($myError) { ?> <html> <body> <b>Please correct the following error:</b><br /> <?php echo $myError; ?> </body> </html> <?php exit(); } ?> Quote Link to comment Share on other sites More sharing options...
Tam_Zeb Posted August 23, 2014 Author Share Posted August 23, 2014 Managed to grab a few hours sleep. Ok above is the code I am using for my contact.php I pulled it from a tutorial on the web and stripped out the stuff that wasn't relevant to my needs. Quote Link to comment Share on other sites More sharing options...
CroNiX Posted August 23, 2014 Share Posted August 23, 2014 You still haven't stated exactly what the error you get is, only that it "made reference to the php.ini". Copy/Paste the exact error message here. Quote Link to comment Share on other sites More sharing options...
Tam_Zeb Posted August 23, 2014 Author Share Posted August 23, 2014 There is NO php.ini file on my server.. I want to create a php.ini to upload.. All I want is some simple code which will recognize my contact.php Quote Link to comment Share on other sites More sharing options...
Tam_Zeb Posted August 23, 2014 Author Share Posted August 23, 2014 Warning: mail() [function.mail]: "sendmail_from" not set in php.ini or custom "From:" header missing in E:\kunden\homepages\24\d540637311\www\mailtest.php on line 2 Mail sent! Sorry if that came over rather rudely I am still feeling pretty rough. Ok I ran the mailtest.php and here is the error Quote Link to comment Share on other sites More sharing options...
kicken Posted August 23, 2014 Share Posted August 23, 2014 create a file called php.ini with the content: [PHP] sendmail_from = your@email.com Then upload it to the root folder of your hosting account. For some hosts this is enough to create your own php.ini files. If that does not work you can either contact your host to find out how they handle it, or follow the second part of the error's suggestion (or custom "From:" header missing) and add your custom From: header using the fourth parameter to mail Quote Link to comment Share on other sites More sharing options...
Tam_Zeb Posted August 23, 2014 Author Share Posted August 23, 2014 Thanks Guru I guess I should have said I am running on a Windows Server if that should make a difference. Quote Link to comment Share on other sites More sharing options...
kicken Posted August 23, 2014 Share Posted August 23, 2014 Checking the manual for sendmail_from shows that it is a PHP_INI_ALL level setting which means you should just be able to set it using ini_set also rather than muck about with a custom php.ini file. ini_set('sendmail_from', $myemail); mail($myemail, $subject, $message); Quote Link to comment Share on other sites More sharing options...
Tam_Zeb Posted August 23, 2014 Author Share Posted August 23, 2014 Hi Guru Sorry but this is all double dutch to me now. There was I time when I knew all this stuff back in 2002 but I haven't done any coding since about 2008. How quickly ones memory fades. I had thought my Host Provider would have some guidance notes a but alas it's not as user friendly as the old websites used to be where the Host Providers were enthusiastic pioneers keen to help Webmaster build and maintain websites on dialup systems. Now it's just a business and making money.. Quote Link to comment Share on other sites More sharing options...
Tam_Zeb Posted August 23, 2014 Author Share Posted August 23, 2014 I seem to recall my old server having a .htaccess file but this new windows server doesn't have one of those either. I seem to be getting out of my depth with this.. I am just so tired... Sorry for rambling Quote Link to comment Share on other sites More sharing options...
CroNiX Posted August 23, 2014 Share Posted August 23, 2014 $myemail = "MY GOES EMAIL HERE"; //change to your email address mail($myemail, $subject, $message, 'From: ' . $myemail); it's mail(to, subject, message, headers) where "headers" can also be additional headers like "reply-to" but needs to contain at least the From header. Additionally, mail() returns a boolean to tell whether it was successful or not. So you can do something like: if (mail(to, subject, message, from)) { echo 'email sent'; } else { echo 'there was a problem sending the email'; } Quote Link to comment Share on other sites More sharing options...
Tam_Zeb Posted August 23, 2014 Author Share Posted August 23, 2014 Hi CroNix Are you suggesting I modify the contact.php page with this code and if so where exactly does this new code go and is there any code I need to delete ? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.