Search code examples
phpposttextinputfill

PHP Post fill text inside <input type="text">


dominios/process.php

This is a domain register script

Here's the output for an available domain, with a Register button next to it

echo
   '<h5 class="available">
       <span>Available</span>
       ' . $domain. '<b>' . $extension .'</b> is available!
    </h5>
   <a href="register-form.php">Register</a>';

That <a href="register-form.php">Register</a> should send register-form.php the chosen domain and extension informations, and fill it in the text input

register-form.php

Formulary that holds the <input id="domain" type="text" /> and that needs to be filled with the functions mentioned above /\ , with both domain and extension

Full process.php code available by clicking the title of this question, /\ above


Solution

  • You can 'fill' your input field with value="your value here"

    You can fill your input field server side with some GET variables like so: value="<?php echo $variable;?>"

    Now it's up to you how you can get the register button to send a GET variable to the register form.php.

    Try googling, as this is basic knowledge; and you need to show us some effort your self.

    edit You can do it with a form as described above, but that's not the only way. You could change the link behind your 'register' text to register-form.php?ext=domainA.com:

    echo
    '<h5 class="available">
       <span>Available</span>
       ' . $domain. '<b>' . $extension .'</b> is available!
    </h5>
    <a href="register-form.php?ext='.$domain.$ext.'">Register</a>';
    

    In your other page you should do something like:

    $url = do_some_type_checkingAndChecks($_GET['ext']);
    <input id="domain" type="text" value='<?php echo $url;?>'/>