Jump to content

Form Returning Odd Response


Xtremer360

Recommended Posts

Every time I submit this form it says : You did not fill in a required field.

 

But I filled everything in. Grrr.

 

function addcharacters() {
if (isset ($_POST['submit'])) { // Handle the form.

// Define the query.
$query = "INSERT INTO characters (chactername, username, , posername, style, gender, status, division, alignment, sort) VALUES ('{$_POST['charactername']}', md5('username'), '{$_POST['posername']}', '{$_POST['style']}', '{$_POST['gender']}', '{$_POST['status']}', '{$_POST['division']}', '{$_POST['alignment']}', '{$_POST['sortorder']}')";

// Execute the query.
if (@mysql_query ($query)) {
	print '<p>The character has been added.</p>';
} else {
	print "<p>Could not add the character because: <b>" . mysql_error() . "</b>. The query was $query.</p>";
}

mysql_close();

} 
print'<h1 class="backstage">Character Management</h1><br />';
print'<h2 class="backstage">Add New Character</h2><br />';
print'<form name="newcharacter" action="backstage.php" method="post" >';
print'<table width="100%" class="table2">';
print'<tr>';
print'<td class="rowheading">Character Name:</td><td class="row3">';
print'<input type="text" name="charactername" class="fieldtext490"></td>';
print'</tr>';
print'<tr>';
print'<td width="120" class="rowheading">Username:</td><td class="row3"><input type="text" name="username" class="fieldtext160"></td>';
print'</tr>';
print'<tr>';
print'<td width="120" class="rowheading">Poser name:</td><td class="row3"><input type="text" name="posername" class="fieldtext160"></td>';
print'</tr>';
print'<tr>';
print'<td class="rowheading">Style:</td>';
print'<td class="row3"><select name="style" class="dropdown"><option value="0">- Select -</option><option value="3">Manager</option><option value="6">Referee</option><option value="1">Singles</option><option value="5">Stable</option><option value="4">Staff</option><option value="2">Tagteam</option></select></td>';
print'</tr>';
print'<tr>';
print'<td class="rowheading">Gender:</td>';
print'<td class="row3"><select name="gender" class="dropdown"><option value="0">- Select -</option><option value="1">Male</option><option value="2">Female</option></select></td>';
print'</tr>';
print'<tr>';
print'<td class="rowheading">Status:</td>';
print'<td class="row3"><select name="status" class="dropdown"><option value=0>- Select -</option><option value="1">Active</option><option value="2">Inactive</option></select></td>';
print'</tr>';
print'<tr>';
print'<td class="rowheading">Division:</td>';
print'<td class=row3><select name="division" class="dropdown"><option value="0">- Select -</option><option value="1">Wrestling</option></select></td>';
print'</tr>';
print'<tr>';
print'<td class="rowheading">Alignment:</td>';
print'<td class="row3"><select name="alignment" class="dropdown"><option value="0">- Select -</option><option value="1">Face</option><option value="3">Heel</option><option value="2">Neutral</option></select></td>';
print'</tr>';
print'<tr>';
print'<td class="rowheading">Sort:</td>';
print'<td class="row3"><select name="sortorder" class="dropdown"><option value="0">- Select -</option><option value="A">A</option><option value="B">B</option><option value="C">C</option><option value="D">D</option><option value="E">E</option><option value="F">F</option><option value="G">G</option><option value="H">H</option><option value="I">I</option><option value="J">J</option><option value="K">K</option><option value="L">L</option><option value="M">M</option><option value="N">N</option><option value="O">O</option><option value="P">P</option><option value="Q">Q</option><option value="R">R</option><option value="S">S</option><option value="T">T</option><option value="U">U</option><option value="V">V</option><option value="W">W</option><option value="X">X</option><option value="Y">Y</option><option value="Z">Z</option><option value="0-9">0-9</option></select></td>';
print'</tr>';
print'</table><br />';
print'<input type="submit" value="Save Character" class="button" name="submit"></form><br />';
print'<form method="POST"><input type="hidden" name="action" value="character"><input type="submit" value="Return to Character List" class="button200"></form><br />';
print'<h2 class=backstage><form method="POST"><input type="hidden" name="action" value="mainmenu"><input type="submit" value="Return to Main Menu" class="button200"></form></h2>';
}

Link to comment
https://forums.phpfreaks.com/topic/138695-form-returning-odd-response/
Share on other sites

Yeah I fixed that earlier but still get that message "You did not fill in a required field."

 

