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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.