Help required with HTML and php

Hi guys and girls.

First post on here.

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…

What I want to do is when someone enters SOL in the form, the formaction URL should read

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.

Dont laugh here is what I tried.

$Cname = $_POST[“Code”];

<form action=““” method=“post”>
<p style=“color:rgb(0,0,0)”>Stock of Interest (Supply share code): <input type=“text” name=“Code” ></p><br>
<input type=“submit” formtarget=”_blank" value=“Submit” echo formaction=“[COLOR=“#FF0000”][B]$code[/B][/COLOR].”>

See the red parts where I tried to echo and reference.

Any help would be greatly appreciated


<form method="post" action="<?php echo $code; ?>">
<input type="submit" value="Submit">

Your code is a bit mixed up as you are using get for the URL part and post as well.

You will need to get the code from the URL and it is not a variable; so this will not work.

// get the variable from the URL
 $Cname = $_GET["code"];

Lets start again - you are submitting your form to a folder called quote and not a php page according to your URL. What is the php page called?

Oh sorry it reads"<form action=“c:\site\code.php”

Now how do I tell the code to go fetch the submitted value from that file into the URL and then running that URL

As I said I can code in a few languages but html and php is greek to me :frowning:

double post

Hi Saffa,

The only way I can see to solve your problem is:

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
fall through and set the $newUrl ($_POST[‘testing’]) parameter

<?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: &nbsp;        <input type="text" name="testing" value="parameter_goes_here" />        <input type="submit" formtarget="_blank" value="Submit" />        <?php // echo formaction="$code." ?>        <br />      </p>    </form></body></html>