Skip to:
Content
Pages
Categories
Search
Top
Bottom

Re: How to add php to a wpmu page???

I followed the Codex and created the template, it looks correct, but when I click “submit” to execute the script…I just get the index page. Any ideas on that? Here is my page code.

<?php

/*

Template Name: Browse ExBriefs

*/

?>

<?php get_header(); ?>

<div id=”content” class=”narrowcolumn”>

<h2>Search</h2>

<form name=”search” method=”post” action=”<?=$PHP_SELF?>”>

Seach for: <input type=”text” name=”find” /> in

<Select NAME=”field”>

<Option VALUE=”first”>First Name</option>

<Option VALUE=”last”>Last Name</option>

<Option VALUE=”city”>City</option>

<Option VALUE=”state”>State</option>

<Option VALUE=”country”>Country</option>

<Option VALUE=”gender”>Gender</option>

</Select>

<input type=”hidden” name=”searching” value=”yes” />

<input type=”submit” name=”search” value=”Search” />

</form>

<?PHP

//This is only displayed if they have submitted the form

if ($_POST[searching] ==”yes”)

{

echo “<h2>Results</h2><p>”;

//If they did not enter a search term we give them an error

if ($_POST[find] == “”)

{

echo “<p>You forgot to enter a search term”;

exit;

}

// Otherwise we connect to our Database

include(“http://www.ex-brief.com/profiles/dbinfo.inc.php&#8221;);

mysql_connect(localhost,$username,$password);

@mysql_select_db($database) or die( “Unable to select database”);

// We preform a bit of filtering

$find = strtoupper($_POST[find]);

$find = strip_tags($find);

$find = trim ($find);

//Now we search for our search term, in the field the user specified

$data=mysql_query(“select * from contacts where “.$_POST[field].” like ‘%”.addslashes($find).”%'”);

//And we display the results

while($result = mysql_fetch_array( $data ))

{

echo $result;

echo ” “;

echo $result;

echo “
“;

echo $result;

echo “
“;

echo $result;

echo “
“;

echo $result;

echo “
“;

echo $result;

echo “
“;

echo “
“;

}

//This counts the number or results – and if there wasn’t any it gives them a little message explaining that

$anymatches=mysql_num_rows($data);

if ($anymatches == 0)

{

echo “Sorry, there is no Ex-Brief for <b>”$find”</b> yet

Please try again.

“;

}

}

?>

</div>

<?php get_sidebar(); ?>

<?php get_footer(); ?>

Skip to toolbar