lauriedunsire Posted July 15, 2009 Share Posted July 15, 2009 Hi everyone, I'm requiring some help with a simple PHP form used on a website for one of my clients. I am a novice when it comes to PHP, to say the least, and I just really used it for contact forms on websites that I produce. I use the same standard template which has always worked fine, however today one site has just stopped recieving anything - not sure how long it has not been working for but they certainly haven't receieved anything recently - so I'm worried it may be the same on all my sites. Basically the contact page itself has the following for on it: <FORM name=form4 action=sendinfo3.php method=post> Full Name: <br> <INPUT name=Name:> <br> <br> Full Company Name: <br> <INPUT name=Company:> <br> <br> Company Telephone Number: <br> <INPUT name=Telephone:> <br> <br> Company Email Address: <br> <INPUT name=email:> <br> <br> Reference Number: <br> <INPUT name=Reference:> <br> <P> <INPUT type=reset value=Reset name=Reset> </P> <P> <INPUT type=submit value=Submit name=Submit> <span class="style6">*Please ensure you fill out <strong>every</strong> field in the form. </span> </P> <P></P> </FORM> And the 'sendinfo3.php' file contains the following: <? $message1 =$_REQUEST ["Name:"]; $message2 =$_REQUEST ["Company:"]; $message3 =$_REQUEST ["Telephone:"]; $message4 =$_REQUEST ["email:"]; $message5 =$_REQUEST ["Reference:"]; $email =$_REQUEST ["email:"]; mail( "info@mydomain.com", "Special Trial Offer Request", "Name: $message1\n Company: $message2\n Telephone: $message3\n email: $message4\n Reference: $message5\n","from: $email:"); header("Location:http://www.mydomain.com/trialoffer/redir.html" ); ?> There might well be a basic error somewhere here, and if there is if someone could let me know it would be much appreciated. I'm just confused as to why this was working previously and now doesn't seem to respond at all Many thanks, Laurie Quote Link to comment https://forums.phpfreaks.com/topic/166113-php-form-very-basic-code-need-assistance/ Share on other sites More sharing options...
Noumes Posted July 15, 2009 Share Posted July 15, 2009 Try and set it up using variables, so your mail function looks like: //invoke mail function to send email mail($toaddress, $subject, $mailcontent, $fromaddress); so when gathering from post try: $name= trim(ucwords($_POST['name'])); $company= trim(ucwords($_POST['company'])); $telephone= trim($_POST['telephone']); $email= trim($_POST['email']); $toaddress = your@email.com; $fromaddress = "From: webserver@example.com"; $subject = "Feedback from web site"; $mailcontent = "<b>Customer Name</b>: ".$name."\n". <b>Customer Company</b>: ".$company."\n". <b>Customer Telephone</b>: ".$telephone."\n". <b>Customer Email</b>: ".$email."\n". Quote Link to comment https://forums.phpfreaks.com/topic/166113-php-form-very-basic-code-need-assistance/#findComment-876080 Share on other sites More sharing options...
KevinM1 Posted July 15, 2009 Share Posted July 15, 2009 Also: 1. Put your form inputs' names within quotes in the HTML (i.e.: <input name="Name"> ). 2. Don't put a space between an array name and the key you're trying to access. In other words, do this: $name = $_REQUEST["Name:"]; 3. Use the right superglobal array instead of $_REQUEST. Since you're passing the data in via POST, use $_POST. 4. Are you certain that you can mail things out successfully? Have you tried writing a small test script to see if the mail() function is working at all? Quote Link to comment https://forums.phpfreaks.com/topic/166113-php-form-very-basic-code-need-assistance/#findComment-876084 Share on other sites More sharing options...
lauriedunsire Posted July 16, 2009 Author Share Posted July 16, 2009 Ok forgive my stupidity, using the above script I presume the $toaddress = your@email.com; line is for whatever email the form will be forwarding to? Is the email supposed to be like that just as itself, as it doesn't seem to want to forward it to the email. And what sort of short test script should I use to test the mail function? Quote Link to comment https://forums.phpfreaks.com/topic/166113-php-form-very-basic-code-need-assistance/#findComment-876300 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.