So I tried making a new page from the pages-default.php. I'm using the carrington theme. The code looks like this:
<?php
/*
Template Name: Boyfriendnicknames
*/
// This file is part of the Carrington Blog Theme for WordPress
// http://carringtontheme.com
//
// Copyright (c) 2008-2009 Crowd Favorite, Ltd. All rights reserved.
// http://crowdfavorite.com
//
// Released under the GPL license
// http://www.opensource.org/licenses/gpl-license.php
//
// **********************************************************************
// This program is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
// **********************************************************************
if (__FILE__ == $_SERVER['SCRIPT_FILENAME']) { die(); }
if (CFCT_DEBUG) { cfct_banner(__FILE__); }
get_header();
?>
<div id="content">
<h2>Generate Your Wu-Name</h2>
<p><hr size=1 noshade></p>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" METHOD="POST">
<p><b>Enter your Name: </b><br />
<input type="text" name="realname" size=25>
<input type="submit" value="Submit">
</p>
</form>
<p><hr size=1 noshade></p>
<?
if ($_SERVER['REQUEST_METHOD'] == "POST") {
$realname = $_POST['realname'];
$displayname = $realname;
$realname = strtolower($realname);
/*== generate seed number from name submitted ==*/
$len = strlen($realname);
$seed = 0; $s = 0;
for ($e=1; $e<=$len; $e++)
{
$chr = substr($realname,$s,$e);
$seed = $seed + ord($chr)*$e;
$s=$e;
}
/*== read in the two files into the arrays ==*/
$adj_array = file("wu_adjs.txt");
$noun_array = file("wu_nouns.txt");
/*== set random seed ==*/
srand($seed);
/*== get the random numbers for each name first/last or adj/noun ==*/
$arnd = rand(0,sizeof($adj_array)-1);
$nrnd = rand(0,sizeof($noun_array)-1);
/*== create name from random numbers ==*/
$wuname = "$adj_array[$arnd] $noun_array[$nrnd]";
print "<p><font size=4><b>$displayname</b> from this day forward you <br />you will also be known as ";
print "<font size='+1'><b> $wuname </b></font></font></p>";
}
?>
<div id="comments">
<?php
comments_template();
?>
</div><!--#comments-->
</div><!--#content-->
<?php
get_sidebar();
get_footer();
?>
But I am having the same problem. When I click submit, it returns me to the front page of my blog. I suspect that it has something to do with this line:
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" METHOD="POST">
But I'm unsure how to fix it. Any help would be grateful.
You can test it here:
http://www.artifacting.com/blog/get-cute-nicknames-for-your-boyfriend-or-girlfriend/