I have the following form that is dynamically generated:
<form action="index.php?route=module/print_wizard/showPrintSheet&token=4ef5f4af6ba25d6096357fdb4809e819" method="post" enctype="multipart/form-data" id="form">
<input name="[print][6][1]" type="hidden" value="on">
<input name="[print][6][3]" type="hidden" value="on">
<input name="[info]" type="hidden" value="INV-GIS-00002-3">
<input name="[layout_override][6][1]" type="hidden" value="">
<input name="[layout_override][6][3]" type="hidden" value="">
<input name="[bundle_override][6][1]" type="hidden" value="">
<input name="[bundle_override][6][3]" type="hidden" value="">
<input name="[run_id]" type="hidden" value="14040455">
<button type="submit">Export</button>
</form>
My PHP code is:
var_dump($_POST);
echo "<HR>".$this->request->server['REQUEST_METHOD'];
I have done this a million times before and can not for the life of me figure out why my $_post array is empty. I have changed my post to a get and all the fields and values are passing, but I need to use a post. Do I need to have one visible form element? Please help!
You are not using valid names for your form fields:
<input name="[print][6][1]" type="hidden" value="on">
is not valid as it just has an array index but no name.
If you change it to for example:
<input name="print[6][1]" type="hidden" value="on">
it will work without any problems.
Related
I have this HTML form:
<form action="" method="post">
<input type="hidden" name="data_first" value="9" />
<input type="hidden" name="data_second" value="2" />
<input type="hidden" name="date" value="2018-01-25" />
<input type="text" name="posted_data" value="0.1" />
</form>
I want combine this Posted data, with serialize function.
I can serialize only one input.
example: serialize($_POST['posted_data']);
I need function like this:
serialize($_POST['posted_data'],$_POST['data_first'],$_POST['data_second'],$_POST['date']);
Any ideas?
You can simply do -
serialize($_POST);
It will serialize all the posted data. And then process them accordingly.
Update
You can use input arrays -
<form action="" method="post">
<input type="hidden" name="data[data_first]" value="9" />
<input type="hidden" name="data[data_second]" value="2" />
<input type="hidden" name="data[date]" value="2018-01-25" />
<input type="text" name="data[posted_data]" value="0.1" />
</form>
And
serialize($_POST['data']);
Will serialize those specific inputs present in data.
there are two ways
1) By sending post array
e.g serialize($_POST)
2) By sending post data through array
e.g serialize(array($_POST['posted_data'],$_POST['data_first'],$_POST['data_second'],$_POST['date']));
I currently built a simple form to GET request someones zipcode.
<form action="http://example.com" method="get" target="_blank">
<p>ZIPCODE</p>
<input type="text" name="zip">
<input type="submit" value="Submit">
</form>
When submitted it will be http://example.com/?zip=ZIPCODE
What I am looking to do it add an additional piece so it will be http://example.com/?zip=234&country=usa
I tried adding a hidden field <input type="hidden" name="country=usa"></input> but this replaces = with %3D and adds = after it like so: http://example.com/?zip=ZIPCODE&country%3Dusa=
How can I easily append the URL with country=usa?
Try:
<form action="http://example.com" method="get" target="_blank">
<p>ZIPCODE</p>
<input type="text" name="zip">
<input type="hidden" name="country" value="usa">
<input type="submit" value="Submit">
</form>
i have a problem keeping a post element in variables before calling one more time post in a second form .
briefly:
variable below contain elements from previous post
$img=isset($_POST['image'])?$_POST['image']:false;
$table=isset($_POST['tabl'])?$_POST['tabl']:false;
Then i have as next to the lines above the form below :
<form method="post" action="" style="padding-top:200px;padding-bottom:200px;padding-left:500px">
<div><span>Email</span></div> <input type="text" value="" name="user"/><br><br>
<div><span>Password</span></div> <input type="password" value="" name="pass"/><br><br>
<input type="submit" value="send" name="submit"/>
</form>
and right after pressing submit $img and $table are both empty .
how can i keep the values in $imgand $table even after calling post again ?
any clue ?
Thanks
You aren't sending the variables you want in the POST data in your second form.
You could use a hidden field to send it,
A bit like this.
<form method="post" action="" style="padding-top:200px;padding-bottom:200px;padding-left:500px">
<input type="hidden" name="img" value="<?php echo $img;?>" />
<input type="hidden" name="table" value="<?php echo $table;?>" />
<div><span>Email</span></div> <input type="text" value="" name="user"/><br><br>
<div><span>Password</span></div> <input type="password" value="" name="pass"/><br><br>
<input type="submit" value="send" name="submit"/>
</form>
i am submitting form using get method to a url which already contain parameter like
localhost/myfile.php?section=console
my form code is
<form method="GET" action="<?=basename($_SERVER['PHP_SELF'])?>/section=console">
<input type="text" name="cmd" />
<input type="submit" value="execute" />
</form>
when i submit this data through post type it submit data then it submit like myfile.php?cmd=blahblah
but i want to submit it to myfile.php?section=console&cmd=blahblah.
i can do this by using hidden field but i am insearch of other better way
Simply add a hidden field into your form
<input type="hidden" name="section" value="console">
If you are not interested in using hidden fields then rewrite your form like this
<form method="GET" action="<?php basename($_SERVER['PHP_SELF']) ?>/?section=console">
You should use a hidden input within your form
<form method="GET" action="<?php echo basename($_SERVER['PHP_SELF']); ?>">
<input type="hidden" name="section" value="console">
<input type="text" name="cmd">
<input type="submit" value="execute">
</form>
I've two forms in a single page. One form fetches data from database table. In the other form I need those fetched values to be added in another table, with additional values.
<form method="post" action="same.php" name="form1">
<input type="text" name="search" />
<input type="submit" name="result" value="search_for" />
</form>
<form method="post" action="same.php" name="form2">
<input type="date" name="add_date" />
<input type="submit" name="result" value="search_for" />
</form>
After searching I will get values in a variable $search.
Now I need to post the variable $search in another table, but when I click submit the search values get null.
i don't think you can do this
you have only one way to do this is to include all input's in to one form
i think you can do this by 2 way
putting all input in one form
or you can do this by making two step as
page 1 contains form one and page2 contain form2
as follows
page 1
<form method="post" action="same.php" name="form1">
<input type="text" name="search"/>
<input type="submit" name="result" value="search_for">
</form>
page 2
<form method="post" action="same.php" name="form2">
//data from page1 {form1}
<input type="hidden" name="search" value=<?php echo $_POST['search']; ?> />
//you will not need this
<input type="submit" name="result" value="search_for">
<input type="date" name="add_date"/>
<input type="submit" name="result" value="search_for">
</form>