I'm developing a plugin in wordpress, there is data that needs to be listed by search but I can't get them with the get parameter.
I can send with the post parameter, but when the user refreshes the page, she has to search again according to the order number.
Following my code:functions.php
add_action('admin_menu', 'testPluginAdminMenu');
function testPluginAdminMenu()
{
add_menu_page('Return Request',
'Return Request',
'manage_options',
'list',
'myFunction'
);
add_submenu_page(
'null',
'Return Request List',
'Return Request List',
'manage_options',
'listAll',
'myFunctionList');
}
index.php
<?php
function myFunctionList(){
if(isset($_GET['request_order'])){
echo $search = $_GET['request_order'];
}
}
function myFunction(){ ?>
<form method="get" action="<?php echo admin_url('admin.php?page=listAll&request_order='.$_GET['request_order'] ) ?>">
<input type="text" name="request_order" placeholder="Search Order Number..">
<button type="submit" >Search</button>
</form>
<?php } ?>
Output from url: localhost/wordpress/wp-admin/admin.php?request_order=7481
page=listAll not appearing on url
Thank you advance.
Can you try something like this
$qs = array(
'page' => 'listAll',
'request_order' => $_GET['request_order']
);
$qs = http_build_query($qs, null, "&", PHP_QUERY_RFC3986);
<?php echo admin_url('admin.php?' . $qs ) ?>
UPDATE 1
<form method="get" action="<?php echo admin_url('admin.php?page=listAll&request_order='.$_GET['request_order'] ) ?>">
<input type="text" name="request_order" placeholder="Search Order Number..">
<input type="hidden" name="page" value="listAll" />
<button type="submit" >Search</button>
</form>
I'm trying to add a form with hidden inputs into the post content using external PHP fle.
When i try it from the browser the form added successfully but when i try it from command line, the form inputs are deleted.
Here is my code:
require('../wp-load.php');
$content = '<div class="buy-preowned">
<form accept-charset="UTF-8" action="https://www.tesla.com//order?redirect=no" id="tesla-cpo-marketing-buy-form" method="post">
<div>
<input name="CPOvehicle" type="text" value="1"/>
<input name="VIN" type="hidden" value="5YJSA1E1XHF210809"/>
<input name="vehicleMapId" type="hidden" value="1280359"/>
<input name="titleStatus" type="hidden" value="NEW"/>
<input name="form_id" type="hidden" value="tesla_cpo_marketing_buy_form"/>
</div>
</form>
<p class="small-text">
Requires a $2,500 deposit
</p>
</div>
';
$post_id = 1;
$data = array(
'ID' => $post_id,
'post_content' => $content,
);
When i checked the database, the form is stored as:
<form accept-charset="UTF-8" action="https://www.tesla.com//order?redirect=no" id="tesla-cpo-marketing-buy-form" method="post">
<div>
</div>
</form>
this is only happen when i rub the script from command line, any idea how to resolve it.
Thank you
It s because of built-in security filters. As it is not normal to store some form data inside content(there are shortcodes for that), WP disabled inserting some non-text tags.
But anyway, you can enable it manually.
kses_remove_filters();
$post_id = 1;
$data = array(
'ID' => $post_id,
'post_content' => $content,
);
wp_update_post($data);
kses_init_filters();
I am trying to validate text area in codeigniter
code in view
Write the best two hoppy you pratise
<?php $user=" "; ?>
<form action= "<?php echo base_url('log_c/save_hoppy/ ' .$user ); ?>" method="post" >
<?php echo form_error('hoppy'); ?>
<textarea name="hoppy" cols="20" rows="2">
<?php echo set_value('hoppy'); ?>
</textarea>
<input type="submit" name="submitbutton" value=" Save ">
</form>
and this code in controller
public function save_hoppy($user)
{
$this->form_validation->set_rules('hoppy', 'Hoppy', 'required|max_length[40]');
echo"after validation".$user."<br>";
$hoppy = $this->input->post('hoppy');
echo"<br>this hoppy".$hoppy;
}
But this validation doesn't work
.the population text area work please any one help me
remove above text area and paste Codeigniter form input
$data = array(
'name' => 'hoppy',
'id' => 'hoppy',
'rows' => '2',
'cols' => '20',
'maxlength' => '40'
);
echo form_textarea($data);
Here is the solution
<textarea name="description">
<?php echo set_value('description'); ?>
</textarea>
Hi guys I'm making a report post form using this code below:
$rp_options = array(
'broring' => 'This is really boring',
'difficult' => 'I don\'t understand this',
'great' => 'Great stuff, need more'
);
$mail_report_to = 'me#domain.com');
function createReportPostForm() {
global $rp_options, $post;
$html = '
<div id="formcont">
<h3>Report this article</h3>
<form id="myform">
<p>
<label for="name">What\'s wrong?</label>
<select name="report-msg" id="report-msg">
<option val="">...</option>';
foreach ($rp_options as $ok => $ov) {
$html .= '
<option val="'.$ok.'">'.$ov.'</option>';
}
$html .= '
</select>
<input type="hidden" name="posturl" value="'.get_permalink().'" />
<input type="hidden" name="action" value="ajax_action" />
<input type="button" value="Submit" id="submit_button" />
</p>
</form>
</div>
<div id="output"></div>';
return $html;
}
add_shortcode('rp-form', 'createReportPostForm');
http://www.web-development-blog.com/archives/wordpress-report-post/
I got the form but it does not send the mail can anyone tell what is missed in this code to make it worked? Thanks
i have some code that will post to the users wall, however, at the minute it will post when the page is loaded, i need it to post only when the 'post to my wall button is submitted.
here is my code:
<div align="center">
<form method="GET" action="translate.php">
<textarea name="status2" cols="50" rows="5"<input type="text"/>
<?php echo str_ireplace(array ('old','awkward','all','again','behind','along','alright','hello','among','children','yes','child','kids','food','barnard castle','beer','book','blow','beautiful','bird','burst','brown','burn','boots'),
array ('auld', 'aakwad', 'aall','agyen','ahint','alang','alreet','alreet','amang','bairns','aye','bairn','bairns','bait','barney','beor','beuk','blaa','bonny','bord','borst','broon','bourn','byeuts'),$status); ?>
</textarea><br>
<input type="submit" value="post to wall"
// i did try my wall code here but it still posted on page load
/>
</form>
</div>
<?php
$args = array(
'message' => 'Hello World',
'link' => 'http://apps.facebook.com/geordie-status/',
'caption' => 'Translate from English to Geordie'
);
$post_id = $facebook->api("/$uid/feed", "post", $args);
?>
Add name attribute to your input tag. and use isset for check if the user pressed the submit button.
<input type="submit" value="post to wall" name="submit"
// i did try my wall code here but it still posted on page load
/>
</form>
</div>
<?php
if (isset($_POST['submit'])){
$args = array(
'message' => 'Hello World',
'link' => 'http://apps.facebook.com/geordie-status/',
'caption' => 'Translate from English to Geordie'
);
$post_id = $facebook->api("/$uid/feed", "post", $args);
}
?>
You should put the code for the posting to the wall inside translate.php since that is the page listed in the form action. When the form gets submitted, values will be passed as parameters to translate.php then you can use $_GET to fetch them and execute the code that writes to the wall.
I think your problem is that your browser re-sends data each time the page is reloaded.
There are 2 approaches:
Redirect user to the same page, so sent data will be cleared (header("Location: asd"))
Store some hash in session, make a hidden input and check whether the hash is right. Change the hash when the form is correctly submitted.