Ilya Medvedev Ilya Medvedev - 1 month ago 8
HTML Question

Changing a variable in php file

How to add values from

<input>
to
$var
in php file?

html

<input type="text" id="align" name="align"/>


php file

<?php
$align="center";
?>

Answer

You mean you want to post it and put it in a PHP variable?

Try this:

<form action="somephpfile.php" method="POST">
    <input type="text" name="align" value="center" />
    <input type="submit" value="Send!" />
</form>

somephpfile.php

    $align = $_POST['align'];
    echo $align;