Draxo Posted May 16, 2012 Share Posted May 16, 2012 Hi, I'd be eternally grateful if someone could tell me where I'm going wrong with the coding for the php form. Many thanks, D <form action="kontaktscript.php" method="post"> <fieldset> <label for="name">Namn:</label> <input type="text" name="name" id="name"/> <label for="name">Tel:</label> <input type="text" name="tel" id="telephone"/> <label for="email">Email:</label> <input type="text" name="email" id="email"/> <label for="message">Meddelande:</label> <textarea id="message"></textarea> <input type="submit" value="Skicka" /> </fieldset> </form> 18384_.php Quote Link to comment Share on other sites More sharing options...
trq Posted May 16, 2012 Share Posted May 16, 2012 It helps if you describe your problem. Quote Link to comment Share on other sites More sharing options...
Draxo Posted May 16, 2012 Author Share Posted May 16, 2012 Hi, sorry, the mail is going through, but no info is being added, it just says name, tel, email, message and then the rest is blank. Quote Link to comment Share on other sites More sharing options...
trq Posted May 16, 2012 Share Posted May 16, 2012 Can you post your php code? Quote Link to comment Share on other sites More sharing options...
Draxo Posted May 16, 2012 Author Share Posted May 16, 2012 Have left out the actual info about the website, google makes it bad for business if it links to this showing the webmaster doesn't know what he's doing, hopefully there will be enough info anyway. <?PHP ###################################################### # # # Forms To Go 4.3.3 # # http://www.bebosoft.com/ # # # ###################################################### error_reporting(E_ERROR | E_WARNING | E_PARSE); ini_set('track_errors', true); function DoStripSlashes($fieldValue) { // temporary fix for PHP6 compatibility - magic quotes deprecated in PHP6 if ( function_exists( 'get_magic_quotes_gpc' ) && get_magic_quotes_gpc() ) { if (is_array($fieldValue) ) { return array_map('DoStripSlashes', $fieldValue); } else { return trim(stripslashes($fieldValue)); } } else { return $fieldValue; } } function FilterCChars($theString) { return preg_replace('/[\x00-\x1F]/', '', $theString); } if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) { $clientIP = $_SERVER['HTTP_X_FORWARDED_FOR']; } else { $clientIP = $_SERVER['REMOTE_ADDR']; } $FTGNAME = DoStripSlashes( $_POST['NAME'] ); $FTGTel = DoStripSlashes( $_POST['TEL'] ); $FTGEmail = DoStripSlashes( $_POST['EMAIL'] ); $FTGMeddelande = DoStripSlashes( $_POST['MEDDELANDE'] ); $validationFailed = false; # Include message in error page and dump it to the browser if ($validationFailed === true) { $errorPage = '<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8" /><title>Error</title></head><body>A <br /><br />Hälsningar,<br /><br />A</body></html>'; $errorPage = str_replace('<!--FIELDVALUE:NAME-->', $FTGNAME, $errorPage); $errorPage = str_replace('<!--FIELDVALUE:TEL:-->', $FTGTEL, $errorPage); $errorPage = str_replace('<!--FIELDVALUE:EMAIL:-->', $FTGEMAIL, $errorPage); $errorPage = str_replace('<!--FIELDVALUE:MEDDELANDE-->', $FTGMEDDELANDE, $errorPage); $errorList = @implode("<br />\n", $FTGErrorMessage); $errorPage = str_replace('<!--VALIDATIONERROR-->', $errorList, $errorPage); echo $errorPage; } if ( $validationFailed === false ) { # Email to Form Owner $emailSubject = FilterCChars("A"); $emailBody = "--FTG_BOUNDRY\n" . "Content-Type: text/plain; charset=\"UTF-8\"\n" . "Content-Transfer-Encoding: base64\n" . "\n" . chunk_split( base64_encode( "NAME : $FTGNAME\n" . "TEL : $FTGTEL\n" . "EMAIL : $FTGEEMAIL\n" . "MEDDELANDE : $FTGMEDDELANDE\n" . "-missing field name- : #-missing field name-#\n" . "" ) ) . "\n" . "--FTG_BOUNDRY\n" . "Content-Type: text/html; charset=\"UTF-8\"\n" . "Content-Transfer-Encoding: base64\n" . "\n" . chunk_split( base64_encode( "<html>\n" . "<head>\n" . "<title></title>\n" . "</head>\n" . "<body>\n" . "NAME : $FTGNAME<br />\n" . "TEL : $FTGTEL<br />\n" . "EMAIL : $FTGEMAIL<br />\n" . "MEDDELANDE : $FTGMEDDELANDE<br />\n" . "</body>\n" . "</html>\n" . "" ) ) . "\n" . "--FTG_BOUNDRY--"; $emailTo = 'Ar <@>'; $emailFrom = FilterCChars("@"); $emailHeader = "From: $emailFrom\n" . "MIME-Version: 1.0\n" . "Content-Type: multipart/alternative; boundary=\"FTG_BOUNDRY\"\n" . "\n"; mail($emailTo, $emailSubject, $emailBody, $emailHeader); # Include message in the success page and dump it to the browser $successPage = '<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8" /><title>Success</title></head><body>A<a href="www/">A</a></body></html>'; $successPage = str_replace('<!--FIELDVALUE:NAME-->', $FTGNAME, $successPage); $successPage = str_replace('<!--FIELDVALUE:TEL-->', $FTGTEL, $successPage); $successPage = str_replace('<!--FIELDVALUE:EMAIL-->', $FTGEMAIL, $successPage); $successPage = str_replace('<!--FIELDVALUE:MEDDELANDE-->', $FTGMEDDELANDE, $successPage); echo $successPage; } ?> Quote Link to comment Share on other sites More sharing options...
trq Posted May 16, 2012 Share Posted May 16, 2012 Your form element names are different to that used in the php code. Quote Link to comment Share on other sites More sharing options...
Jamdog Posted May 16, 2012 Share Posted May 16, 2012 Your form element names are different to that used in the php code. As Thorpe said, your problem is here: $FTGNAME = DoStripSlashes( $_POST['NAME'] ); $FTGTel = DoStripSlashes( $_POST['TEL'] ); $FTGEmail = DoStripSlashes( $_POST['EMAIL'] ); $FTGMeddelande = DoStripSlashes( $_POST['MEDDELANDE'] ); MEDDELANDE doesn't exist at all - in your form, this field has no name... In your form, you need: <label for="message">Meddelande:</label> <textarea id="message" name="meddelande"></textarea> The others are all upper-case in your PHP script, and lower-case in your form. Not sure if this makes a difference, but worth making them the same just in case... Quote Link to comment Share on other sites More sharing options...
Draxo Posted May 16, 2012 Author Share Posted May 16, 2012 Thanks guys, Have got it to show the name field now, the others are still blank, have transformed all form elements in the html to uppercase as there are too many elements in the php form which make me very confused as to which I would make lowercase otherwise. What could the problem be that makes the other fields blank, all names seem to match up now? Quote Link to comment Share on other sites More sharing options...
trq Posted May 16, 2012 Share Posted May 16, 2012 Your going to need to post your current code. In tags please. Quote Link to comment Share on other sites More sharing options...
Draxo Posted May 16, 2012 Author Share Posted May 16, 2012 <form action="kontaktscript.php" method="post"> <fieldset> <label for="name">Namn:</label> <input type="text" name="NAME" id="NAME"/> <label for="name">Tel:</label> <input type="text" name="TEL" id="TEL"/> <label for="email">Email:</label> <input type="text" name="EMAIL" id="EMAIL"/> <label for="MEDDELANDE">Meddelande:</label> <textarea id="MEDDELANDE" name="MEDDELANDE"> </textarea> <input type="submit" value="Skicka" /> </fieldset> </form> <?PHP ###################################################### # # # Forms To Go 4.3.3 # # http://www.bebosoft.com/ # # # ###################################################### error_reporting(E_ERROR | E_WARNING | E_PARSE); ini_set('track_errors', true); function DoStripSlashes($fieldValue) { // temporary fix for PHP6 compatibility - magic quotes deprecated in PHP6 if ( function_exists( 'get_magic_quotes_gpc' ) && get_magic_quotes_gpc() ) { if (is_array($fieldValue) ) { return array_map('DoStripSlashes', $fieldValue); } else { return trim(stripslashes($fieldValue)); } } else { return $fieldValue; } } function FilterCChars($theString) { return preg_replace('/[\x00-\x1F]/', '', $theString); } if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) { $clientIP = $_SERVER['HTTP_X_FORWARDED_FOR']; } else { $clientIP = $_SERVER['REMOTE_ADDR']; } $FTGNAME = DoStripSlashes( $_POST['NAME'] ); $FTGTel = DoStripSlashes( $_POST['TEL'] ); $FTGEmail = DoStripSlashes( $_POST['EMAIL'] ); $FTGMeddelande = DoStripSlashes( $_POST['MEDDELANDE'] ); $validationFailed = false; # Include message in error page and dump it to the browser if ($validationFailed === true) { $errorPage = '<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8" /><title>Error</title></head><body>A <br /><br />A<br /><br />A</body></html>'; $errorPage = str_replace('<!--FIELDVALUE:NAME-->', $FTGNAME, $errorPage); $errorPage = str_replace('<!--FIELDVALUE:TEL:-->', $FTGTEL, $errorPage); $errorPage = str_replace('<!--FIELDVALUE:EMAIL:-->', $FTGEMAIL, $errorPage); $errorPage = str_replace('<!--FIELDVALUE:MEDDELANDE-->', $FTGMEDDELANDE, $errorPage); $errorList = @implode("<br />\n", $FTGErrorMessage); $errorPage = str_replace('<!--VALIDATIONERROR-->', $errorList, $errorPage); echo $errorPage; } if ( $validationFailed === false ) { # Email to Form Owner $emailSubject = FilterCChars("A"); $emailBody = "--FTG_BOUNDRY\n" . "Content-Type: text/plain; charset=\"UTF-8\"\n" . "Content-Transfer-Encoding: base64\n" . "\n" . chunk_split( base64_encode( "NAME : $FTGNAME\n" . "TEL : $FTGTEL\n" . "EMAIL : $FTGEEMAIL\n" . "MEDDELANDE : $FTGMEDDELANDE\n" . "-missing field name- : #-missing field name-#\n" . "" ) ) . "\n" . "--FTG_BOUNDRY\n" . "Content-Type: text/html; charset=\"UTF-8\"\n" . "Content-Transfer-Encoding: base64\n" . "\n" . chunk_split( base64_encode( "<html>\n" . "<head>\n" . "<title></title>\n" . "</head>\n" . "<body>\n" . "NAME : $FTGNAME<br />\n" . "TEL : $FTGTEL<br />\n" . "EMAIL : $FTGEMAIL<br />\n" . "MEDDELANDE : $FTGMEDDELANDE<br />\n" . "</body>\n" . "</html>\n" . "" ) ) . "\n" . "--FTG_BOUNDRY--"; $emailTo = 'A <@>'; $emailFrom = FilterCChars("@"); $emailHeader = "From: $emailFrom\n" . "MIME-Version: 1.0\n" . "Content-Type: multipart/alternative; boundary=\"FTG_BOUNDRY\"\n" . "\n"; mail($emailTo, $emailSubject, $emailBody, $emailHeader); # Include message in the success page and dump it to the browser $successPage = '<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8" /><title>Success</title></head><body>A<a href="www/">A</a></body></html>'; $successPage = str_replace('<!--FIELDVALUE:NAME-->', $FTGNAME, $successPage); $successPage = str_replace('<!--FIELDVALUE:TEL-->', $FTGTEL, $successPage); $successPage = str_replace('<!--FIELDVALUE:EMAIL-->', $FTGEMAIL, $successPage); $successPage = str_replace('<!--FIELDVALUE:MEDDELANDE-->', $FTGMEDDELANDE, $successPage); echo $successPage; } ?> Quote Link to comment Share on other sites More sharing options...
Jamdog Posted May 16, 2012 Share Posted May 16, 2012 Variable names in PHP are case sensitive... You have: $FTGNAME = DoStripSlashes( $_POST['NAME'] ); $FTGTel = DoStripSlashes( $_POST['TEL'] ); $FTGEmail = DoStripSlashes( $_POST['EMAIL'] ); $FTGMeddelande = DoStripSlashes( $_POST['MEDDELANDE'] ); So, your variables here are: $FTGNAME, $FTGTel, $FTGEmail and $FTGMeddelande then you try to use them: $errorPage = str_replace('<!--FIELDVALUE:NAME-->', $FTGNAME, $errorPage); $errorPage = str_replace('<!--FIELDVALUE:TEL:-->', $FTGTEL, $errorPage); $errorPage = str_replace('<!--FIELDVALUE:EMAIL:-->', $FTGEMAIL, $errorPage); $errorPage = str_replace('<!--FIELDVALUE:MEDDELANDE-->', $FTGMEDDELANDE, $errorPage); and further down: . chunk_split( base64_encode( "NAME : $FTGNAME\n" . "TEL : $FTGTEL\n" . "EMAIL : $FTGEEMAIL\n" . "MEDDELANDE : $FTGMEDDELANDE\n" where (in both cases) you are looking for $FTGNAME, $FTGTEL, $FTGEMAIL and $FTGMEDDELANDE. $FTGNAME matches the variable name from the $_POST line. The other three will be blank because, as far as PHP is concerned, they are different variables, just as if they were different names. For example: $i = 5; $I = 10; print $i; would output 5, not 10... If you change the variable names to caps here, it should cure your program: $FTGNAME = DoStripSlashes( $_POST['NAME'] ); $FTGTEL = DoStripSlashes( $_POST['TEL'] ); $FTGEMAIL = DoStripSlashes( $_POST['EMAIL'] ); $FTGMEDDELANDE = DoStripSlashes( $_POST['MEDDELANDE'] ); Quote Link to comment Share on other sites More sharing options...
Draxo Posted May 19, 2012 Author Share Posted May 19, 2012 Thanks man, got it working 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.