Updated Code:

 

function addcharacters() {
if (isset ($_POST['submit'])) { // Handle the form.

// Define the query.
$query = "INSERT INTO characters (charactername, username, posername, style, gender, status, division, alignment, sort) VALUES ('{$_POST['charactername']}', '{$_POST['username']}', '{$_POST['posername']}', '{$_POST['style']}', '{$_POST['gender']}', '{$_POST['status']}', '{$_POST['division']}', '{$_POST['alignment']}', '{$_POST['sortorder']}')";

// Execute the query.
if (@mysql_query ($query)) {
	print '<p>The character has been added.</p>';
} else {
	print "<p>Could not add the character because: <b>" . mysql_error() . "</b>. The query was $query.</p>";
}

mysql_close();

} 
print'<h1 class="backstage">Character Management</h1><br />';
print'<h2 class="backstage">Add New Character</h2><br />';
print'<form name="newcharacter" action="backstage.php" method="post" >';
print'<table width="100%" class="table2">';
print'<tr>';
print'<td class="rowheading">Character Name:</td><td class="row3">';
print'<input type="text" name="charactername" class="fieldtext490"></td>';
print'</tr>';
print'<tr>';
print'<td width="120" class="rowheading">Username:</td><td class="row3"><input type="text" name="username" class="fieldtext160"></td>';
print'</tr>';
print'<tr>';
print'<td width="120" class="rowheading">Poser name:</td><td class="row3"><input type="text" name="posername" class="fieldtext160"></td>';
print'</tr>';
print'<tr>';
print'<td class="rowheading">Style:</td>';
print'<td class="row3"><select name="style" class="dropdown"><option value="0">- Select -</option><option value="3">Manager</option><option value="6">Referee</option><option value="1">Singles</option><option value="5">Stable</option><option value="4">Staff</option><option value="2">Tagteam</option></select></td>';
print'</tr>';
print'<tr>';
print'<td class="rowheading">Gender:</td>';
print'<td class="row3"><select name="gender" class="dropdown"><option value="0">- Select -</option><option value="1">Male</option><option value="2">Female</option></select></td>';
print'</tr>';
print'<tr>';
print'<td class="rowheading">Status:</td>';
print'<td class="row3"><select name="status" class="dropdown"><option value=0>- Select -</option><option value="1">Active</option><option value="2">Inactive</option></select></td>';
print'</tr>';
print'<tr>';
print'<td class="rowheading">Division:</td>';
print'<td class=row3><select name="division" class="dropdown"><option value="0">- Select -</option><option value="1">Wrestling</option></select></td>';
print'</tr>';
print'<tr>';
print'<td class="rowheading">Alignment:</td>';
print'<td class="row3"><select name="alignment" class="dropdown"><option value="0">- Select -</option><option value="1">Face</option><option value="3">Heel</option><option value="2">Neutral</option></select></td>';
print'</tr>';
print'<tr>';
print'<td class="rowheading">Sort:</td>';
print'<td class="row3"><select name="sortorder" class="dropdown"><option value="0">- Select -</option><option value="A">A</option><option value="B">B</option><option value="C">C</option><option value="D">D</option><option value="E">E</option><option value="F">F</option><option value="G">G</option><option value="H">H</option><option value="I">I</option><option value="J">J</option><option value="K">K</option><option value="L">L</option><option value="M">M</option><option value="N">N</option><option value="O">O</option><option value="P">P</option><option value="Q">Q</option><option value="R">R</option><option value="S">S</option><option value="T">T</option><option value="U">U</option><option value="V">V</option><option value="W">W</option><option value="X">X</option><option value="Y">Y</option><option value="Z">Z</option><option value="0-9">0-9</option></select></td>';
print'</tr>';
print'</table><br />';
print'<input type="submit" value="Save Character" class="button" name="submit"></form><br />';
print'<input type="hidden" name="action" value="character"><input type="submit" value="Return to Character List" class="button200"><br />';
print'<h2 class=backstage><input type="hidden" name="action" value="mainmenu"><input type="submit" value="Return to Main Menu" class="button200"></h2>';
}

Try this, I don't know if it will do anything but it is worth a try...

 

	

