Support » Plugins and Hacks » PHP Form submit problems

  • So I tried making a new page from the pages-default.php. I’m using the carrington theme. The code looks like this:

    Template Name: Boyfriendnicknames
    // This file is part of the Carrington Blog Theme for WordPress
    // Copyright (c) 2008-2009 Crowd Favorite, Ltd. All rights reserved.
    // Released under the GPL license
    // **********************************************************************
    // This program is distributed in the hope that it will be useful, but
    // WITHOUT ANY WARRANTY; without even the implied warranty of
    // **********************************************************************
    if (__FILE__ == $_SERVER['SCRIPT_FILENAME']) { die(); }
    if (CFCT_DEBUG) { cfct_banner(__FILE__); }
    <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> &nbsp; &nbsp;
        <input type="submit" value="Submit">
    <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;
        /*== read in the two files into the arrays ==*/
        $adj_array = file("wu_adjs.txt");
        $noun_array = file("wu_nouns.txt");
        /*== set random 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">

    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:

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘PHP Form submit problems’ is closed to new replies.