Im not new to coding. Can code more than sufficiently in SQL, SAS, VB and Pascal (many years ago).
I have a basic form created where someone is required to enter a stock/share code into it.
I want to take this answer and add that to a website URL.
For example someone types share code SOL, i want that to feed into the website’s URL and when the answer is submitted the formaction is then the modified URL containing the give share code of SOL.
So the original site is say… www.sharetracker.co.za/quote/
What I want to do is when someone enters SOL in the form, the formaction URL should read www.sharetracker.co.za/quote/SOL
But for the life of me I cannot reference the answer given in the form into the formaction URL.
Read up on php stuff and echo and the $ used to reference answers but I am lost when it comes to HTML and php coding rules.
test to see if your $_POST[‘testing’] variable has been set.
if it is set
save $_POST[‘testing’] to $newUrl value.
reset $_POST[‘testing’]
redirect page with $newUrl
else
fall through and set the $newUrl ($_POST[‘testing’]) parameter
end
<?php if(isset($_POST['testing'])): // $_SERVER['REQUEST_URI'] should be the page URL // $_SERVER['SCRIPT_NAME'] should ALSO be the page URL
$newUrl = 'http://' .$_SERVER['SERVER_NAME'] .'/' .$_SERVER['REQUEST_URI'] .$_POST['testing']; $newUrl = str_replace(' ', '-', $newUrl); // replace spaces with dashes $_POST['testing'] = NULL; // reset to prevent loop
header('Location: ' .$newUrl); // recall this page or send to another page endif; ?><!doctype html><head></head><body>
<h4>Cosmetic to display $_POST and/or $_SERVER parameters</h4> <pre style="background-color:#cff"> <br /> <?php print_r($_POST);?> <?php # print_r($_SERVER); // shows all parameters?> <br /> </pre>
<form action="?" method="post"> <p style="background-color:#cfc"> <br /> Set your URL parameter here: <input type="text" name="testing" value="parameter_goes_here" /> <input type="submit" formtarget="_blank" value="Submit" /> <?php // echo formaction="http://www.sharenet.co.za/quote/$code." ?> <br /> </p> </form></body></html>