Skip to content Skip to sidebar Skip to footer

Click Submit In Html And Run Php Code

I am new to html & php and I appreciate your help. I am trying to accept user input into a webpage and then after the user clicks the submit button, write a new record out to

Solution 1:

I think it can be good to read a bit more about it. Check here.

Anyway, you need to say the name of the file to post to: <input type="submit" action="file.php" name="Submit" /> for example.

And you need to have more inputs than the submit.

Acording to your php you should have as example this in the html:

<formaction="your_php_file.php"method="post"><p>Your first name: <inputtype="text"name="FName" /></p><p>Your last name: <inputtype="text"name="LName" /></p><p>Your MI: <inputtype="text"name="MI" /></p><p><inputtype="submit"name="Submit"/></p></form>

And the php tags are like <?php to open, and ?> to close.

So like:

<?phpif(isset($_POST['Submit'])) {
        $FName = $_POST['FName'];
        $MI = $_POST['MI'];
        $LName = $_POST['LName'];
//....?>

Solution 2:

Your PHP tags are incorrect. Use <?php and ?> to tell PHP to start and stop interpreting the code between them. Also, make sure you're closing the form element (I only see you're opening it) using </form> and that you indeed have all those fields contained inside of it.

Post a Comment for "Click Submit In Html And Run Php Code"