lonelobo Posted February 17, 2009 Share Posted February 17, 2009 Greetings to one and all! I just found this forum after doing a google search (actually it was the first forum listed so kudos to the website!) and am hoping someone here can help me with a problem I am having. First let me state that while I have programming experience, it isn't in PHP and thus my frustration with figuring out why this isn't working. The Basic Scenario Ok, so the short version of this is I am trying to create an online form for specific individuals to fill out. It's your basic information form, but also has the capacity for file uploads. I used DW CS4 to create the form itself, and because I am not very PHP savvy I went out and got "Forms2Go" because that program is supposed to take my code and create a PHP that is viable for my purpose. The Problem I could say, "it doesn't work" but that would not be specific. What happens when I test the form is this: I fill it out. I attach a dummy file (to test that aspect). I click "submit" The form then seemingly processes it and I get a screen that says, "Form submitted successfully. It will be reviewed soon." Problem is, I never see it. It is supposed to email the form to me (in HTML format), but nothing ever happens. I don't know if it's going into la la land in cyberspace, some random person is getting random forms in their email or what is happening. The one thing I know that ISN'T happening is the form isn't showing up in my email. As this is my first post to this forum, I can only hope that this is the correct place for me to be right now to submit this request. My apologies to any and all for my ignorance of PHP but this is a great learning opportunity for me too. My thanks in advance to any and all responders. If you need more specific information, want too see snippets of code, etc just let me know! Quote Link to comment https://forums.phpfreaks.com/topic/145647-problem-with-a-form-submission/ Share on other sites More sharing options...
allworknoplay Posted February 17, 2009 Share Posted February 17, 2009 You'd have to really contact the people at FORMS2GO as it is their script. I mean, you haven't really provided code or anything, just a general issue.... There's not much we can really do to help ya?? Quote Link to comment https://forums.phpfreaks.com/topic/145647-problem-with-a-form-submission/#findComment-764611 Share on other sites More sharing options...
lonelobo Posted February 17, 2009 Author Share Posted February 17, 2009 I'm sorry, I wasn't sure what part of the code to post? Should I post the whole PHP document? Quote Link to comment https://forums.phpfreaks.com/topic/145647-problem-with-a-form-submission/#findComment-764618 Share on other sites More sharing options...
allworknoplay Posted February 17, 2009 Share Posted February 17, 2009 I'm sorry, I wasn't sure what part of the code to post? Should I post the whole PHP document? Well you could but if it's like 100 lines, I'm not sure anyone will take the time to read it all... are you hosting your website yourself or at an ISP? please try to provide as much info about your hosting environment as much as possible. Quote Link to comment https://forums.phpfreaks.com/topic/145647-problem-with-a-form-submission/#findComment-764623 Share on other sites More sharing options...
lonelobo Posted February 17, 2009 Author Share Posted February 17, 2009 Ok, I'm entering the code here, slightly edited (nothing that makes a difference). I don't know how many lines there are but you can probably cruise past most of it. From what I can see the email submission should work fine, and yet nothing happens. As I mentioned before when I click submit all I get on the "Success" window is "Form submitted successfully. It will be reviewed soon." The site/page is hosted by GoDaddy. PHP is an acceptable medium for the page. CODE <?PHP define('kOptional', true); define('kMandatory', false); define('kStringRangeFrom', 1); define('kStringRangeTo', 2); define('kStringRangeBetween', 3); define('kYes', 'yes'); define('kNo', 'no'); error_reporting(E_ERROR | E_WARNING | E_PARSE); ini_set('track_errors', true); function ListArray($theArray) { return @implode(", ", $theArray); } function DoStripSlashes($fieldValue) { if ( get_magic_quotes_gpc() ) { if (is_array($fieldValue) ) { return array_map('DoStripSlashes', $fieldValue); } else { return stripslashes($fieldValue); } } else { return $fieldValue; } } function FilterCChars($theString) { return preg_replace('/[\x00-\x1F]/', '', $theString); } function CheckString($value, $low, $high, $mode, $limitAlpha, $limitNumbers, $limitEmptySpaces, $limitExtraChars, $optional) { if ($limitAlpha == kYes) { $regExp = 'A-Za-z'; } if ($limitNumbers == kYes) { $regExp .= '0-9'; } if ($limitEmptySpaces == kYes) { $regExp .= ' '; } if (strlen($limitExtraChars) > 0) { $search = array('\\', '[', ']', '-', '$', '.', '*', '(', ')', '?', '+', '^', '{', '}', '|', '/'); $replace = array('\\\\', '\[', '\]', '\-', '\$', '\.', '\*', '\(', '\)', '\?', '\+', '\^', '\{', '\}', '\|', '\/'); $regExp .= str_replace($search, $replace, $limitExtraChars); } if ( (strlen($regExp) > 0) && (strlen($value) > 0) ){ if (preg_match('/[^' . $regExp . ']/', $value)) { return false; } } if ( (strlen($value) == 0) && ($optional === kOptional) ) { return true; } elseif ( (strlen($value) >= $low) && ($mode == kStringRangeFrom) ) { return true; } elseif ( (strlen($value) <= $high) && ($mode == kStringRangeTo) ) { return true; } elseif ( (strlen($value) >= $low) && (strlen($value) <= $high) && ($mode == kStringRangeBetween) ) { return true; } else { return false; } } function CheckEmail($email, $optional) { if ( (strlen($email) == 0) && ($optional === kOptional) ) { return true; } elseif ( eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$", $email) ) { return true; } else { return false; } } if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) { $clientIP = $_SERVER['HTTP_X_FORWARDED_FOR']; } else { $clientIP = $_SERVER['REMOTE_ADDR']; } $FTGfirstName = DoStripSlashes( $_POST['firstName'] ); $FTGmonth = DoStripSlashes( $_POST['month'] ); $FTGday = DoStripSlashes( $_POST['day'] ); $FTGyear = DoStripSlashes( $_POST['year'] ); $FTGlastName = DoStripSlashes( $_POST['lastName'] ); $FTGheight = DoStripSlashes( $_POST['height'] ); $FTGphone = DoStripSlashes( $_POST['phone'] ); $FTGweight = DoStripSlashes( $_POST['weight'] ); $FTGemail = DoStripSlashes( $_POST['email'] ); $FTGethnicity = DoStripSlashes( $_POST['ethnicity'] ); $FTGStreetAddress = DoStripSlashes( $_POST['StreetAddress'] ); $FTGhairColor = DoStripSlashes( $_POST['hairColor'] ); $FTGcity = DoStripSlashes( $_POST['city'] ); $FTGeyeColor = DoStripSlashes( $_POST['eyeColor'] ); $FTGstate = DoStripSlashes( $_POST['state'] ); $FTGchest = DoStripSlashes( $_POST['chest'] ); $FTGcountry = DoStripSlashes( $_POST['country'] ); $FTGcup = DoStripSlashes( $_POST['cup'] ); $FTGzipCode = DoStripSlashes( $_POST['zipCode'] ); $FTGhips = DoStripSlashes( $_POST['hips'] ); $FTGexperience = DoStripSlashes( $_POST['experience'] ); $FTGwaist = DoStripSlashes( $_POST['waist'] ); $FTGwebsite = DoStripSlashes( $_POST['website'] ); $FTGshoeSize = DoStripSlashes( $_POST['shoeSize'] ); $FTGtravel = DoStripSlashes( $_POST['travel'] ); $FTGdressSize = DoStripSlashes( $_POST['dressSize'] ); $FTGmark = DoStripSlashes( $_POST['mark'] ); $FTGmarkDesc = DoStripSlashes( $_POST['markDesc'] ); $FTGcasting = DoStripSlashes( $_POST['casting'] ); $FTGcomments = DoStripSlashes( $_POST['comments'] ); $FTGuserfile = $_FILES['userfile']['name']; $FTGinsert = DoStripSlashes( $_POST['insert'] ); $FTGSubmit = DoStripSlashes( $_POST['Submit'] ); $List_casting = ListArray($FTGcasting); $validationFailed = false; # Fields Validations if (!CheckEmail($FTGemail, kMandatory)) { $FTGErrorMessage['email'] = 'You must enter a valid email address'; $validationFailed = true; } if (!CheckString($FTGcountry, 1, 0, kStringRangeFrom, kNo, kNo, kNo, '', kMandatory)) { $FTGErrorMessage['country'] = 'Please enter a valid country'; $validationFailed = true; } # Include message in error page and dump it to the browser if ($validationFailed === true) { $errorPage = '<html><head><title>Error</title></head><body>Errors found: <!--VALIDATIONERROR--></body></html>'; $errorPage = str_replace('<!--FIELDVALUE:firstName-->', $FTGfirstName, $errorPage); $errorPage = str_replace('<!--FIELDVALUE:month-->', $FTGmonth, $errorPage); $errorPage = str_replace('<!--FIELDVALUE:day-->', $FTGday, $errorPage); $errorPage = str_replace('<!--FIELDVALUE:year-->', $FTGyear, $errorPage); $errorPage = str_replace('<!--FIELDVALUE:lastName-->', $FTGlastName, $errorPage); $errorPage = str_replace('<!--FIELDVALUE:height-->', $FTGheight, $errorPage); $errorPage = str_replace('<!--FIELDVALUE:phone-->', $FTGphone, $errorPage); $errorPage = str_replace('<!--FIELDVALUE:weight-->', $FTGweight, $errorPage); $errorPage = str_replace('<!--FIELDVALUE:email-->', $FTGemail, $errorPage); $errorPage = str_replace('<!--FIELDVALUE:ethnicity-->', $FTGethnicity, $errorPage); $errorPage = str_replace('<!--FIELDVALUE:StreetAddress-->', $FTGStreetAddress, $errorPage); $errorPage = str_replace('<!--FIELDVALUE:hairColor-->', $FTGhairColor, $errorPage); $errorPage = str_replace('<!--FIELDVALUE:city-->', $FTGcity, $errorPage); $errorPage = str_replace('<!--FIELDVALUE:eyeColor-->', $FTGeyeColor, $errorPage); $errorPage = str_replace('<!--FIELDVALUE:state-->', $FTGstate, $errorPage); $errorPage = str_replace('<!--FIELDVALUE:chest-->', $FTGchest, $errorPage); $errorPage = str_replace('<!--FIELDVALUE:country-->', $FTGcountry, $errorPage); $errorPage = str_replace('<!--FIELDVALUE:cup-->', $FTGcup, $errorPage); $errorPage = str_replace('<!--FIELDVALUE:zipCode-->', $FTGzipCode, $errorPage); $errorPage = str_replace('<!--FIELDVALUE:hips-->', $FTGhips, $errorPage); $errorPage = str_replace('<!--FIELDVALUE:experience-->', $FTGexperience, $errorPage); $errorPage = str_replace('<!--FIELDVALUE:waist-->', $FTGwaist, $errorPage); $errorPage = str_replace('<!--FIELDVALUE:website-->', $FTGwebsite, $errorPage); $errorPage = str_replace('<!--FIELDVALUE:shoeSize-->', $FTGshoeSize, $errorPage); $errorPage = str_replace('<!--FIELDVALUE:travel-->', $FTGtravel, $errorPage); $errorPage = str_replace('<!--FIELDVALUE:dressSize-->', $FTGdressSize, $errorPage); $errorPage = str_replace('<!--FIELDVALUE:mark-->', $FTGmark, $errorPage); $errorPage = str_replace('<!--FIELDVALUE:markDesc-->', $FTGmarkDesc, $errorPage); $errorPage = str_replace('<!--FIELDVALUE:casting-->', $List_casting, $errorPage); $errorPage = str_replace('<!--FIELDVALUE:comments-->', $FTGcomments, $errorPage); $errorPage = str_replace('<!--FIELDVALUE:userfile-->', $FTGuserfile, $errorPage); $errorPage = str_replace('<!--FIELDVALUE:insert-->', $FTGinsert, $errorPage); $errorPage = str_replace('<!--FIELDVALUE:Submit-->', $FTGSubmit, $errorPage); $errorPage = str_replace('<!--ERRORMSG:email-->', $FTGErrorMessage['email'], $errorPage); $errorPage = str_replace('<!--ERRORMSG:country-->', $FTGErrorMessage['country'], $errorPage); $errorList = @implode("<br />\n", $FTGErrorMessage); $errorPage = str_replace('<!--VALIDATIONERROR-->', $errorList, $errorPage); echo $errorPage; } if ( $validationFailed === false ) { # Email to Form Owner $emailSubject = FilterCChars("New Model Submission"); $emailBody = "--FTG_BOUNDRY\n" . "Content-Type: text/html; charset=\"ISO-8859-1\"\n" . "Content-Transfer-Encoding: base64\n" . "\n" . chunk_split( base64_encode( "<html>\n" . "<head>\n" . "<title></title>\n" . "</head>\n" . "<body>\n" . "\n" . "" . $_SERVER['HTTP_USER_AGENT'] . "\n" . "$clientIP\n" . "" . date('d/m/Y') . "\n" . "\n" . "Name: $FTGfirstName $FTGlastName<br />\n" . "Birthdate: $FTGmonth/$FTGday/$FTGyear <br />\n" . "Address : $FTGStreetAddress<br />\n" . " $FTGcity, $FTGstate $FTGzipCode <br />\n" . " $FTGcountry<br />\n" . "\n" . "Phone : $FTGphone<br />\n" . "Email : $FTGemail<br />\n" . "\n" . "Height : $FTGheight<br />\n" . "Weight : $FTGweight<br />\n" . "Ethnicity : $FTGethnicity<br />\n" . "HairColor : $FTGhairColor<br />\n" . "EyeColor : $FTGeyeColor<br />\n" . "Experience : $FTGexperience<br />\n" . "\n" . "Chest : $FTGchest $FTGcup<br />\n" . "Waist : $FTGwaist<br />\n" . "Hips : $FTGhips<br />\n" . "\n" . "DressSize : $FTGdressSize<br />\n" . "ShoeSize : $FTGshoeSize<br />\n" . "\n" . "Travel : $FTGtravel<br />\n" . "\n" . "Tattoos/piercings or markings: $FTGmark<br />\n" . "Description: $FTGmarkDesc<br />\n" . "\n" . "Website : $FTGwebsite<br />\n" . "\n" . "Styles of Glamour : $List_casting<br />\n" . "\n" . "Comments/Credits: $FTGcomments<br />\n" . "\n" . "\n" . "userfile : $FTGuserfile<br />\n" . "insert : $FTGinsert<br />\n" . "Submit : $FTGSubmit<br />\n" . "</body>\n" . "</html>\n" . "" ) ) . "\n"; if ( is_uploaded_file($_FILES['userfile']['tmp_name']) ) { $fileName = $_FILES['userfile']['tmp_name']; $fileHandle = fopen($fileName, 'r'); $fileAttach = fread($fileHandle, filesize ($fileName)); fclose($fileHandle); $fileAttach = chunk_split(base64_encode($fileAttach)); $emailBody .= "--FTG_BOUNDRY\n" . "Content-Type: " . $_FILES['userfile']['type'] . "; name=\"" . $_FILES['userfile']['name'] . "\"\n" . "Content-disposition: attachment\n" . "Content-transfer-encoding: base64\n" . "\n" . "$fileAttach\n" . "\n"; } $emailBody .= "--FTG_BOUNDRY--\n"; $emailTo = 'Model Submission <[email protected]>'; $emailFrom = FilterCChars("$FTGemail"); $emailHeader = "From: $emailFrom\n" . "MIME-Version: 1.0\n" . "Content-Type: multipart/mixed; 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><title>Success</title></head><body>Form submitted successfully. It will be reviewed soon.</body></html>'; $successPage = str_replace('<!--FIELDVALUE:firstName-->', $FTGfirstName, $successPage); $successPage = str_replace('<!--FIELDVALUE:month-->', $FTGmonth, $successPage); $successPage = str_replace('<!--FIELDVALUE:day-->', $FTGday, $successPage); $successPage = str_replace('<!--FIELDVALUE:year-->', $FTGyear, $successPage); $successPage = str_replace('<!--FIELDVALUE:lastName-->', $FTGlastName, $successPage); $successPage = str_replace('<!--FIELDVALUE:height-->', $FTGheight, $successPage); $successPage = str_replace('<!--FIELDVALUE:phone-->', $FTGphone, $successPage); $successPage = str_replace('<!--FIELDVALUE:weight-->', $FTGweight, $successPage); $successPage = str_replace('<!--FIELDVALUE:email-->', $FTGemail, $successPage); $successPage = str_replace('<!--FIELDVALUE:ethnicity-->', $FTGethnicity, $successPage); $successPage = str_replace('<!--FIELDVALUE:StreetAddress-->', $FTGStreetAddress, $successPage); $successPage = str_replace('<!--FIELDVALUE:hairColor-->', $FTGhairColor, $successPage); $successPage = str_replace('<!--FIELDVALUE:city-->', $FTGcity, $successPage); $successPage = str_replace('<!--FIELDVALUE:eyeColor-->', $FTGeyeColor, $successPage); $successPage = str_replace('<!--FIELDVALUE:state-->', $FTGstate, $successPage); $successPage = str_replace('<!--FIELDVALUE:chest-->', $FTGchest, $successPage); $successPage = str_replace('<!--FIELDVALUE:country-->', $FTGcountry, $successPage); $successPage = str_replace('<!--FIELDVALUE:cup-->', $FTGcup, $successPage); $successPage = str_replace('<!--FIELDVALUE:zipCode-->', $FTGzipCode, $successPage); $successPage = str_replace('<!--FIELDVALUE:hips-->', $FTGhips, $successPage); $successPage = str_replace('<!--FIELDVALUE:experience-->', $FTGexperience, $successPage); $successPage = str_replace('<!--FIELDVALUE:waist-->', $FTGwaist, $successPage); $successPage = str_replace('<!--FIELDVALUE:website-->', $FTGwebsite, $successPage); $successPage = str_replace('<!--FIELDVALUE:shoeSize-->', $FTGshoeSize, $successPage); $successPage = str_replace('<!--FIELDVALUE:travel-->', $FTGtravel, $successPage); $successPage = str_replace('<!--FIELDVALUE:dressSize-->', $FTGdressSize, $successPage); $successPage = str_replace('<!--FIELDVALUE:mark-->', $FTGmark, $successPage); $successPage = str_replace('<!--FIELDVALUE:markDesc-->', $FTGmarkDesc, $successPage); $successPage = str_replace('<!--FIELDVALUE:casting-->', $List_casting, $successPage); $successPage = str_replace('<!--FIELDVALUE:comments-->', $FTGcomments, $successPage); $successPage = str_replace('<!--FIELDVALUE:userfile-->', $FTGuserfile, $successPage); $successPage = str_replace('<!--FIELDVALUE:insert-->', $FTGinsert, $successPage); $successPage = str_replace('<!--FIELDVALUE:Submit-->', $FTGSubmit, $successPage); echo $successPage; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/145647-problem-with-a-form-submission/#findComment-764640 Share on other sites More sharing options...
Cal Posted February 17, 2009 Share Posted February 17, 2009 Maybe your hosting account doesn't have mail() enabled? Quote Link to comment https://forums.phpfreaks.com/topic/145647-problem-with-a-form-submission/#findComment-764648 Share on other sites More sharing options...
lonelobo Posted February 17, 2009 Author Share Posted February 17, 2009 That's a good question ... I'll have to check with their tech support. Any other thoughts? Quote Link to comment https://forums.phpfreaks.com/topic/145647-problem-with-a-form-submission/#findComment-764661 Share on other sites More sharing options...
lonelobo Posted February 17, 2009 Author Share Posted February 17, 2009 Checked, mail() is enabled. Quote Link to comment https://forums.phpfreaks.com/topic/145647-problem-with-a-form-submission/#findComment-764674 Share on other sites More sharing options...
allworknoplay Posted February 17, 2009 Share Posted February 17, 2009 I don't see the FORM tag anywhere? Quote Link to comment https://forums.phpfreaks.com/topic/145647-problem-with-a-form-submission/#findComment-764676 Share on other sites More sharing options...
lonelobo Posted February 17, 2009 Author Share Posted February 17, 2009 Sorry, that would be in the HTML document that leads to this one. Here is the *** begin snippett *** <form name="form1" method="post" action="model.php" enctype="multipart/form-data" onSubmit="return validate(this);"> <tr> <td valign="top" background="images/J0028WEB2.jpg" bgcolor="#000000" style="background-position:top left; background-repeat:no-repeat"><table align="center" border="0" cellpadding="2" cellspacing="1" width="100%"> <form name="form1" method="post" action="model.php" enctype="multipart/form-data" onSubmit="return validate(this);"> *** end snippett *** I didn't know if you needed/wanted the whole form's code or not. That is where the form is created (above) and the previous PHP I posted is the "model.php" file which is supposed to handle the submission. Let me know what else you need, and thank you again for your help with this PHP newbie! :-) Quote Link to comment https://forums.phpfreaks.com/topic/145647-problem-with-a-form-submission/#findComment-764680 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.