Jump to content

Ch0cu3r

Staff Alumni
  • Posts

    3,404
  • Joined

  • Last visited

  • Days Won

    55

Everything posted by Ch0cu3r

  1. Locked Please do not post duplicate topics. You already have topic open in the PHP Help forum.
  2. You cannot call PHP functions from javascript. PHP and javascript are two completely different languages, they both run at different times. PHP runs on the server when the .php file is requested. Javascripts runs in browser when it receives the response from the request. The only way you can do this is via ajax, whereby you send a http request to your php script. In the PHP script you have PHP code which then will call the LCS PHP function. Example JavaScript code, using JQuery ajax method <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script> <script> function LSC() { // using jquery ajax method for calling the php script $.ajax({ // set this to the url of your php script for calling the LSC function url: 'lsc_script.php', // if the result of the ajax request is ok then this function is called success: function(response) { // the variable 'response' will contain the output from your php script // as an example we'll use a javascript alert to show the output of the response alert(response); } }); } </script> Example code for your PHP script <?php function lsc() { echo "Hello world has changed"; } // call lsc function lsc();
  3. Then remove the PHP short tags <?= ?>
  4. As explained in googles recaptcha documentation for verifying the recaptcha response you need to send a POST request to https://www.google.com/recaptcha/api/siteverify containing both your google recaptcha's secret key and the g-recaptcha-response value in order for google to verify the users recpatcha value is valid when your form has been submitted. To do this you would use curl, take a look at the post by printf's here for the code to do this. Note you will need to set the value of $key here $key = 'my key'; to your google recaptcha secrete key. And also replace echo 'Recaptha Result: '; var_dump ( $result['success'] ); With if($result['success']) { // YOUR CODE FOR SENDING THE EMAIL GOES HERE }
  5. What is CNT_TXT_WARNING_EMAILSENTOK and CNT_TXT_WARNING_EMAILSENTERROR are they constants or they literal strings for the msg query string value?
  6. The code you posted is not PHP. What you posted is HTML/Javascript. The PHP Help forum is for getting help with your PHP code not HTML/Javascript. We have specific forums sections for those languages.
  7. Use Jquery's delay method rather than setTimeout to remove the fade class
  8. I have merged your two topics as this is continuation from last time. The textbox value needs to be set in swal's callback function. So replace the following function() { swal({ html: 'You entered:' + $('#input-field').val() }); remarksField.val(#input-field').val()); With function() { remarksField.val( $('#input-field').val() ); }); Also closeOnConfirm: needs to be set to true
  9. Yes you can echo the value of $fileId for passing its as an argument to the javascript function. Your javascript function definition then becomes function removeReceipt(fileId) { $.ajax({ url: '<?php echo Thisurl();?>', data:{ReceiptId: fileId }, type: 'post', success:function() { window.location.reload(true); } }); }
  10. No, I believe we're using version 3. Why? Whats wrong with modded ipb4?
  11. Replace echo 'Recaptha Result: '; var_dump ( $result['success'] ); With your code for sending the emails.
  12. Probably because $(this) is only defined by jquery if it is handling the click event. Jquery only handles events you instruct it to do. Either have Jquery handle the onclick event (using its event handler) or pass this as the argument to the function being called in the onclick attribute onclick="DeleteItemByID(this)". Setting this as the argument passes the event instance of the element that was clicked to the function. Now in your function will be function DeleteItemByID(elm) { var deleteid = elm.id; // get the id attribute from the element instance from where this function was called from alert(deleteid); }
  13. Your way words just fine. The other way would be to use regex field = field.replace(/(\w+)\.(\d+)\.(\w+)/g, '$1[$2][$3]');
  14. Your question is not clear are you wanting convert the string 'products.0.name' to the string 'products[0][name]' or are wanting to convert it to array notation so you can return the name item from the array at index 0 of the variable named products?
  15. That will mean the code given by printf is successfully resolving the google recaptha.
  16. @tommytx the reason extract is not working is because by default $wpdb->get_results() returns the query results as an object. extract requires an (associative) array. You need to set the second argument (called output type) for $wpdb->get_results() to ARRAY_A. See documentation on various output types here: https://codex.wordpress.org/Class_Reference/wpdb#SELECT_Generic_Results I do agree with benanamen comment though.
  17. Change your regex to be #<img[^>]+>(\s*</a>)?#i The regex will optionally match a </a> if it comes after the <img /> tag Live PHP replacement demo (click the preg_replace tab).
  18. No you do not want to be using regex for this. You want to parse the HTML document using PHP DOM and with the use of xPath queries for finding the HTML element(s) from a page. You may find SimpleHTMLDOM easier to use as it uses css selector queries (similar to JQuery).
  19. With a manual install mysql does not come with configuration or data directory. Those you need to create or configure yourself. The following explains what steps you need to take for a manual install https://dev.mysql.com/doc/refman/5.7/en/windows-install-archive.html
  20. You should not be seeing the PHP code outputted at all. This suggests to me either the file containing the php code does not have a .php extension or your server is not configured correctly. Can you tell use how you are accessing/running the php code?
  21. Use a foreach loop to iterative over the names array, using the array key to get the corresponding value in the prices array // loop over the names array foreach($array['names'] as $key => $name) { // use the array key to reference the corresponding value in the prices array $price = $array['prices'][$key]; // do insert query } Change $array to be your variable that contain the names and prices array
  22. So you do not want people navigating to your private folder? The simplest solution is to move it so it is outside your document root.
  23. Should you not be comparing $left_operand with $right_operand here? $output =bccomp($right_operand ,$right_operand); As it is you are comparing $right_operand with $right_operand Also you have the variables in the wrong way round in the echo statements elseif ($output > 0){ echo $right_operand.' is biger then '.$left_operand; } else{ echo $left_operand.' is bigger then '.$right_operand ; } They should be the other way round. Quote from php.net That is saying if $left_operand is greater then $right_operand it will return 1, otherwise it will return -1 if $right_operand is greater then $left_operand.
  24. If you want the {gallery:xxxxx} string to replaced with the images in the gallery then you need to use preg_replace_callback preg_replace_callback( '~\{gallery\[0-9]{1,5})\}~' // call anonymous function for replacing {gallery:xxxxx} with gallery contents , function($matches) { // get the id from index 1 $id = intval($matches[1]); $query = 'SELECT * FROM gallery_images WHERE gid = '.$int; $gallery = ms_query($query); //ms_query is a function I wrote myself. Unlike mysqli_query function this function doesn't require the connection parameter every single time I call it, only the query itself // use concatenation for bulding the gallery contents $galleryImages = ''; while($gimage = mysqli_fetch_assoc($gallery)) { $galleryImages .= '<img src="admin/uploaded/'.$gimage['imagepath'].'" width ="100">'; } // return the gallery contents to be used as the replacement return $galleryImages; } // the subject , $page['content']);
×
×
  • 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.