$query = "INSERT INTO characters (chactername, username, posername, style, gender, status, division, alignment, sort) VALUES ('{$_POST['charactername']}', md5('username'), '{$_POST['posername']}', '{$_POST['style']}', '{$_POST['gender']}', '{$_POST['status']}', '{$_POST['division']}', '{$_POST['alignment']}', '{$_POST['sortorder']}')";
$result = mysql_query($query){
// Execute the query.
if ($result) {

Well here's the file that calls the function.

 

<?php 

include ('database.php');

//if the login form is submitted
if(isset($_POST['submit']))
{
    // makes sure they filled it in
    if(!$_POST['username'] || !$_POST['password'])
    {
        die('You did not fill in a required field.');
    }
   $username = mysql_real_escape_string($_POST['username']); 
   $pass = mysql_real_escape_string($_POST['password']); 

    $check = mysql_query("SELECT * FROM users WHERE username = '".$username."'")or die(mysql_error());

    //Gives error if user dosen't exist
    $check2 = mysql_num_rows($check);
    if ($check2 == 0)
    {
        die('That user does not exist in our database.');
    }
    while($info = mysql_fetch_array( $check )) 
    {
        $pass = md5(stripslashes($_POST['password']));
        $info['password'] = stripslashes($info['password']);
        //$_POST['pass'] = md5($_POST['pass']); THIS IS DONE IN THE ABOVE STATEMENT
        //gives error if the password is wrong
        if ($pass != $info['password'])
        {
            die('Incorrect password, please try again.');
        }
        else 
      
      // if login is ok then we add a cookie and send them to the correct page
        { 
            $username = stripslashes($username); 
         $_SESSION['username'] = $username; 
         $_SESSION['loggedin'] = time();
            
            // Finds out the user type
            $query = "SELECT `admin` FROM `users` WHERE `username` = '" . $username . "'";
            $result = mysql_query($query) or die(mysql_error()); 
            $row = mysql_fetch_array($result); 
            $admin = $row['admin'];
         $_SESSION['admin'] = $admin;

#########################################
######## ADMIN SCRIPT CAN BE ADDED BELOW
#########################################
if(isset($_SESSION['admin'])) { ?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Style-Type" content="text/css">
<meta http-equiv="Content-Language" content="en-us">
<meta name="language" content="en-us">
<title>Backstage V1 Administration Console</title>
<link rel="stylesheet" href="backstage.css" type="text/css" media="screen">
<link rel="stylesheet" href="backstage_print.css" type="text/css" media="print">
<script src="prototype.js" type="text/javascript"></script>
<script src="scriptaculous.js" type="text/javascript"></script>
<script type="text/javascript" src="ajax.js"></script>
<script type="text/javascript">
var page = document.cookie.match(/page=[\w][\w\-\.]+;/);
if(page != null) {
    ajaxpage("page", "content");
} else {
    ajaxpage("home", "content");
}
</script>
<link rel=stylesheet href=backstage.css type=css media=screen>
<link rel=stylesheet href=backstage_print.css type=css media=print>
</head>
<body>
<div id=container>
<div class=header>
<table cellpadding="0" cellspacing="0" border="0" width="95%">
<tr>
<td width=110 align=center></td>
<td></td>
<td width=40 valign=bottom align=right>
<a href="#" onclick="ajaxpage('home', 'content'); return false;">Home</a> | <a href="#" onclick="ajaxpage('logout', 'content'); return false;">Logout</a> | <a target="_blank" href="http://kansasoutlawwrestling.com/phpBB3">Forums</a></td>
</tr>
</table>
</div>
<div id=container2>
<div id=nav>
<?php if(isset($_SESSION['loggedin']))   { ?>
<h1>Character</h1>
<ul>
<li><a href="#" onclick="ajaxpage('bio', 'content'); return false;">Bio</a></li>
<li><a href="#" onclick="ajaxpage('allies', 'content'); return false;">Allies</a></li>
<li><a href="#" onclick="ajaxpage('rivals', 'content'); return false;">Rivals</a></li>
<li><a href="#" onclick="ajaxpage('quotes', 'content'); return false;">Quotes</a></li>
</ul>
<?php } ?>
<?php if(isset($_SESSION['loggedin']))   { ?>
<h1>Submit</h1>
<ul>
<li><a href="#" onclick="ajaxpage('roleplay', 'content'); return false;">Roleplay</a></li>
<li><a href="#" onclick="ajaxpage('news', 'content'); return false;">News</a></li>
<li><a href="#" onclick="ajaxpage('match', 'content'); return false;">Match</a></li>
<li><a href="#" onclick="ajaxpage('seg', 'content'); return false;">Seg</a></li>
</ul>
<?php } ?>
<?php if(isset($_SESSION['loggedin']) && $_SESSION['admin'] == 1) { ?>  
<h1>Handler</h1>
<ul>
<li><a href="#" onclick="ajaxpage('directory', 'content'); return false;">Directory</a></li>
</ul>
<?php } ?>
<?php if(isset($_SESSION['loggedin']) && $_SESSION['admin'] == 1) { ?>  
<h1>Booking</h1>
<ul>
<li><a href="#" onclick="ajaxpage('champions', 'content'); return false;">Champions</a></li>
<li><a href="#" onclick="ajaxpage('booker', 'content'); return false;">Booker</a></li>
<li><a href="#" onclick="ajaxpage('compiler', 'content'); return false;">Compiler</a></li>
<li><a href="#" onclick="ajaxpage('archives', 'content'); return false;">Archives</a></li>
</ul>
<?php } ?>
<?php if(isset($_SESSION['loggedin']) && $_SESSION['admin'] == 1) { ?>  
<h1>Fed Admin</h1>
<ul>
<li><a href="#" onclick="ajaxpage('handlers', 'content'); return false;">Handlers</a></li>
<li><a href="#" onclick="ajaxpage('characters', 'content'); return false;">Characters</a></li>
<li><a href="#" onclick="ajaxpage('applications', 'content'); return false;">Applications</a></li>
<li><a href="#" onclick="ajaxpage('eventnames', 'content'); return false;">Event Names</a></li>
<li><a href="#" onclick="ajaxpage('titlenames', 'content'); return false;">Title Names</a></li>
<li><a href="#" onclick="ajaxpage('matchtypes', 'content'); return false;">Match Types</a></li>
<li><a href="#" onclick="ajaxpage('divisions', 'content'); return false;">Divisions</a></li>
<li><a href="#" onclick="ajaxpage('countries', 'content'); return false;">Arenas</a></li>
</ul>
<?php } ?>
<?php if(isset($_SESSION['loggedin']) && $_SESSION['admin'] == 1) { ?>  
<h1>Site Admin</h1>
<ul>
<li><a href="#" onclick="ajaxpage('templates', 'content'); return false;">Templates</a></li>
<li><a href="#" onclick="ajaxpage('content', 'content'); return false;">Content</a></li>
<li><a href="#" onclick="ajaxpage('biosconfig', 'content'); return false;">Bio Configuration</a></li>
<li><a href="#" onclick="ajaxpage('newscat', 'content'); return false;">News Categories</a></li>
<li><a href="#" onclick="ajaxpage('menus', 'content'); return false;">Menus</a></li>
</ul>
<?php } ?>
</div>
<div id=content>
</div>
<div id="footer">Backstage 1 © 2009
</div>
</div>
</div>
</body>
</html>
<?php  
#########################################
######## ADMIN SCRIPT HAS TO END ABOVE
#########################################
    }
        } 
    } 
} 
else 
{
// if they have not submitted the form
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Style-Type" content="text/css">
<meta http-equiv="Content-Language" content="en-us">
<meta name="language" content="en-us">
<title>Backstage V1 Administration Console</title>
<link rel="stylesheet" href="backstage.css" type="text/css" media="screen">
<link rel="stylesheet" href="backstage_print.css" type="text/css" media="print">
<script src="prototype.js" type="text/javascript"></script>
<script src="scriptaculous.js" type="text/javascript"></script>
<script type="text/javascript" src="ajax.js"></script>
<link rel=stylesheet href=backstage.css type=css media=screen>
<link rel=stylesheet href=backstage_print.css type=css media=print>
</head>
<body>
<div id=login>
<form method="POST" action="/other/backstage.php">
<h1>KOW Backstage</h1>
<p><label>Username:<br><input type="text" name="username" id="log" tabindex="1"></label></p>
<p><label>Password:<br><input type="password" name="password" id="pwd" tabindex="2"></label></p>
<p style="text-align: center;"><input type="submit" class="button" name="submit" id="submit" value="Login »" tabindex="4"></p>
</form>
</div>
</body>
</html>
<?php
}
?>

I turned the function's form action to backstagefunctions.php and got his response after submission:

 

Error 404!

 

And then this code is at the top of my backstagefunctions page:

 

<?php

include ('database.php');

/* Gets the value of 'f' from the URL and secures the variable against XSS */
$f = htmlentities($_GET['f'], ENT_QUOTES);

if (function_exists($f)) {
$f();
} else {
die('Error 404!');
} 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.