Text Input Field in Backend [Hack Help]

macmemo 25 Mar, 2011
Hello,

i use chronocontacts and i love it😀

but i need some help🙂

i tried to modify the backend of chronoforms.( i didn't know, there is ChronoConnectivity to view all database information )
But it is ok, i have to learn PHP + MySQL😀

now i've got some problems. I added a text-input-field. i want to see the database information and update it. but updating does not work for me.

Here some code, maybe it is easier to explain🙂

admin.chronocontact.html.php:
        <td align="center">			
        	<input type="text" id="betrag<?php echo $i;?>" name="betrag[<?php echo $i;?>]" size="5" value="<?php
                    $abfrage = ("SELECT * FROM #__chrono_contact WHERE id='".$formid."'");
                    $ergebnis = mysql_query($abfrage);
                    echo "$row->betrag"; ?>" 
                <?php echo $disabled ?> class="text_area" style="text-align: center" />
                <a href="#betrag" onclick="return listItemTask('cb<?php echo $i;?>','betrag')">
                	<img border="0" alt="Betrag" src="images/filesave.png"/>
               	</a>	
		</td>


admin.chronocontact.php:
function betragChronoContact( $cid, $option ) {
    global $mainframe;
    $database =& JFactory::getDBO();
    $betrag = JRequest::getVar( 'betrag', array(), 'post', 'array' );
    
		if (!is_array( $betrag )) {
			$betrag = array(0);
		}

	$zahl = $cid[0];

	$error = JError::raiseWarning(100, $betrag[0]);
    if (count( $cid ) < 1) {
		$error;
        $mainframe->redirect( "index.php?option=com_chronocontact&task=show&formid=1" );
    }
    $cids = implode( ',', $cid );
    $database->setQuery( "UPDATE #__chronoforms_rhelper SET betrag='".$betrag[0]."' WHERE cf_id='".$zahl."'");

    if (!$database->query()) {
        JError::raiseWarning(100, $database->getErrorMsg());
        $mainframe->redirect( "index.php?option=com_chronocontact&task=show&formid=1" );
    }
     if (count( $cid ) == 1) {
        $row =& JTable::getInstance('chronocontact', 'Table'); 
        $row->checkin( $cid[0] );
    }
    $error;
    $mainframe->redirect( "index.php?option=com_chronocontact&task=show&formid=1" );
}


Updating the first input field works....but i can't update input field 2, 3 and so on...
i have to change "$betrag[0]" to $betrag[1] , $betrag[2]...but this is not dynamic enough....

can you help me?
sorry, for my english, i am from germany.

macmemo
GreyHead 25 Mar, 2011
Hi macmemo,

Sorry but I really suggest that you don't hack the admin code like this.

If you need to edit the records from the admin area then use the EasySQL extension or - prbably better - PHPMyAdmin.

Bob
macmemo 25 Mar, 2011
Thank you for your reply, Bob!

yeah, i know. it is not good to change the admin code, but in my opinion it is easy and confortable for me to see all information and updating with one click.

macmemo
This topic is locked and no more replies can be posted.