October 17, 200916 yr Hello, I'm wondering if someone can be kind enough to at least give me some pointers with regards to creating a php script. I have an xhtml page(s) that's the main contact form in which the php will get the data from, and I have a OK and failure page for after the button is pressed. I need php code to be exclusive to a php page and not mixed with the xhtml. The main css style sheet will style all webpages and the contact form in the xhtml page. I need it to be secure and I'll try and try add recaptcha to it after. I've looked at tecrite and phpmailer code, and seeing it has over 1,000 lines of code it kind of went way over my head. <?php // get posted data into local variables $EmailFrom = Trim(stripslashes($_POST['EmailFrom'])); $EmailTo = "jon@mywebsite.com"; $Subject = "from web site"; $Name = Trim(stripslashes($_POST['Name'])); $Address = Trim(stripslashes($_POST['Address'])); $Telephone = Trim(stripslashes($_POST['Telephone'])); $message = Trim(stripslashes($_POST['message'])); // validation $validationOK=true; if (Trim($EmailFrom)=="") $validationOK=false; if (Trim($message)=="") $validationOK=false; if (!$validationOK) { print "<meta http-equiv=\"refresh\" content=\"0;URL=failure.htm\">"; exit; } // prepare email body text $Body = ""; $Body .= "Name: "; $Body .= $Name; $Body .= "\n"; $Body .= "Address: "; $Body .= $Address; $Body .= "\n"; $Body .= "Telephone: "; $Body .= $Telephone; $Body .= "\n"; $Body .= "message: "; $Body .= $message; $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=ok.htm\">"; } else{ print "<meta http-equiv=\"refresh\" content=\"0;URL=failure.htm\">"; } ?>
October 17, 200916 yr Hi Look at Jem's PHP form script at http://www.jemjabella.co.uk/php-scripts#php-mail-form It gets a lot of praise.
October 18, 200916 yr Hi, I have a PHP (OOP) contact form processing script on a secure (SSL) server, you can use if your interested. Upon success or failure we can redirect the users back to any location you wish. PM me if you interested. Kyle Edited October 18, 200916 yr by Kyle Hudson MCP CCNA CIW
Create an account or sign in to comment