Form to redirect to a particular URL

272
May 05, 2017, at 11:27 PM

I need a form with one input (eg. "number") that after sumbit redirects the broswer to http://staticurl/[number].html How can I do?

Answer 1
header('location:  http://staticurl/'.$_POST['number'].'html');

Maybe?

Answer 2

Assume a HTML form like

<form action="" method="POST">
    <input type="number" name="number">
    <input type="submit" name="submit" value="submit">
</form>

Now using php you can redirect

<?php 
    if(isset($_POST['submit'])){
        header("Location: http://staticurl/".$_POST['number'].".html");
    }
 ?>

If header() returns any error then you can do it with javascript inside php like

<?php 
    if(isset($_POST['submit'])){
        echo '
            <script>
                window.location.href = "http://staticurl/'.$_POST['number'].'.html";
            </script>
        ';
    }
 ?>

Validate the form data before processing it.

READ ALSO
How to pick the profile picture from the users table

How to pick the profile picture from the users table

i am building a social media site and i am currently working on the posts module

184
How put files from FTP to Firebase-storage?

How put files from FTP to Firebase-storage?

I have files on FTP-serverHow i can to move them to my firebase-storage with PHP or javascript? Or maybe someone know how put files from 1C to firebase? Both options are good for me

294
PHP Variable Scope and includes

PHP Variable Scope and includes

I have a page (indexphp) set out like this:

253
PHP Warning: SimpleXMLElement::asXML()

PHP Warning: SimpleXMLElement::asXML()

for some time now I am receiving this warning on two of my sites:

644