Jump to content

shahriar

Members
  • Posts

    7
  • Joined

  • Last visited

Posts posted by shahriar

  1. I need Javascript code:

    Check all html code (inside and outside body): if see "shahriar"s word, block this line or class or link:

    <!DOCTYPE html>
    <html>
    <head>
    </head>
    <body>
    
    </body>
     <script src="https://test.com/include/shahriar_js.php?4" type="text/javascript"></script>
    </html>

     

  2. see this:

    html:

    <form method="post"><?php mysearch(); ?>
    <div class="hidden"><input type="checkbox" name="link[]" value="art" checked="checked"></div>
    <input type="checkbox" name="link[]" value="mix">Mix
    <input type="checkbox" name="link[]" value="bro">Bro
    <input type="checkbox" name="link[]" value="wood">Wood
    <input name="word" placeholder="Word Search..." value="">
    <input name="year" placeholder="Year" value="">
    <input name="month" placeholder="Month" value="">
    <input name="day" placeholder="Day" value="">
    <input id="mymenu" name="mytag" value="<?php $post_tags = get_the_tags(); if ( $post_tags ) { echo $post_tags[0]->name; } ?>">
    <button type="submit" class="Sbutton">search it</button></form>

     

    php:

    <?php
    function mysearch() {
        $mytag =  $_POST['mytag'];
    	$word =  $_POST['word'];
    	$year =  $_POST['year'];
        if(isset($year) && !empty($year)) { $year2 = "&year=" . $year; }	
    	$month =  $_POST['month'];
    	if(isset($month) && !empty($month)) { $month2 = "&month=" . $month; }
    	$day =  $_POST['day'];
    	if(isset($day) && !empty($day)) { $day2 = "&day=" . $day; }
    	
    	
        if(isset($_POST['link'])) {
        $name = $_POST['link'];  
        foreach ($name as $link){
        $mycat .= $link . "+";  
        $mycat2 =  $mycat;
        if ($mycat2 == 'art+') { $mycat2 = "/?tag="; }	
        else { $mycat2 = "/category/" . substr($mycat2, 4, -1) . "/?tag="; }
                                 }
    	$mylink = "http://test.com" . $mycat2 . $mytag . $year2 . $month2 . $day2 . "&s=" . $word;
    	header("Location: {$mylink}");
                                   }   
                          }
    ?>

    I have written this search box. is very simple.

    But I don't know why it only works a few times! And if you click on it one after the other, WordPress will give an error.

    Then you have to refresh the page for it to work again. And again, it crashes again after a few times and goes to the error page.

     

  3. 7 hours ago, Ingolme said:

    You should go through the effort of learning PHP rather than asking people to write code for you. Most of us have jobs and can't spend the time writing code if we're not getting paid for it, but just to illustrate my previous post, I'll write the code for this example.

    
    <?php
    if($_SERVER['REQUEST_METHOD'] == 'POST') {
      $data = [
        'tag'    => implode(',', $_POST['txt']),
        'year'   => $_POST['year'],
        'month'  => $_POST['month'],
        'day'    => $_POST['day'],
        's' => $_POST['s']
      ];
      $target = 'http://test.com/class/category-photography/?' . http_build_query($data);
      header("Location: {$target}");
      exit;
    }
    ?>
    <!DOCTYPE html>
    <html>
    <body>
      <form method="POST">
        <input type="checkbox" name="txt[]" value="photo">With tag1<br>
        <input type="checkbox" name="txt[]" value="pic">With tag2<br>
        <input type="checkbox" name="txt[]" value="cream">With tag3<br>
        <input name="year" value="">
        <input name="month" value="">
        <input name="day" value="">
        <br>
        <input name="s" value="">
        <br>
        <button type="submit">Search It!</button>
      </form>
    </body>
    </html>

     

    very thanks buddy. very thanks.

    I know you have job. I only asked for help if anyone was interested and could help.

    You have been very kind to me :)

  4. translate my code please; javascript to php. very very thanks.

     

    <!DOCTYPE html>
    <html>
    <body>
    <form>
    <input type="checkbox" name="myfilter" value=",photo">With tag1<br>
    <input type="checkbox" name="myfilter" value=",pic">With tag2<br>
    <input type="checkbox" name="myfilter" value=",cream">With tag3<br>
    <input id="year1" value="">
    <input id="month1" value="">
    <input id="day1" value="">
    <br>
    <input id="search1" value="">
    <br>
    </form>
    <button onclick="myFunction()">Search It!</button>
    <p id="demo"></p>
    
    
    <script>
    function myFunction() {
      var myfilter = document.forms[0];
      var txt = "";
      var i;
      for (i = 0; i < myfilter.length; i++) {
        if (myfilter[i].checked) {
          txt = txt + myfilter[i].value;
        }
          var year = "&year=" + document.getElementById("year1").value;
              var month = "&month=" + document.getElementById("month1").value;
                 var day = "&day=" + document.getElementById("day1").value;
                    var search = "&s=" + document.getElementById("search1").value;
      }
      var zzz = "http://test.com/class/category-photography/?tag=" + txt + year + month + day + search;
     window.location.assign(zzz)
    }
    </script>
    </body>
    </html>

     

  5. <div class="price">4.21</div>
    <div class="price">3.82</div>
    <script>
    var sum = 1;
    $('.price').each(function()
    {
        sum *= parseFloat($(this).text());
    });
     document.write(sum);
    </script>

    Can anyone convert this into Java? read "price class" as anywhere in the template and multiply elements inside them.

×
×
  • Create New...