This is my first question so if I am doing something wrong just let me know.
I currently maintain a webserver running ubuntu
, php
and mysql
.
What I would like to do is add a new page to the site which shows a user a box where they can input text and when they click "Go" it modifies a URL and opens a new tab.
For example the URL would look like the below.
http://1.2.4.5/api.php?getServices={"account":"variable"}
If the person was to input 12345
into the box and select Go it would modify the link to:
http://1.2.4.5/api.php?getServices={"account":"12345"}
I have attempted multiple different ways to implement this but had no luck so far and I can't seem to find any information about it online, could anyone give me a hand?
You can use JavaScript for this as:
$(document).on('click', '#buttonid', function(){
var variable_name = $('#textboxid').val();
var url = 'http://1.2.4.5/api.php?getServices={"account":"'+variable_name+'"}';
window.open(url);
});
Or you can do it using PHP too. Add target="_blank"
attribute in your <form>
tag
<form action="action.php" target="_blank" method="post">
And then write this PHP script on action.php
$url = 'http://1.2.4.5/api.php?getServices={"account":"'.$_POST['variable_name'].'"}';
header('location: '.$url);