Jump to content

dc_jt

Members
  • Posts

    290
  • Joined

  • Last visited

    Never

Everything posted by dc_jt

  1. dc_jt

    !$_POST

    Sorry, wrong forum. Can someone please move this to PHP Coding??
  2. dc_jt

    !$_POST

    In plain english, if someone enters 0 I dont want if(!$_POST) to pick it up.
  3. dc_jt

    !$_POST

    Hi I have a drop down box which lists months from 0 - 11 and also includes a "Please select..." option which value is set to "". However, when I submit the form with 0, it is not recognised as a value, therefore when I do if($_POST) this is not returned. Is there a way for $_POST to recognise 0 as a value rather than nothing? Hope that makes sense! Thanks
  4. I solved it by adding the following code to the ajax request function: jQuery(".formError").remove(); jQuery("#formID").validationEngine();
  5. Hi I have got a page which contains a form. The form uses jquery inline validation from here: http://www.position-absolute.com/articles/jquery-form-validator-because-form-validation-is-a-mess/ Within my page, I have got a button which uses a jquery function to load a form in from an external page which replaces the current form. However, once this is loaded, the validation stops working! Any idea why? Please see my code below: Original page with form: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title></title> <meta name="description" content=""/> <meta name="Keywords" content=""/> <meta name="robots" content="index"/> <meta name="revisit-after" content="1 days"/> <meta name="author" content=""/> <meta name="copyright" content=""/> <link rel="stylesheet" href="css/validationEngine.jquery.css" type="text/css" media="screen" charset="utf-8" /> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js" type="text/javascript"></script> <script src="js/jquery.validationEngine-en.js" type="text/javascript"></script> <script src="js/jquery.validationEngine.js" type="text/javascript"></script> <script src="js/postcode-anywhere.js" type="text/javascript"></script> <script> jQuery.noConflict(); jQuery(document).ready(function() { jQuery("#formID").validationEngine() }); function example_ajax_request(divId, url) { jQuery('#'+divId).load(url, "", function(responseText, textStatus, XMLHttpRequest) { if(textStatus == 'error') { jQuery('#'+divId).html('<p>There was an error making the AJAX request</p>'); } } ); } </script> </head> <body> <div id="step2-form"> <form id="formID" name=formID" method="post" action="<?=$_SERVER['PHP_SELF'];?>"> <input type="hidden" id="stage_complete" name="stage_complete" value="2" /> echo "<input name=\"edit\" type=\"button\" value=\"edit\" onclick=\"example_ajax_request('step2-form', 'ajax/updateStep2Form.php?iAddressId=".$oAddress->addressId."&iCustomerId=".$_SESSION['application']->customerId."');\">"; <label for="address1"> <span>Address 1<em>*</em></span> <span> <input name="address1" type="text" class="validate[required,length[0,100]] text-input" id="address1" value="<?=$_POST['address1'] ? $_POST['address1'] : "";?>" /> </span> </label> </form> </div> This is the external page (updateStage2.php): <div id="step2-form"> <form id="formID" name=formID" method="post" action="<?=$_SERVER['PHP_SELF'];?>"> <input type="hidden" id="stage_complete" name="stage_complete" value="2" /> echo "<input name=\"edit\" type=\"button\" value=\"edit\" onclick=\"example_ajax_request('step2-form', 'ajax/updateStep2Form.php?iAddressId=".$oAddress->addressId."&iCustomerId=".$_GET['iCustomerId']."');\">"; <label for="address1"> <span>Address 1<em>*</em></span> <span> <input name="address1" type="text" class="validate[required,length[0,100]] text-input" id="address1" value="<?=$_POST['address1'] ? $_POST['address1'] : "";?>" /> </span> </label> </form> </div> There must be a conflict somewhere because the validation just doesnt work at all once I have loaded in the external page into the <div> called step2-form. Does anyone know why? I have been trying various things for hours! Could it be because of the validationEngine function being called? Any help will be greatly appreciated. Thanks
  6. Hi Does anyone know where I can download open source code to do something similar to the validation on this form? https://carfinance.netcars.co.uk/apply.htm Looking at the source, it looks as though it may be jquery, does anyone know where I can find it? Thanks!
  7. Hi Ive got a form which has a "Years" and a "Months" field where a user enters the number of years and months they have been at their residential address. However, the form must have at least 3 years record of their residential history, therefore they can add multiple addresses. What I need to work out is when they get to the 3 years. To do this, would I turn the years into months i.e 1 = 12, 2 = 24 etc and add this to the number of months? Then work out if this total is equal to or greater than 36 (3 years)? Is this the best way to do it or is there a better alternative? Also, how would I represent this in PHP? Thanks!
  8. Hi I am about to implement a long online application form consisting of 5/6 steps similar to https://www.britishcredittrust.co.uk/apply/ this and need to save the data after each step and can also go back as well as forward through the application. My question is for an opinion really, would I be best saving the data in a session and save them after every step in the database but continue to use the session or should I just save the $_POST data and then if they were to go back to a previous step, retrieve this data from the database and update it when they go forward again? Hope that makes sense. Thanks
  9. Hi I have got a loop with a count starting at 0 and I need to change a class within the loop everytime the count hits 0, 6, 12, 18, 24 etc going up in sixes. I then need one for everytime the count is 7, 13, 19, 25 etc again up in sixes but starting from 7. How would I do this? I was thinking something like: if($count%6==0) for the first one? Not sure about the second though starting at 7? Thanks
  10. Excellent!! Thank you very much.
  11. Nope still havent got it. This is my code: $add1 = "address1"; $add2 = "address2"; $add3 = "address3"; $add4 = "address4"; $add5 = "address5"; $address = array($add1, $add2, $add3, $add4, $add5); $array = array_diff($address, array("")); $add1 = isset($array[0]) ? $array[0] : ""; $add2 = isset($array[1]) ? $array[1] : ""; $add3 = isset($array[2]) ? $array[2] : ""; $add4 = isset($array[3]) ? $array[3] : ""; $add5 = isset($array[4]) ? $array[4] : ""; print_r($array); print("<br />");print("<br />"); print($add1); print("<br />"); print($add2); print("<br />"); print($add3); print("<br />"); print($add4); print("<br />"); print($add5); print("<br />"); Array ( [0] => address1 [3] => address3[4] => address4) address1 address3 address4
  12. Thanks for the quick reply. The thing is I cant just separate them with a line break. I am using placeholders on a pdf document so I need to set address 1 to a value, address 2 to a value etc so there is no gap. I.e Address 1 Address 4 Address 5 This is how it is coming out now because for example, address 2 and 3 are not set a value. It doesnt matter if address 5 doesnt have a value because it has moved upto address 5 becausse there will be nothing below that. Does that make sense? Thanks
  13. Ive got address 1-5 fields listed on separate lines (they have to be like this) but I need to make sure there are no gaps in the lines. Therefore, if there is no address 1, this shows address 2, if there is no address 2 this shows address 3 etc. I cant work out the logic, I tried this but it doesnt work if there is no address 2 AND no address 3. Any ideas? if($add1 == ""){ $add1 = $add2; $add2 = $add3; $add3 = $add4; $add4 = $add5; $add5 = ''; } if($add2 == ""){ $add2 = $add3; $add3 = $add4; $add4 = $add5; $add5 = ''; } if($add3 == ""){ $add3 = $add4; $add4 = $add5; $add5 = ''; } if($add4 == ""){ $add4 = $add5; $add5 = ''; }
  14. Hi I am looking to create a csv file based on the data entered in a contact form and then upload this csv file to an FTP server. I have created the CSV using the following code but unsure how to upload this to the FTP site (which is on another server) rather than my own site. Any idea? $sDate=date('Y')."-".date('m')."-".date('d')."-".time(); $filename = $sDate."_contact.csv"; //path to uploads folder on my site $filename_path = UPLOADS_PATH.'/csv_files/'.$filename; //open the file for APPENDING //add the "t" terminator for windows //if using a mac then set the ini directive $fh = fopen($filename_path, "at"); //Lock the file for the write operation flock($fh, LOCK_EX); $sType = "Contact Form Enquiry"; $sName = explode(" ", $_POST[name]); $sForename = $sName[0]; $sSurname = $sName[1]; $top = 'Type,Forename,Surname,Company,Telephone,Email,Comment,Date Added,Notes'; $top .="\n"; $top .='"'.$sType.'",'; $top .='"'.$sForename.'",'; $top .='"'.$sSurname.'",'; $top .='"'.$_POST[company].'",'; $top .='"'.$_POST[telephone].'",'; $top .='"'.$_POST[email].'",'; $top .='"'.$_POST[comment].'",'; $top .='"'.date('d')."/".date('m')."/".date('Y').'",'; $top .='" ",'; $top .="\n"; fwrite($fh, $top ."\n",strlen($top)); fclose($fh);
  15. Hi Can someone please help me with the following. I have a content area where I can add content and I want to embed a youtube video within the content. I am trying to do it so that if I type [youtube: http://www....com] then I can use preg_replace to get the embed code. Currently Im using the following function: return preg_replace('/\[youtube: ([^\]]+?)\]/', '<object width="560" height="340"><param name="movie" value="\\1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="\\1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="560" height="340"></embed></object>', $body); However this returns it in an incorrect format. I need to convert it from to =en&fs=1& Can anyone help? Thanks
  16. No problem. Just noticed that I forgot the function declaration. <?php function is_divisible_by($number, $divby) { $number = $number / $divby; if(is_int($number)) { return true; } else { return false; } } ?> Dont worry I added that myself Thanks again.
  17. Infact it looks as though mattal999 works fine, thanks!
  18. Thanks for the quick replies. ToonMariner's almost works but it accepts values such as 10.50 which it shouldnt. Is there a way around this? Thanks
  19. Hi I have a form where a user enters a value and I need to check if the value is an increment of 5 i.e 5,10,15,20,25 etc. I am thinking of dividing the value they enter by 5 and if it is a round number then it is correct if not then it is incorrect but does anyone know how to check this? Is there an is_round() function or anything similar? Thanks
  20. Hi I am using the code below to refresh a page using javascript and ajax so that a user is never kicked out however I have had one user say they were kicked out. Is there any reason why their session may have expired? Could it be anything to do with their browser such as they dont have javascript enabled maybe? function Ajax() { this.toString = function() { return "Ajax"; } this.makeRequest = function(_method, _url) { this.request = (window.XMLHttpRequest) ? new XMLHttpRequest() : new ActiveXObject("MSXML2.XMLHTTP"); this.request.open(_method, _url, true); this.request.send(_url); } this.checkReadyState = function(_id, _1, _2, _3) { switch (this.request.readyState) { case 1: if (_id != null) document.getElementById(_id).innerHTML = _1; break; case 2: if (_id != null) document.getElementById(_id).innerHTML = _2; break; case 3: if (_id != null) document.getElementById(_id).innerHTML = _3; break; case 4: return this.request.status; } } } var oAjax = new Ajax(); var limit = 0; function ajaxRefresh() { if (limit==1) { //make background request oAjax.makeRequest('GET', '/sessionrefresh.php'); limit = iMinutes * 60 + iSeconds; } else { limit--; } setTimeout("ajaxRefresh()",1000) } function beginAjaxRefresh() { limit = iMinutes * 60 + iSeconds; setTimeout("ajaxRefresh()",1000) } var iMinutes = 5; var iSeconds = 0; beginAjaxRefresh();
  21. Please see the array below. You will notice there is a date added. What I need to do is work out what the earliest and latest date is from this array, therefore in this example the earliest will be 2009-06-18 09:12:28 and the latest will be [date_added] => 2009-06-18 15:29:35 What is the best way to work this out? Is it by sorting the array by date_added (how do I do this?) or is there a way to simply work it out? Here is the array: Array ( [37] => Array ( [out_new] => Array ( [0] => Array ( [application_id] => 23 [case_id] => 30 [date_added] => 2009-06-18 14:23:37 [consumer_id] => 17 [introducer_id] => 37 [master_id] => 1 [introducerName] => introducer1 ) [1] => Array ( [application_id] => 26 [case_id] => 32 [date_added] => 2009-06-18 09:12:28 [consumer_id] => 17 [introducer_id] => 37 [master_id] => 1 [introducerName] => introducer1 ) ) ) [43] => Array ( [out_complete] => Array ( [0] => Array ( [application_id] => 28 [case_id] => 34 [date_added] => 2009-06-18 15:29:35 [consumer_id] => 13 [introducer_id] => 43 [master_id] => 38 [introducerName] => introducer6 ) ) ) ) Thanks.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.