Jump to content

Insert value into URL from a FORM


dani33l_87

Recommended Posts

<html>
<body>

<form action="url.php" method="post">
Website: <input type="text" name="web" value="phpfreak.com"><br>
Category: <input type="text" name="cat" value="coding" ><br>
<input type="submit">
</form>

</body>
</html>

 

 

How can I take the value from a form and insert it in a URL that can be accessed by the user:

                          http://{web}/{cat}

 

A little complicate, how can I take the value without click it on submit action and open in a new page with the URL Values.

Link to comment
https://forums.phpfreaks.com/topic/289105-insert-value-into-url-from-a-form/
Share on other sites

Well the submit button has to be pressed for the server to know what post values you have. Just redirect after you check to see if the form has been submitted

 

 

if(!empty($_POST))
{
   $url = "http://" . $_POST['web'] . "/" . $_POST['cat'];
   header("Location:$url");
   exit;
}

 

* Keep in mind, my code is not safe at all. Just an example

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.