Hi, i m using the below php form to get contacted by visitor but always it redirected to error page. <?PHP error_reporting(7); if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) { $ClientIP = $_SERVER['HTTP_X_FORWARDED_FOR']; } else { $ClientIP = $_SERVER['REMOTE_ADDR']; } $FTGname = $_POST['name']; $FTGemail = $_POST['email']; $FTGcity = $_POST['city']; $FTGphone = $_POST['phone']; $FTGmessage = $_POST['message']; $FTGSubmit = $_POST['Submit']; $FTGReset = $_POST['Reset']; $FTGselect = $select; $FTGname = $name; $FTGemail = $email; #$FTGtitle = $title; #$FTGcompany = $company; #$FTGwebsite = $website; $FTGcity = $city; #$FTGcountry = $country; $FTGphone = $phone; #$FTGfax = $fax; #$FTGbusiness = $business; #$FTGmessage = $message; $FTGSubmit = $Submit; $FTGReset = $Reset; #if (get_magic_quotes_gpc) { #$FTGselect = DoStripSlashes( $_REQUEST['select'] ); #$FTGname = DoStripSlashes( $_REQUEST['name'] ); #$FTGemail = DoStripSlashes( $_REQUEST['email'] ); #$FTGtitle = DoStripSlashes( $_REQUEST['title'] ); #$FTGcompany = DoStripSlashes( $_REQUEST['company'] ); #$FTGwebsite = DoStripSlashes( $_REQUEST['website'] ); #$FTGcity = DoStripSlashes( $_REQUEST['city'] ); #$FTGcountry = DoStripSlashes( $_REQUEST['country'] ); #$FTGphone = DoStripSlashes( $_REQUEST['phone'] ); #$FTGfax = DoStripSlashes( $_REQUEST['fax'] ); # $FTGbusiness = DoStripSlashes( $_REQUEST['business'] ); #$FTGmessage =DoStripSlashes( $_REQUEST['message'] ); #$FTGSubmit = DoStripSlashes( $_REQUEST['Submit'] ); #$FTGReset = DoStripSlashes( $_REQUEST['Reset'] ); $FTGname = stripslashes($FTGname); $FTGemail = stripslashes($FTGemail); $FTGcity = stripslashes($FTGcity); $FTGphone = stripslashes($FTGphone); $FTGmessage = stripslashes($FTGmessage); $FTGSubmit = stripslashes($FTGSubmit); $FTGReset = stripslashes($FTGReset); #} # Redirect user to the error page if ($validationFailed == false) { header("Location: error.html"); exit; } # Email to Form Owner $emailTo = '"nura235@gmail.com" <nura235@gmail.com>'; $emailSubject = "Form details for AA Patent Drawings"; $emailSubject = preg_replace('/[\x00-\x1F]/', '', $emailSubject); $emailFrom = "$FTGemail"; $emailFrom = preg_replace('/[\x00-\x1F]/', '', $emailFrom); $emailBody = "name: $FTGname\n" . "email: $FTGemail\n" . "city: $FTGcity\n" . "phone: $FTGphone\n" . "message: $FTGmessage\n" . "\n" . ""; $emailHeader = "From: $emailFrom\n" . "Reply-To: $emailFrom\n" . "MIME-Version: 1.0\n" . "Content-type: text/plain; charset=\"ISO-8859-1\"\n" . "Content-transfer-encoding: 8bit\n"; mail($emailTo, $emailSubject, $emailBody, $emailHeader); # Confirmation Email to User #$confEmailTo = $FTGemail; #$confEmailTo = preg_replace('/[\x00-\x1F]/', '', $confEmailTo); #$confEmailSubject = "Thank you for contacting us"; #$confEmailSubject = preg_replace('/[\x00-\x1F]/', '', $confEmailSubject); #$confEmailBody = "Dear $FTGname,\n" #. "Thanks for contacting us, one of our representatives will contact you within 24 hours.\n" #. "\n" #. "Following are the details submitted by you :-\n" #. "name: $FTGname\n" #. "email: $FTGemail\n" #. "city: $FTGcity\n" #. "phone: $FTGphone\n" #. "message: $FTGmessage\n" #. "\n" #. "Yours,\n" #. "AA Patent Drawings"; $confEmailHeader = "From: nura235@gmail.com\n" . "Reply-To: nura235@gmail.com\n" . "MIME-Version: 1.0\n" . "Content-type: text/plain; charset=\"ISO-8859-1\"\n" . "Content-transfer-encoding: 8bit\n"; mail($confEmailTo, $confEmailSubject, $confEmailBody, $confEmailHeader); # Redirect user to success page header("Location: thanks.html"); exit; # End of PHP script ?> PHP: i m using this form here http://www.aapatentdrawings.com/contact-us.html Code (markup):
You can't troubleshoot a PHP application with error reporting set to a useless level. Line 2 should read:
Using PHP in contact pages is really a mess dude..! Instead Use HTML+CSS for contact page structure and Use PHP to get it mailed to your Email..! That would be easy for you..! Just a suggestion This is just a suggestion, And Sorry if you feel am bumping the thread. I can delete this post if you feel so...! Thanks.
Take a look at this error: Warning: Cannot modify header information - headers already sent by (output started at [path]) in [path] on line 62 It is telling you that the headers were already sent. Headers might include the session, cookies, and so forth. You can buffer the output by using ob_start();
seems that you're using lots of uncdefined variables: $FTGselect = $select; $FTGname = $name; $FTGemail = $email; PHP: those on the right side are undefined. Also, $validationFailed == false PHP: $validationFailed will always be null (undefined) there yielding to false with ==. That's why probably you're always redirected
Change contact page script or remove And in something inc.php search for $validation and remove that! Still if you can't resolve PM me the whole thing
i just made it work $validationFailed == true PHP: but making true, dont check if form is blank or any error
problem solved, used another php form. easily implement to my website css and also customized field name. recommended for others : http://cssproperty.com/php-mail-form/
An automatically generated form.. the best way to not learn anything about PHP! I would recommend you find a good tutorial and make a form yourself. The skills you learn as a developer are invaluable.
Your demo: http://www.aapatentdrawings.com/contact-us.html html for the form is totally different to the code you posted??. Furthermore your code is a mess undefined variables and so on. I suggest you recode from scratch or atleast reply with the html for your contact form so we can assist you with the php to go with it.
Yes i agree with your word, but i m not a professional programmer, just only know playing with some of php codes, anyway thanks for your help, i assume that my current code is much better than previous one, it give alert instantly when something goes wrong, while on php it give error after submit. Yes this is bcoz i find the correct working another code.