forms - PHP Added to query string on submit -


i have text field , submit button, when click on submit button want add on query string.

example

http://www.fakewebsite.com/?name=mike

but name appears blank

here code

<?php  if($_post){       echo $_post['name'];     }else{ ?>       <form action="http://www.fakewebsite.com/test.php?name=<?php $_server['name']; ?>" method="post">     <label for="name">name</label><input type="text" name="name" id="name" />     <input type="submit" name="submit" id="submit" />     </form>   <?php } ?> 

post request differ get requests in terms of how send data server.

with data elements appended url (like tried).

with post data elements within body of http request.

this problem 1: trying pass argument parameter. can work, not guarranteed to.

the other thing is, have input field same name name. if first thing work, input field override data.

what can fox that? can add hidden input field different name send input server:

<form action="foo.php" method="post">   <input type="hidden" name="other_name" value="<?= $_server['name'] ?>" />   <input type="text" name="name" value="" />   <input type="submit" /> </form> 

and keep name collision in check.

edit:

a third problem appeared me <? $_server['name'] ?> not output data within $_server['name'].

to should use

<?php echo $_server['name'] ?>  // or, works  <?= $_server['name'] ?> 

Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -