I currently have the following code:
<form action="process.php" method="POST">
<fieldset class="form-search">
<input type="text" class="input-text" name="keyword" value="Enter Keyword / Catalogue Code" id="textBox"/>
<?php echo $form->error("keyword"); ?>
<input type="image" class="catalog_search_top" name="search" alt="Search" src="../images/search_form_button.png" />
</fieldset>
My problem is that the image when submitted isn't doing the same as if its image type submit.
When submitting the form with the code I provided, woul开发者_运维问答d it be expected that it would go to form process.php and send $_POST['submit']?
Thanks
if you use a image as submit button you will have in php $_POST['search_x'] and $_POST['search_y'] instead of $_POST['search']
when using an image button to submit it'll simple be a POST.
so check:
if ( $_POST )
{
// process form
}
Or you could use - based on the 'name' of the image input:
if ( isset( $_POST['search'] ) )
{
// process form
}
yip sorry as it's an image it posts co-ordinates, so search_x and search_y as stated.
Just change name="search" to name="submit", it'll work as you want.
But why you need get value for $_POST['submit']? If you want to detect your page has received a request, just use this code:
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
// Do some thing...
}
I think it better!
your field name first input is 'keyword', so in process.php try change $_POST['submit'] with $_POST['keyword'].
精彩评论