tg11 Posted March 21, 2006 Share Posted March 21, 2006 Hi all,Im looking for some advice regarding my email form on a website I did for somebody. I received an email asking me to make som adjustments to it. This is the code I was originally using that worked fine [code]<?php // Website Contact Form Generator // [url]http://www.tele-pro.co.uk/scripts/contact_form/[/url] // This script is free to use as long as you // retain the credit link // get posted data into local variables $EmailFrom = Trim(stripslashes($_POST['EmailFrom'])); $EmailTo = "enquiries@celebcars.co.uk"; $Subject = "information request"; $Name = Trim(stripslashes($_POST['Name'])); $subject = Trim(stripslashes($_POST['subject'])); $comments = Trim(stripslashes($_POST['comments'])); // validation $validationOK=true; if (Trim($EmailFrom)=="") $validationOK=false; if (Trim($Name)=="") $validationOK=false; if (Trim($subject)=="") $validationOK=false; if (Trim($comments)=="") $validationOK=false; if (!$validationOK) { print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">"; exit; } // prepare email body text $Body = ""; $Body .= "Name: "; $Body .= $Name; $Body .= "\n"; $Body .= "subject: "; $Body .= $subject; $Body .= "\n"; $Body .= "comments: "; $Body .= $comments; $Body .= "\n"; // send email $success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>"); // redirect to success page if ($success){ print "<meta http-equiv=\"refresh\" content=\"0;URL=thankyou.htm\">"; } else{ print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">"; } ?> [/code]but they said they updated their server and this is a fix here for it [a href=\"http://www.fasthosts.co.uk/knowledg.../?article_id=65\" target=\"_blank\"]http://www.fasthosts.co.uk/knowledg.../?article_id=65[/a]do I just need to add this line they suggest - ini_set("sendmail_from", " email@mydomain "); Im not sure where to add this to the code.Hope somebody can help Im totally lost on this..thanks in advanceRob Quote Link to comment https://forums.phpfreaks.com/topic/5405-email-form-hellp-for-novice/ Share on other sites More sharing options...
redbullmarky Posted March 21, 2006 Share Posted March 21, 2006 I couldn't get the link you provided to work, but the code in question, ini_set, would go before the 'mail' function is called. i normally stick things like that right at the top of my page, after my includes and session_start().the mail function's manual, ( [a href=\"http://uk.php.net/mail\" target=\"_blank\"]http://uk.php.net/mail[/a] ) will probably shed some light on what you want youre tryign to achieve, but when i change servers, normally the only setting i need to alter is 'SMTP' if i havent got a mail server set up on the same server as the php.otherwise, i can't really see many reasons why the code you've posted still wouldnt work as it is.did they give you any info in terms of the problem they were having? Quote Link to comment https://forums.phpfreaks.com/topic/5405-email-form-hellp-for-novice/#findComment-19273 Share on other sites More sharing options...
tg11 Posted March 21, 2006 Author Share Posted March 21, 2006 thanks very much for replying.What was on the link I sent was this PHP on WindowsUse the PHP mail function and set the mail from using the following line of code - replacing email@mydomain with the correct domain name.ini_set("sendmail_from", " email@mydomain "); So I am assuming that all I would need to do was to add it to my code like this, Is this right?thanks [code]<?phpini_set("sendmail_from", " enquiries@celebcars.co.uk");// get posted data into local variables$EmailFrom = Trim(stripslashes($_POST['EmailFrom'])); $EmailTo = "enquiries@celebcars.co.uk";$Subject = "information request";$Name = Trim(stripslashes($_POST['Name'])); $subject = Trim(stripslashes($_POST['subject'])); $comments = Trim(stripslashes($_POST['comments'])); // validation$validationOK=true;if (Trim($EmailFrom)=="") $validationOK=false;if (Trim($Name)=="") $validationOK=false;if (Trim($subject)=="") $validationOK=false;if (Trim($comments)=="") $validationOK=false;if (!$validationOK) { print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">"; exit;}// prepare email body text$Body = "";$Body .= "Name: ";$Body .= $Name;$Body .= "\n";$Body .= "subject: ";$Body .= $subject;$Body .= "\n";$Body .= "comments: ";$Body .= $comments;$Body .= "\n";// send email $success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>");// redirect to success page if ($success){ print "<meta http-equiv=\"refresh\" content=\"0;URL=thankyou.htm\">";}else{ print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";}?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/5405-email-form-hellp-for-novice/#findComment-19275 Share on other sites More sharing options...
redbullmarky Posted March 21, 2006 Share Posted March 21, 2006 pretty much, yes.if they have further problems, then a line like:[code]ini_set("SMTP", "smtp.celebcars.co.uk");[/code]or whatever their outgoing mailserver is next to the other ini_set line should also help. Quote Link to comment https://forums.phpfreaks.com/topic/5405-email-form-hellp-for-novice/#findComment-19276 Share on other sites More sharing options...
tg11 Posted March 21, 2006 Author Share Posted March 21, 2006 thanks a lot, I'll give that a try, I know it was working flawlessly up until a couple of days ago. Quote Link to comment https://forums.phpfreaks.com/topic/5405-email-form-hellp-for-novice/#findComment-19279 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.