Jump to content

Extra character for form submission


Xtremer360

Recommended Posts

I shouldn't even be posting this but I"m tired and want to get this last part done by the end of the night. This script works however with the echoed "sortorder" its getting in the way of what's echoed for the submitmenuitem because its showing up as say 1good after form submission and not sure how to get it to not show up like that after form submission because that sortorder is getting echoed on document is ready.

 


<?php

// Include the database page
require ('../inc/dbconfig.php');

if ( isset( $_POST['menuid'] ) ) {
    $menuid = (int)$_POST['menuid'];
    $query = "SELECT COUNT(sortorder) AS numOrder FROM `menuitems` WHERE `menu_id` = '".$menuid."'"; 
    $result = mysqli_query ($dbc, $query);  
    $row = mysqli_fetch_array( $result, MYSQL_ASSOC );
    $sortorder = $row[ 'numOrder' ] + 1; 
    echo $sortorder;
}

if (isset($_POST['submitmenuitem'])) {
    $menuid = mysqli_real_escape_string($dbc, $_POST['menuid']);
    $itemname = mysqli_real_escape_string($dbc, $_POST['itemname']);
    $itemurl = mysqli_real_escape_string($dbc, $_POST['itemurl']);
    $sortorder = mysqli_real_escape_string($dbc, $_POST['sortorder']);
    $contentpage = mysqli_real_escape_string($dbc, $_POST['contentpage']);
    $newscategory = mysqli_real_escape_string($dbc, $_POST['newscategory']);
    $application = mysqli_real_escape_string($dbc, $_POST['application']);

    $query = "SELECT * FROM `menuitems` WHERE (`itemname` = '".$itemname."') OR (`itemurl` = '".$itemurl."') OR (`contentpage_id` = '".$contentpage."') OR (`application_id` = '".$application."') OR (`newscategory_id` = '".$newscategory."')";
    $result = mysqli_query ( $dbc, $query ); // Run The Query
    $rows = mysqli_num_rows($result);
    
    if ($rows == 0) {
    
        $query = "INSERT INTO `menuitems` 
                (menu_id, itemname, itemurl, sortorder, contentpage_id, newscategory_id, application_id, creator_id, datecreated, enabled) 
            VALUES 
                ('".$menuid."','".$itemname."','".$itemurl."','".$sortorder."','".$contentpage."', '".$newscategory."', '".$application."', 1, NOW(), 0)";
        
        mysqli_query($dbc, $query);

        echo "good";
    
    } else {
        
        $row = mysqli_fetch_array($result); 
        if (($row['itemname'] == $itemname) && ($row['itemurl'] == $itemurl) && ($row['contentpage_id'] == $contentpage) && ($row['application_id'] == $application) && ($row['newscategory_id'] == $newcategory)) echo 'bad6';  
        elseif ($row['newscategory_id'] == $newscategory) echo 'bad5';
        elseif ($row['application_id'] == $application) echo 'bad4';
        elseif ($row['contentpage_id'] == $contentpage) echo 'bad3';
        elseif ($row['itemurl'] == $itemurl) echo 'bad2'; 
        elseif ($row['itemname'] == $itemname) echo 'bad1';    
        
    }
    
}
        

Link to comment
https://forums.phpfreaks.com/topic/224582-extra-character-for-form-submission/
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.