emilysnothere Posted April 29, 2010 Share Posted April 29, 2010 I am having an issue with forms submitting on Chrome and Safari. I initially thought this was a $_POST issue, after doing some googling, however I can still use my logins (which use $_POST) and then realized some of my forms do work! An example of a form that does work is : <?php require_once 'includes/headcode.php'; $form = new makeForm($dbConArray); $form->messageArray['customername'] = '*'; $form->messageArray['address'] = '*'; $form->messageArray['suburb'] = '*'; $form->messageArray['city'] = '*'; $form->messageArray['state'] = '*'; $form->messageArray['phone'] = '*'; $form->messageArray['planone'] = 'Total $22 Each'; $form->messageArray['plantwo'] = 'Total $61 Each'; $formsent = 0; //Process the form if($_POST['submit']){ // a) store data $form->storeValues($_POST); // b) Check each one, $form->checkEmpty('customername'); $form->checkEmpty('address'); $form->checkEmpty('suburb'); $form->checkEmpty('city'); $form->checkEmpty('state'); $form->checkEmpty('phone'); $form->checkNotRequired('mobile'); $form->checkNotRequired('ccard'); $form->checkNotRequired('ctype'); $form->checkNotRequired('cexpiry'); $form->checkNotRequired('business'); $form->checkNotRequired('abnno'); $form->checkNotRequired('planone'); $form->checkNotRequired('plantwo'); $form->checkNotRequired('numberreq'); $form->checkNotRequired('porting'); $form->checkNotRequired('dob'); $form->checkNotRequired('currentcarrier'); $form->checkNotRequired('currentaccount'); $form->checkNotRequired('websiteint'); $form->checkNotRequired('itint'); $form->checkNotRequired('comments'); //filter the message or enquiry, stripping < and > from it to prevent injections. Not as important here as it only sends an email. $filterMessage = array('<', '>'); $messageCleaner = str_replace($filterMessage,"", $_REQUEST['comments']); // Check for errors if($form->totalErrors == 0){ //c) insert cleaned form details into database. $query= "INSERT INTO tbl_phone SET customername = '{$form->clean['customername']}', address = '{$form->clean['address']}', suburb = '{$form->clean['suburb']}', city = '{$form->clean['city']}', state = '{$form->clean['state']}', phone = '{$form->clean['phone']}', mobile = '{$form->clean['mobile']}', ccard = '{$form->clean['ccard']}', ctype = '{$form->clean['ctype']}', cexpiry= '{$form->clean['cexpiry']}', business= '{$form->clean['business']}', abnno= '{$form->clean['abnno']}', planone= '{$form->clean['planone']}', plantwo= '{$form->clean['plantwo']}', numberreq= '{$form->clean['numberreq']}', porting= '{$form->clean['porting']}', dob= '{$form->clean['dob']}', currentcarrier= '{$form->clean['currentcarrier']}', currentaccount= '{$form->clean['currentaccount']}', websiteint= '{$form->clean['websiteint']}', itint= '{$form->clean['itint']}', callcenter= '$callcenter', comments = '{$form->clean['comments']}'"; $form->query($query); //d) send form details to the designated person. //email form if there are no errors in it // message that will be inserted into the mail $message =''; $message .='A new phone plan service form has been completed <br />'; $message .='<p>Call Center Staff Member Details:<br /> '.$callcenter.'</p>'; $message .='<br />Customer Details'; $message .= '<table>'; $message .= '<tr><td>Customer Name: </td><td>'. $form->clean['customername']. "\r\n" ; $message .= '</td></tr><tr><td>Address: </td><td>'. $form->clean['address']. "\r\n" ; $message .= '</td></tr><tr><td>Suburb: </td><td>'.$form->clean['suburb']. "\r\n" ; $message .= '</td></tr><tr><td>Town/ City: </td><td>'.$form->clean['city']. "\r\n" ; $message .= '</td></tr><tr><td>State: </td><td>'.$form->clean['state']. "\r\n" ; $message .= '</td></tr><tr><td>Contact Phone Number: </td><td>'.$form->clean['phone']. "\r\n" ; $message .= '</td></tr><tr><td>Mobile number: </td><td>'.$form->clean['mobile']. "\r\n" ; $message .='</td></tr></table>'; $message .='<br />Card Details'; $message .= '<table>'; $message .= '<tr><td>Credit Card Number: </td><td>'.$form->clean['ccard']. "\r\n" ; $message .= '</td></tr><tr><td>Card type: </td><td>'.$form->clean['ctype']. "\r\n" ; $message .= '</td></tr><tr><td>Expiry Date: </td><td>'.$form->clean['cexpiry']. "\r\n" ; $message .='</td></tr></table>'; $message .='<br />Business Details'; $message .= '<table>'; $message .= '<tr><td>Business Name: </td><td>'.$form->clean['business']. "\r\n" ; $message .= '</td></tr><tr><td>ABN Number: </td><td>'.$form->clean['abnno']. "\r\n" ; $message .='</td></tr></table>'; $message .='<br />Plan Details'; $message .= '<table>'; $message .= '<tr><td>Handsets for Mobile $22Simply Business Mobile Plan: </td><td>'.$form->clean['planone']. "\r\n" ; $message .= '</td></tr><tr><td>Handsets for Blackberry $22 Simply Business Mobile plan - Plus $39 Unlimited Data: </td><td>'.$form->clean['plantwo']. "\r\n" ; $message .= '</td></tr><tr><td>New number required? </td><td>'.$form->clean['numberreq']. "\r\n" ; $message .= '</td></tr><tr><td>Porting Number: </td><td>'.$form->clean['porting']. "\r\n" ; $message .= '</td></tr><tr><td>Current Carrier: </td><td>'.$form->clean['currentcarrier']. "\r\n" ; $message .= '</td></tr><tr><td>Current Account Number with Carrier: </td><td>'.$form->clean['currentaccount']. "\r\n" ; $message .= '</td></tr><tr><td>Message: </td><td>'.stripslashes(nl2br($messageCleaner)). "\r\n" ; $message .='</td></tr></table>'; $message .='<br />Extras'; $message .= '<table>'; $message .= '<tr><td>Website Interest: </td><td>'.$form->clean['websiteint']. "\r\n" ; $message .= '</td></tr><tr><td>IT Interest: </td><td>'.$form->clean['itint']. "\r\n" ; $message .='</td></tr></table>'; $mail = new PHPMailer(); $body = $mail->getFile('phone.php'); $body = eregi_replace("[\]",'',$message); $subject = eregi_replace("[\]",'',$subject); $mail->From = $form->clean['email']; $mail->FromName = "FROMNAME"; $mail->Subject = "Call Center - Phone Service"; $mail->MsgHTML($message); //email address the message is being sent to. $mail->AddAddress("[email protected]", "FROMNAME"); if($mail->Send()) { // We'll be outputting a PDF $formsent = 1; $sentMessage= '<p>The form has been sent successfully.</p>'; } }else{ $formError = '<div class="error">Please fill in the required fields</div>'; } //e) return call center user to the admin index page. //header('Location: viewnewsletters.php'); ob_flush(); } // end if $_POST['submit'] $selectArray = array ('Visa' => 'Visa', 'Master Card'=>'Master Card', 'American Express'=>'American Express'); $form->openForm('addphone', '', 'post', 'multipart/form-data'); $form->makeHiddenField('phoneID',$phoneID); $form->createHeading('Customer Details'); $form->makeInputRow('customername', 'checkEmpty','Name','','text'); $form->makeInputRow('address', 'checkEmpty','Address','','text'); $form->makeInputRow('suburb', 'checkEmpty','Suburb','','text'); $form->makeInputRow('city', 'checkEmpty','City','','text'); $form->makeInputRow('state', 'checkEmpty','State','','text'); $form->makeInputRow('phone', 'checkEmpty','Contact Number','','text'); $form->makeInputRow('mobile', '','Mobile Number','','text'); $form->createHeading('Credit Card Details'); $form->makeInputRow('ccard', 'checkEmpty','Card Number','','text'); $form->makeSelectRow('ctype', 'checkEmpty','Card Type',$selectArray); $form->makeInputRow('cexpiry', 'checkEmpty','Card Expiry','mm/yyyy','text'); $form->createHeading('formtext', 'Business details'); $form->makeInputRow('business', 'checkEmpty','Business Name','','text'); $form->makeInputRow('abnno', 'checkEmpty','ABN Number','','text'); $form->createHeading('Plan Details'); $form->makeText('indentformtext', 'Number of Handsets'); $form->makeInputRow('planone', '','Mobile $22 Simply Business Mobile plan','','text'); $form->makeInputRow('plantwo', '','Blackberry $22 Simply Business Mobile plan - Plus $39 Unlimited Data Pack','','text'); $form->createHeading('Other Information'); $form->makeInputRow('numberreq', 'checkEmpty','New Number Required? ','','text'); $form->makeInputRow('porting', 'checkEmpty','Porting Number','','text'); $form->makeInputRow('dob', 'checkEmpty','Date of Birth','','text'); $form->makeInputRow('currentcarrier', 'checkEmpty','Current Carrier','','text'); $form->makeInputRow('currentaccount', 'checkEmpty','Current Account Number with Carrier','','text'); $form->makeTextareaRow('comments', '', 'Extra Comments', '', '25', '5'); $form->createHeading('Extras'); $form->makeInputRow('websiteint', '','Website Interest','','text'); $form->makeInputRow('itint', '','IT Interest','','text'); $form->submitButton('Submit'); $form->closeForm(); ###### Content inserted into template ###### $heading = 'Add Customer Phone Plan'; $body = ''; if($formsent != 1){ $body .= $form->wholeForm; }else{ $body .= $formConfirmation; } ###### Include Template ##### include 'template.php'; ob_flush(); // because we started it at the top of the script ?> and one that doesnt work <?php require_once 'includes/headcode.php'; $sentMessage ='Please Fill out the form'; //create the form $form = new makeForm($dbConArray); $formsent=0; // default messages for registrant details $form->messageArray['domainName'] = '*'; $form->messageArray['abn'] = '*'; $form->messageArray['term'] = '* 2 year min for Australian domains'; $form->messageArray['registrantName'] = '* The person or company that <br />this domain will be registered to'; $form->messageArray['address1'] = '*'; $form->messageArray['city'] = '*'; $form->messageArray['country'] = '*'; $form->messageArray['phone'] = '*'; $form->messageArray['email'] = '*'; // default messages for administrative details $form->messageArray['adminContactName'] = '* The person or company that <br />will administer this domain'; $form->messageArray['adminAddress1'] = '*'; $form->messageArray['adminCity'] = '*'; $form->messageArray['adminCountry'] = '*'; $form->messageArray['adminPhone'] = '*'; $form->messageArray['adminEmail'] = '*'; if($_POST['submit']){ // the test to see if the form has been submitted then process data. // filter all the data $form->filterEverything($_POST); //Check all the fields for registrant using php to make sure they're filled in correctly $form->checkEmpty('domainName'); $form->checkNotRequired('abn'); $form->checkNotRequired('term'); $form->checkNotRequired('hostingPackage'); $form->checkNotRequired('designPackage'); $form->checkEmpty('registrantName'); $form->checkEmpty('address1'); $form->checkNotRequired('address2'); $form->checkEmpty('city'); $form->checkNotRequired('postcode'); $form->checkNotRequired('state'); $form->checkNotRequired('country'); $form->checkEmpty('phone'); $form->checkNotRequired('fax'); $form->rqCheckEmail('email'); //Check all the fields for the administrative contact using php to make sure they're filled in correctly $form->checkEmpty('adminContactName'); $form->checkEmpty('adminAddress1'); $form->checkNotRequired('adminAddress2'); $form->checkEmpty('adminCity'); $form->checkNotRequired('adminPostcode'); $form->checkNotRequired('adminState'); $form->checkNotRequired('adminCountry'); $form->checkEmpty('adminPhone'); $form->checkNotRequired('adminFax'); $form->rqCheckEmail('adminEmail'); // Check for errors if($form->totalErrors == 0){ //email form using php mailer if there are no errors in it // message - registrant details $message = '<b>Domain Name:</b> '. $form->clean['domainName']. "\r\n" ; $message .= '<p><b>DOMAIN REGISTRATION </b>'; $message .= '<br /><b>ABN or ACN Number: </b>'. $form->clean['abn']. "\r\n" ; $message .= '<br /><b>Term: </b>'. $form->clean['term']. "\r\n" ; $message .= '</p><p><b>HOSTING</b>'; $message .= '<br /><b>Hosting Package: </b>'. $form->clean['hostingPackage']. "\r\n" ; $message .= '</p><p><b>DESIGN</b>'; $message .= '<br /><b>Design Package: </b>'. $form->clean['designPackage']. "\r\n" ; $message .= '</p><p><b>REGISTRANT DETAILS </b>'; $message .= '<br /><b>Registrant Name:</b> '. $form->clean['registrantName']. "\r\n" ; $message .= '<br /><b>Address 1:</b> '. $form->clean['address1']. "\r\n" ; $message .= '<br /><b>Address 2: </b>'. $form->clean['address2']. "\r\n" ; $message .= '<br /><b>City: </b>'. $form->clean['city']. "\r\n" ; $message .= '<br /><b>Post Code: </b>'. $form->clean['postcode']. "\r\n" ; $message .= '<br /><b>State: </b>'. $form->clean['state']. "\r\n" ; $message .= '<br /><b>Country:</b> '. $form->clean['country']. "\r\n" ; $message .= '<br /><b>Phone: </b>'. $form->clean['phone']. "\r\n" ; $message .= '<br /><b>Fax: </b>'. $form->clean['fax']. "\r\n" ; $message .= '<br /><b>Email:</b> '. $form->clean['email']. "\r\n" ; // message - administrative details $message .= '</p><p><b>ADMINISTRATIVE DETAILS </b>'; $message .= '<br /><b>Administrative Contact Details: </b>'. $form->clean['adminContactName']. "\r\n" ; $message .= '<br /><b>Address 1: </b>'. $form->clean['adminAddress1']. "\r\n" ; $message .= '<br /><b>Address 2: </b>'. $form->clean['adminAddress2']. "\r\n" ; $message .= '<br /><b>City: </b>'. $form->clean['adminCity']. "\r\n" ; $message .= '<br /><b>Post Code: </b>'. $form->clean['adminPostcode']. "\r\n" ; $message .= '<br /><b>State: </b>'. $form->clean['adminState']. "\r\n" ; $message .= '<br /><b>Country:</b> '. $form->clean['adminCountry']. "\r\n" ; $message .= '<br /><b>Phone:</b> '. $form->clean['adminPhone']. "\r\n" ; $message .= '<br /><b>Fax:</b> '. $form->clean['adminFax']. "\r\n" ; $message .= '<br /><b>Email:</b> '. $form->clean['adminEmail']. "\r\n" ; $message .= '</p>' ; $mail = new PHPMailer(); $body = $mail->getFile('website.php'); $body = eregi_replace("[\]",'',$message); $subject = eregi_replace("[\]",'',$subject); $mail->From = $form->clean['email']; $mail->FromName = "FROMNAME"; $mail->Subject = "Call Center Website Lead"; $mail->MsgHTML($message); //email address it is being sent to $mail->AddAddress("[email protected]", "FROMNAME"); if($mail->Send()) { $formsent = 1; $sentMessage = '<p>The form has been sent successfully.</p>'; } else { $sentMessage = '<div class="contact_text">Sorry, the request could not be processed.</div>'; } }else{ $sentMessage='<p class="error">Please fill in the required fields</p><br />'; } // end $form->totalErrors } // end if $_POST['submit'] $selectArray = array ('6 Months'=>'6 Months', '1 Year'=>'1 Year', '2 Years'=>'2 Years', '5 Years'=>'5 Years', '10 Years'=>'10 Years'); $selectArray3 = array ('Victoria'=>'Victoria', 'New South Wales'=>'New South Wales', 'Queensland'=>'Queensland', 'Tasmania'=>'Tasmania', 'South Australia'=>'South Australia', 'Northern Territory'=>'Northern Territory', 'Western Australia'=>'Western Australia'); $selectArray2 = array ('Australia'=>'Australia'); #### WRITE THE FORM #### $form->openForm('domainForm', '', 'post', 'text'); //registrant $form->createHeading('Website Services'); $form->makeInputRow('domainName', 'checkEmpty','Domain Name', 'text'); $form->createHeading('Domain Registration'); $form->makeInputRow('abn', 'checkEmpty','ABN or ACN Number', 'text'); $form->makeSelectRow('term', 'checkEmpty','Term' ,$selectArray ); $form->createHeading('Hosting'); $form->makeCheckBoxRow('hostingPackage','Webhosting Package'); $form->createHeading('Web Design'); $form->makeCheckBoxRow_design('designPackage','Design Package'); $form->createHeading('Registrant Details'); $form->makeInputRow('registrantName', 'checkEmpty','Registrant Name', 'text'); $form->makeInputRow('address1', 'checkEmpty','Address 1', 'text'); $form->makeInputRow('address2', '','Address 2', 'text'); $form->makeInputRow('city', 'checkEmpty','City', 'text'); $form->makeInputRow('postcode', '','Post Code', 'text'); $form->makeSelectRow('state', 'checkEmpty','State', $selectArray3); $form->makeSelectRow('country', 'checkEmpty','Country', $selectArray2); $form->makeInputRow('phone', 'checkNumber','Phone', 'text'); $form->makeInputRow('fax', '','Fax', 'text'); $form->makeInputRow('email', 'checkEmail','Email', 'text'); //checkbox that will copy the registrant information to the administrative information if checked. $form->makeCopyCheckbox(); //administrative $form->createHeading('Administrative Contact Details'); $form->makeInputRow('adminContactName', 'checkEmpty','Administrative Contact Name', 'text'); $form->makeInputRow('adminAddress1', 'checkEmpty','Address 1', 'text'); $form->makeInputRow('adminAddress2', '','Address 2', 'text'); $form->makeInputRow('adminCity', 'checkEmpty','City', 'text'); $form->makeInputRow('adminPostcode', '','Post Code', 'text'); $form->makeSelectRow('adminState', 'checkEmpty','State', $selectArray3); $form->makeSelectRow('adminCountry', 'checkEmpty','Country', $selectArray2); $form->makeInputRow('adminPhone', 'checkNumber','Phone', 'text'); $form->makeInputRow('adminFax', '','Fax', 'text'); $form->makeInputRow('adminEmail', 'checkEmail','Email', 'text'); $form->submitButton('Submit'); $form->closeForm(); ###### Content inserted into template ###### $heading = 'Add Web Services'; $body = ''; if($formsent !=1){ $body .= $form->wholeForm; }else{ $body .= $formConfirmation; } ###### Include Template ##### include 'template.php'; ob_flush(); // because we started it at the top of the script ?> Both these scripts use the same form/database/headcode/config scripts. Also, I know the fields are slightly different, however I'm having this issue with contact forms that just contain basic fields used in both forms. Does anyone know where I went wrong? Link to comment https://forums.phpfreaks.com/topic/200114-submitting-form-issue-with-chrome-and-safari-only-one-some-forms/ Share on other sites More sharing options...
mrMarcus Posted April 29, 2010 Share Posted April 29, 2010 ugh. what is the "issue"? Link to comment https://forums.phpfreaks.com/topic/200114-submitting-form-issue-with-chrome-and-safari-only-one-some-forms/#findComment-1050315 Share on other sites More sharing options...
emilysnothere Posted April 29, 2010 Author Share Posted April 29, 2010 Sorry, I got sidetracked writing that... The issue is that some forms, once the submit button is selected, just refresh the page without storing data or returning errors if there are any (or sending the form). (essentially the submit function is not being picked up but instead the page is just refreshed) However, this doesnt happen with login forms or with, as shown in the above example, all my forms which are written with the same form class. Link to comment https://forums.phpfreaks.com/topic/200114-submitting-form-issue-with-chrome-and-safari-only-one-some-forms/#findComment-1050318 Share on other sites More sharing options...
darkfreaks Posted April 29, 2010 Share Posted April 29, 2010 if(isset($_POST['submit'])){ // makes sure the button has been pressed } Link to comment https://forums.phpfreaks.com/topic/200114-submitting-form-issue-with-chrome-and-safari-only-one-some-forms/#findComment-1050326 Share on other sites More sharing options...
emilysnothere Posted April 29, 2010 Author Share Posted April 29, 2010 I have fixed the issue For future reference (if anyone else is silly enough to make this mistake ) the issue was as follows: the form that was not working opened with: $form->openForm('domainForm', '', 'post', 'text'); The form that worked opened with: $form->openForm('domainForm', '', 'post', ''); or $form->openForm('addphone', '', 'post', 'multipart/form-data'); The form enctype was being set to 'text' and chrome had an issue with this Thanks, Emily Link to comment https://forums.phpfreaks.com/topic/200114-submitting-form-issue-with-chrome-and-safari-only-one-some-forms/#findComment-1050782 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.