form post with control values in URL

A

Anonymous

Guest
Dear all,

I have the php page code. How to do below??

<form action="<?php echo base_url().MY_PATH.'search/'.$catID_.'/'.$locID_.'/'.$keywords.'/'.$sortByID;?>" method="POST">

How to replace the $catID, $locID, $keywords, $sortByID by control selected value of drop down when submit?? Does I need to use javascript to submit and assign control value getelement...to the location.href?? Any sample Code??
 
You don't need to replace if you use GET instead of POST. Your input field values will be added to the url as key/value pairs.
 
Code:
/* Get the current page */
$phpSelf = filter_input(INPUT_SERVER, 'PHP_SELF', FILTER_SANITIZE_URL); // Same thing as $_SERVER['PHP_SELF']; but safer:
$path_parts = pathinfo($phpSelf);
echo "<pre>" . print_r($path_parts, 1) . "</pre>";
$basename = $path_parts['basename']; // Use this variable for action='':
$pageName = ucfirst($path_parts['filename']);

I don't know if the above will help you out, but I would check it out

I do this for my forms

Code:
<form id="contact" action="<?php echo $basename; ?>" method="post">
//more code....
 
Here's a quick video from jream.com that shows passing form data with get, post, and request
https://www.youtube.com/watch?v=CEl3bhCBjtI
 
Back
Top