-
Posts
3,404 -
Joined
-
Last visited
-
Days Won
55
Everything posted by Ch0cu3r
-
Locked Please do not post duplicate topics. You already have topic open in the PHP Help forum.
-
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();
-
Then remove the PHP short tags <?= ?>
-
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 }
-
What is CNT_TXT_WARNING_EMAILSENTOK and CNT_TXT_WARNING_EMAILSENTERROR are they constants or they literal strings for the msg query string value?
-
PHP Selection not showing on selction on dropbox
Ch0cu3r replied to DigiMartKe's topic in Javascript Help
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. -
Use Jquery's delay method rather than setTimeout to remove the fade class
-
How to pass pop up prompt value to its assigned textbox.
Ch0cu3r replied to samuel_lopez's topic in Javascript Help
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 -
What? Or free if you use google.
-
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); } }); }
-
is this forum on UNMODDED IPB4?
Ch0cu3r replied to ollie007's topic in PHPFreaks.com Website Feedback
No, I believe we're using version 3. Why? Whats wrong with modded ipb4? -
Replace echo 'Recaptha Result: '; var_dump ( $result['success'] ); With your code for sending the emails.
-
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); }
-
Your way words just fine. The other way would be to use regex field = field.replace(/(\w+)\.(\d+)\.(\w+)/g, '$1[$2][$3]');
-
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?
-
That will mean the code given by printf is successfully resolving the google recaptha.
-
Why manual array works with extract but auto download does not?
Ch0cu3r replied to tommytx's topic in PHP Coding Help
@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. -
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).
-
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
-
error need help,checkbox POST form cant work!
Ch0cu3r replied to wolvesbane's topic in PHP Coding Help
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? -
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
-
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.
-
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.
-
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']);