Jump to content

The program does not work after a few runs


Recommended Posts

see this:


<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>



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.


Edited by shahriar
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...