lmchaelichkatel
11-03-2009, 03:33 AM
Hi
I want to submit a post forum with curl, I need to specifies fields to send with option CURLOPT_POSTFIELDS, this option where I specify data to send with the form to submit.
I give the form in too examples the first is the real one with php content, and the second is html part after I execute it on my server. What I want to know is fields to send to CURLOPT_POSTFIELDS, all necessary fields including <input> and whatever.
I have a question is that I want to select checkbox and I want to check it but how to do that and send the checking option to CURLOPT_POSTFIELDS ?
<input type="checkbox" name="toggle" value="" onclick="checkAll(<?php echo count( $rows ); ?>);" />
The fields I think I should send are the last 6 hidden fields
<input type="hidden" name="option" value="com_content" />
<input type="hidden" name="task" value="" />
<input type="hidden" name="boxchecked" value="0" />
<input type="hidden" name="redirect" value="<?php echo $redirect;?>" />
<input type="hidden" name="filter_order" value="<?php echo $lists['order']; ?>" />
<input type="hidden" name="filter_order_Dir" value="<?php echo $lists['order_Dir']; ?>" />
and a field where to mention that I selected checkall.
<form action="index.php?option=com_content" method="post" name="adminForm">
<table>
<tr>
<td width="100%">
<?php echo ( 'Filter' ); ?>:
<input type="text" name="search" id="search" value="<?php echo $lists['search'];?>" class="text_area" onchange="document.adminForm.submit();" title="<?php echo ( 'Filter by title or enter article ID' );?>"/>
<button onclick="this.form.submit();"><?php echo ( 'Go' ); ?></button>
<button onclick="document.getElementById('search').value='';this.form.getElementById('filter_sectionid').value='-1';this.form.getElementById('catid').value='0';this.form.getElementById('filter_authorid').value='0' ;this.form.getElementById('filter_state').value='';this.form.submit();"><?php echo ( 'Reset' ); ?></button>
</td>
<td nowrap="nowrap">
<?php
echo $lists['sectionid'];
echo $lists['catid'];
echo $lists['authorid'];
echo $lists['state'];
?>
</td>
</tr>
</table>
<table class="adminlist" cellspacing="1">
<thead>
<tr>
<th width="5">
<?php echo ( 'Num' ); ?>
</th>
<th width="5">
<input type="checkbox" name="toggle" value="" onclick="checkAll(<?php echo count( $rows ); ?>);" />
</th>
<th class="title">
<?php echo ('grid.sort', 'Title', 'c.title', @$lists['order_Dir'], @$lists['order'] ); ?>
</th>
<th width="1%" nowrap="nowrap">
<?php echo ('grid.sort', 'Published', 'c.state', @$lists['order_Dir'], @$lists['order'] ); ?>
</th>
<th nowrap="nowrap" width="1%">
<?php echo ('grid.sort', 'Front Page', 'frontpage', @$lists['order_Dir'], @$lists['order'] ); ?>
</th>
<th width="8%">
<?php echo ('grid.sort', 'Order', 'c.ordering', @$lists['order_Dir'], @$lists['order'] ); ?>
<?php if ($ordering) echo ('grid.order', $rows ); ?>
</th>
<th width="7%">
<?php echo ('grid.sort', 'Access', 'groupname', @$lists['order_Dir'], @$lists['order'] ); ?>
</th>
<th class="title" width="8%" nowrap="nowrap">
<?php echo ('grid.sort', 'Section', 'section_name', @$lists['order_Dir'], @$lists['order'] ); ?>
</th>
<th class="title" width="8%" nowrap="nowrap">
<?php echo ('grid.sort', 'Category', 'cc.title', @$lists['order_Dir'], @$lists['order'] ); ?>
</th>
<th class="title" width="8%" nowrap="nowrap">
<?php echo ('grid.sort', 'Author', 'author', @$lists['order_Dir'], @$lists['order'] ); ?>
</th>
<th align="center" width="10">
<?php echo ('grid.sort', 'Date', 'c.created', @$lists['order_Dir'], @$lists['order'] ); ?>
</th>
<th align="center" width="10">
<?php echo ('grid.sort', 'Hits', 'c.hits', @$lists['order_Dir'], @$lists['order'] ); ?>
</th>
<th width="1%" class="title">
<?php echo ('grid.sort', 'ID', 'c.id', @$lists['order_Dir'], @$lists['order'] ); ?>
</th>
</tr>
</thead>
<tfoot>
<tr>
<td colspan="15">
<?php echo $page->getListFooter(); ?>
</td>
</tr>
</tfoot>
<tbody>
<?php
$k = 0;
$nullDate = $db->getNullDate();
for ($i=0, $n=count( $rows ); $i < $n; $i++)
{
$row = &$rows[$i];
$link = 'index.php?option=com_content§ionid='. $redirect .'&task=edit&cid[]='. $row->id;
$row->sect_link = JRoute::_( 'index.php?option=com_sections&task=edit&cid[]='. $row->sectionid );
$row->cat_link = JRoute::_( 'index.php?option=com_categories&task=edit&cid[]='. $row->catid );
$publish_up =& JFactory::getDate($row->publish_up);
$publish_down =& JFactory::getDate($row->publish_down);
$publish_up->setOffset($config->getValue('config.offset'));
$publish_down->setOffset($config->getValue('config.offset'));
if ( $now->toUnix() <= $publish_up->toUnix() && $row->state == 1 ) {
$img = 'publish_y.png';
$alt = ( 'Published' );
} else if ( ( $now->toUnix() <= $publish_down->toUnix() || $row->publish_down == $nullDate ) && $row->state == 1 ) {
$img = 'publish_g.png';
$alt = ( 'Published' );
} else if ( $now->toUnix() > $publish_down->toUnix() && $row->state == 1 ) {
$img = 'publish_r.png';
$alt = ( 'Expired' );
} else if ( $row->state == 0 ) {
$img = 'publish_x.png';
$alt = ( 'Unpublished' );
} else if ( $row->state == -1 ) {
$img = 'disabled.png';
$alt = ( 'Archived' );
}
$times = '';
if (isset($row->publish_up)) {
if ($row->publish_up == $nullDate) {
$times .= ( 'Start: Always' );
} else {
$times .= ( 'Start' ) .": ". $publish_up->toFormat();
}
}
if (isset($row->publish_down)) {
if ($row->publish_down == $nullDate) {
$times .= "<br />". ( 'Finish: No Expiry' );
} else {
$times .= "<br />". ( 'Finish' ) .": ". $publish_down->toFormat();
}
}
if ( $user->authorize( 'com_users', 'manage' ) ) {
if ( $row->created_by_alias ) {
$author = $row->created_by_alias;
} else {
$linkA = 'index.php?option=com_users&task=edit&cid[]='. $row->created_by;
$author = '<a href="'. JRoute::_( $linkA ) .'" title="'. ( 'Edit User' ) .'">'. $row->author .'</a>';
}
} else {
if ( $row->created_by_alias ) {
$author = $row->created_by_alias;
} else {
$author = $row->author;
}
}
$access = ('grid.access', $row, $i, $row->state );
$checked = ('grid.checkedout', $row, $i );
?>
<tr class="<?php echo "row$k"; ?>">
<td>
<?php echo $page->getRowOffset( $i ); ?>
</td>
<td align="center">
<?php echo $checked; ?>
</td>
<td>
<?php
if ( JTable::isCheckedOut($user->get ('id'), $row->checked_out ) ) {
echo $row->title;
} else if ($row->state == -1) {
echo htmlspecialchars($row->title, ENT_QUOTES, 'UTF-8');
echo ' [ '. ( 'Archived' ) .' ]';
} else {
?>
<a href="<?php echo JRoute::_( $link ); ?>">
<?php echo htmlspecialchars($row->title, ENT_QUOTES); ?></a>
<?php
}
?>
</td>
<?php
if ( $times ) {
?>
<td align="center">
<span class="editlinktip hasTip" title="<?php echo ( 'Publish Information' );?>::<?php echo $times; ?>"><a href="javascript:void(0);" onclick="return listItemTask('cb<?php echo $i;?>','<?php echo $row->state ? 'unpublish' : 'publish' ?>')">
<img src="images/<?php echo $img;?>" width="16" height="16" border="0" alt="<?php echo $alt; ?>" /></a></span>
</td>
<?php
}
?>
<td align="center">
<a href="javascript:void(0);" onclick="return listItemTask('cb<?php echo $i;?>','toggle_frontpage')" title="<?php echo ( $row->frontpage ) ? ( 'Yes' ) : ( 'No' );?>">
<img src="images/<?php echo ( $row->frontpage ) ? 'tick.png' : ( $row->state != -1 ? 'publish_x.png' : 'disabled.png' );?>" width="16" height="16" border="0" alt="<?php echo ( $row->frontpage ) ? ( 'Yes' ) : ( 'No' );?>" /></a>
</td>
<td class="order">
<span><?php echo $page->orderUpIcon( $i, ($row->catid == @$rows[$i-1]->catid), 'orderup', 'Move Up', $ordering); ?></span>
<span><?php echo $page->orderDownIcon( $i, $n, ($row->catid == @$rows[$i+1]->catid), 'orderdown', 'Move Down', $ordering ); ?></span>
<?php $disabled = $ordering ? '' : 'disabled="disabled"'; ?>
<input type="text" name="order[]" size="5" value="<?php echo $row->ordering; ?>" <?php echo $disabled; ?> class="text_area" style="text-align: center" />
</td>
<td align="center">
<?php echo $access;?>
</td>
<td>
<a href="<?php echo $row->sect_link; ?>" title="<?php echo ( 'Edit Section' ); ?>">
<?php echo $row->section_name; ?></a>
</td>
<td>
<a href="<?php echo $row->cat_link; ?>" title="<?php echo ( 'Edit Category' ); ?>">
<?php echo $row->name; ?></a>
</td>
<td>
<?php echo $author; ?>
</td>
<td nowrap="nowrap">
<?php echo ('date', $row->created, ('DATE_FORMAT_LC4') ); ?>
</td>
<td nowrap="nowrap" align="center">
<?php echo $row->hits ?>
</td>
<td>
<?php echo $row->id; ?>
</td>
</tr>
<?php
$k = 1 - $k;
}
?>
</tbody>
</table>
<?php ('content.legend'); ?>
<input type="hidden" name="option" value="com_content" />
<input type="hidden" name="task" value="" />
<input type="hidden" name="boxchecked" value="0" />
<input type="hidden" name="redirect" value="<?php echo $redirect;?>" />
<input type="hidden" name="filter_order" value="<?php echo $lists['order']; ?>" />
<input type="hidden" name="filter_order_Dir" value="<?php echo $lists['order_Dir']; ?>" />
</form>
The seem form after execution of php code :
I want to submit a post forum with curl, I need to specifies fields to send with option CURLOPT_POSTFIELDS, this option where I specify data to send with the form to submit.
I give the form in too examples the first is the real one with php content, and the second is html part after I execute it on my server. What I want to know is fields to send to CURLOPT_POSTFIELDS, all necessary fields including <input> and whatever.
I have a question is that I want to select checkbox and I want to check it but how to do that and send the checking option to CURLOPT_POSTFIELDS ?
<input type="checkbox" name="toggle" value="" onclick="checkAll(<?php echo count( $rows ); ?>);" />
The fields I think I should send are the last 6 hidden fields
<input type="hidden" name="option" value="com_content" />
<input type="hidden" name="task" value="" />
<input type="hidden" name="boxchecked" value="0" />
<input type="hidden" name="redirect" value="<?php echo $redirect;?>" />
<input type="hidden" name="filter_order" value="<?php echo $lists['order']; ?>" />
<input type="hidden" name="filter_order_Dir" value="<?php echo $lists['order_Dir']; ?>" />
and a field where to mention that I selected checkall.
<form action="index.php?option=com_content" method="post" name="adminForm">
<table>
<tr>
<td width="100%">
<?php echo ( 'Filter' ); ?>:
<input type="text" name="search" id="search" value="<?php echo $lists['search'];?>" class="text_area" onchange="document.adminForm.submit();" title="<?php echo ( 'Filter by title or enter article ID' );?>"/>
<button onclick="this.form.submit();"><?php echo ( 'Go' ); ?></button>
<button onclick="document.getElementById('search').value='';this.form.getElementById('filter_sectionid').value='-1';this.form.getElementById('catid').value='0';this.form.getElementById('filter_authorid').value='0' ;this.form.getElementById('filter_state').value='';this.form.submit();"><?php echo ( 'Reset' ); ?></button>
</td>
<td nowrap="nowrap">
<?php
echo $lists['sectionid'];
echo $lists['catid'];
echo $lists['authorid'];
echo $lists['state'];
?>
</td>
</tr>
</table>
<table class="adminlist" cellspacing="1">
<thead>
<tr>
<th width="5">
<?php echo ( 'Num' ); ?>
</th>
<th width="5">
<input type="checkbox" name="toggle" value="" onclick="checkAll(<?php echo count( $rows ); ?>);" />
</th>
<th class="title">
<?php echo ('grid.sort', 'Title', 'c.title', @$lists['order_Dir'], @$lists['order'] ); ?>
</th>
<th width="1%" nowrap="nowrap">
<?php echo ('grid.sort', 'Published', 'c.state', @$lists['order_Dir'], @$lists['order'] ); ?>
</th>
<th nowrap="nowrap" width="1%">
<?php echo ('grid.sort', 'Front Page', 'frontpage', @$lists['order_Dir'], @$lists['order'] ); ?>
</th>
<th width="8%">
<?php echo ('grid.sort', 'Order', 'c.ordering', @$lists['order_Dir'], @$lists['order'] ); ?>
<?php if ($ordering) echo ('grid.order', $rows ); ?>
</th>
<th width="7%">
<?php echo ('grid.sort', 'Access', 'groupname', @$lists['order_Dir'], @$lists['order'] ); ?>
</th>
<th class="title" width="8%" nowrap="nowrap">
<?php echo ('grid.sort', 'Section', 'section_name', @$lists['order_Dir'], @$lists['order'] ); ?>
</th>
<th class="title" width="8%" nowrap="nowrap">
<?php echo ('grid.sort', 'Category', 'cc.title', @$lists['order_Dir'], @$lists['order'] ); ?>
</th>
<th class="title" width="8%" nowrap="nowrap">
<?php echo ('grid.sort', 'Author', 'author', @$lists['order_Dir'], @$lists['order'] ); ?>
</th>
<th align="center" width="10">
<?php echo ('grid.sort', 'Date', 'c.created', @$lists['order_Dir'], @$lists['order'] ); ?>
</th>
<th align="center" width="10">
<?php echo ('grid.sort', 'Hits', 'c.hits', @$lists['order_Dir'], @$lists['order'] ); ?>
</th>
<th width="1%" class="title">
<?php echo ('grid.sort', 'ID', 'c.id', @$lists['order_Dir'], @$lists['order'] ); ?>
</th>
</tr>
</thead>
<tfoot>
<tr>
<td colspan="15">
<?php echo $page->getListFooter(); ?>
</td>
</tr>
</tfoot>
<tbody>
<?php
$k = 0;
$nullDate = $db->getNullDate();
for ($i=0, $n=count( $rows ); $i < $n; $i++)
{
$row = &$rows[$i];
$link = 'index.php?option=com_content§ionid='. $redirect .'&task=edit&cid[]='. $row->id;
$row->sect_link = JRoute::_( 'index.php?option=com_sections&task=edit&cid[]='. $row->sectionid );
$row->cat_link = JRoute::_( 'index.php?option=com_categories&task=edit&cid[]='. $row->catid );
$publish_up =& JFactory::getDate($row->publish_up);
$publish_down =& JFactory::getDate($row->publish_down);
$publish_up->setOffset($config->getValue('config.offset'));
$publish_down->setOffset($config->getValue('config.offset'));
if ( $now->toUnix() <= $publish_up->toUnix() && $row->state == 1 ) {
$img = 'publish_y.png';
$alt = ( 'Published' );
} else if ( ( $now->toUnix() <= $publish_down->toUnix() || $row->publish_down == $nullDate ) && $row->state == 1 ) {
$img = 'publish_g.png';
$alt = ( 'Published' );
} else if ( $now->toUnix() > $publish_down->toUnix() && $row->state == 1 ) {
$img = 'publish_r.png';
$alt = ( 'Expired' );
} else if ( $row->state == 0 ) {
$img = 'publish_x.png';
$alt = ( 'Unpublished' );
} else if ( $row->state == -1 ) {
$img = 'disabled.png';
$alt = ( 'Archived' );
}
$times = '';
if (isset($row->publish_up)) {
if ($row->publish_up == $nullDate) {
$times .= ( 'Start: Always' );
} else {
$times .= ( 'Start' ) .": ". $publish_up->toFormat();
}
}
if (isset($row->publish_down)) {
if ($row->publish_down == $nullDate) {
$times .= "<br />". ( 'Finish: No Expiry' );
} else {
$times .= "<br />". ( 'Finish' ) .": ". $publish_down->toFormat();
}
}
if ( $user->authorize( 'com_users', 'manage' ) ) {
if ( $row->created_by_alias ) {
$author = $row->created_by_alias;
} else {
$linkA = 'index.php?option=com_users&task=edit&cid[]='. $row->created_by;
$author = '<a href="'. JRoute::_( $linkA ) .'" title="'. ( 'Edit User' ) .'">'. $row->author .'</a>';
}
} else {
if ( $row->created_by_alias ) {
$author = $row->created_by_alias;
} else {
$author = $row->author;
}
}
$access = ('grid.access', $row, $i, $row->state );
$checked = ('grid.checkedout', $row, $i );
?>
<tr class="<?php echo "row$k"; ?>">
<td>
<?php echo $page->getRowOffset( $i ); ?>
</td>
<td align="center">
<?php echo $checked; ?>
</td>
<td>
<?php
if ( JTable::isCheckedOut($user->get ('id'), $row->checked_out ) ) {
echo $row->title;
} else if ($row->state == -1) {
echo htmlspecialchars($row->title, ENT_QUOTES, 'UTF-8');
echo ' [ '. ( 'Archived' ) .' ]';
} else {
?>
<a href="<?php echo JRoute::_( $link ); ?>">
<?php echo htmlspecialchars($row->title, ENT_QUOTES); ?></a>
<?php
}
?>
</td>
<?php
if ( $times ) {
?>
<td align="center">
<span class="editlinktip hasTip" title="<?php echo ( 'Publish Information' );?>::<?php echo $times; ?>"><a href="javascript:void(0);" onclick="return listItemTask('cb<?php echo $i;?>','<?php echo $row->state ? 'unpublish' : 'publish' ?>')">
<img src="images/<?php echo $img;?>" width="16" height="16" border="0" alt="<?php echo $alt; ?>" /></a></span>
</td>
<?php
}
?>
<td align="center">
<a href="javascript:void(0);" onclick="return listItemTask('cb<?php echo $i;?>','toggle_frontpage')" title="<?php echo ( $row->frontpage ) ? ( 'Yes' ) : ( 'No' );?>">
<img src="images/<?php echo ( $row->frontpage ) ? 'tick.png' : ( $row->state != -1 ? 'publish_x.png' : 'disabled.png' );?>" width="16" height="16" border="0" alt="<?php echo ( $row->frontpage ) ? ( 'Yes' ) : ( 'No' );?>" /></a>
</td>
<td class="order">
<span><?php echo $page->orderUpIcon( $i, ($row->catid == @$rows[$i-1]->catid), 'orderup', 'Move Up', $ordering); ?></span>
<span><?php echo $page->orderDownIcon( $i, $n, ($row->catid == @$rows[$i+1]->catid), 'orderdown', 'Move Down', $ordering ); ?></span>
<?php $disabled = $ordering ? '' : 'disabled="disabled"'; ?>
<input type="text" name="order[]" size="5" value="<?php echo $row->ordering; ?>" <?php echo $disabled; ?> class="text_area" style="text-align: center" />
</td>
<td align="center">
<?php echo $access;?>
</td>
<td>
<a href="<?php echo $row->sect_link; ?>" title="<?php echo ( 'Edit Section' ); ?>">
<?php echo $row->section_name; ?></a>
</td>
<td>
<a href="<?php echo $row->cat_link; ?>" title="<?php echo ( 'Edit Category' ); ?>">
<?php echo $row->name; ?></a>
</td>
<td>
<?php echo $author; ?>
</td>
<td nowrap="nowrap">
<?php echo ('date', $row->created, ('DATE_FORMAT_LC4') ); ?>
</td>
<td nowrap="nowrap" align="center">
<?php echo $row->hits ?>
</td>
<td>
<?php echo $row->id; ?>
</td>
</tr>
<?php
$k = 1 - $k;
}
?>
</tbody>
</table>
<?php ('content.legend'); ?>
<input type="hidden" name="option" value="com_content" />
<input type="hidden" name="task" value="" />
<input type="hidden" name="boxchecked" value="0" />
<input type="hidden" name="redirect" value="<?php echo $redirect;?>" />
<input type="hidden" name="filter_order" value="<?php echo $lists['order']; ?>" />
<input type="hidden" name="filter_order_Dir" value="<?php echo $lists['order_Dir']; ?>" />
</form>
The seem form after execution of php code :