Friday 15 February 2013

forms - HTML to open url based on text box entry -



forms - HTML to open url based on text box entry -

i know basic html

i want set text box on website in if user enters order number, open link order summary.

the links order summary saved on web server in format of ordernumber-date (example: http://www.mywebsite.com/orders/od12354-22.02.14.html)

all want 2 text boxes user enters order number , date. on clicking submit, should take user link automatically.

this way in php. of course of study need validate user has entered info in right formats, chapter.

findorder.php

<?php if (!empty($_post['order']) && !empty($_post['date'])) { $redirect = "orders/" . $_post['order'] . "-" . $_post['date'] . ".html"; if(file_exists($redirect) == true) { header('location: ' . $redirect); die(); } else { echo "order not found"; } } ?> <form action="findorder.php" method="post"> <input id="order" name="order" type="text" placeholder="order number"> <input id="date" name="date" type="date" placeholder="date"> <input type="submit" value="submit"> </form>

update: added file_exists bit. note can't pass proper url there, filepath.

html forms

No comments:

Post a Comment