Jump to content

Form Action Problems


Xtremer360

Recommended Posts

After I submit the form it doesn't place it in the database. Don't know why.

 

print '<h1 class="backstage">Match Type Management</h1><br />';
    print '<h2 class="backstage">Add New Match Type</h2><br />';
    print '<form name="matchtype" method="post">';
    print '<table width="100%" class="table2">';
    print '<tr>';
    print '<td width="120" class="rowheading" valign="center">Match Type:</td><td class="row3"><input type="text" name="matchtype" class="fieldtext490"></td>';
    print '</tr>';
    print '</table><br />';
    print '<input type="hidden" name="newadded"><input type="submit" value="Save Match Type" class="button" name="addmatchtype"></form><br />';
    print '<form method="POST"><input type="submit" value="Return to Match Type List" class="button200" name="return"></form><br />';

 

<?php 
    function matchtypes()
    {
        if(isset($_POST['addmatchtype']))
    {
        $matchtype = $_POST['matchtype'];
        $query = "INSERT INTO `efed_list_matchtypes` (`matchtype`) VALUES ('$matchtype')";

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

Link to comment
https://forums.phpfreaks.com/topic/184348-form-action-problems/
Share on other sites

u should include a file right at the top of the php file

u can use it under the

<?php 

tag

like this

<?php
include "inc.php";
print '<h1 class="backstage">Match Type Management</h1><br />';
    print '<h2 class="backstage">Add New Match Type</h2><br />';
    print '<form name="matchtype" method="post">';
    print '<table width="100%" class="table2">';
    print '<tr>';
    print '<td width="120" class="rowheading" valign="center">Match Type:</td><td class="row3"><input type="text" name="matchtype" class="fieldtext490"></td>';
    print '</tr>';
    print '</table><br />';
    print '<input type="hidden" name="newadded"><input type="submit" value="Save Match Type" class="button" name="addmatchtype"></form><br />';
    print '<form method="POST"><input type="submit" value="Return to Match Type List" class="button200" name="return"></form><br />';

    function matchtypes()
    {
        if(isset($_POST['addmatchtype']))
    {
        $matchtype = $_POST['matchtype'];
        $query = "INSERT INTO `efed_list_matchtypes` (`matchtype`) VALUES ('$matchtype')";

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

 

i dont know y it didnt showed u any error..

it should have obviusly given u one..

just try this code and see..

also one more thing change the file name from inc.php to something relevant

 

Link to comment
https://forums.phpfreaks.com/topic/184348-form-action-problems/#findComment-973243
Share on other sites

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.