Jump to content

Insert value into URL from a FORM


dani33l_87
Go to solution Solved by akphidelt2007,

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
Share on other sites

  • Solution

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.