dani33l_87 Posted June 10, 2014 Share Posted June 10, 2014 <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 More sharing options...
akphidelt2007 Posted June 10, 2014 Share Posted June 10, 2014 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 https://forums.phpfreaks.com/topic/289105-insert-value-into-url-from-a-form/#findComment-1482408 Share on other sites More sharing options...
dani33l_87 Posted June 10, 2014 Author Share Posted June 10, 2014 Thanks, But why do you say is not safe at all? Link to comment https://forums.phpfreaks.com/topic/289105-insert-value-into-url-from-a-form/#findComment-1482412 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.