Home php HTML & AMP button; PHP

HTML & AMP button; PHP

Author

Date

Category

I need to create a shape in which there will be a SUBMIT type button and two text fields in which you can enter 2 numbers, and the PHP script should be launched by pressing the button which for example will display the inscription “Hello”.
I made only the shape and button, I have no idea how to call php script.

& lt;! doctype HTML & gt;
& lt; HTML LANG = "EN" & GT;
& lt; Head & gt;
  & lt; Meta Charset = "UTF-8" & gt;
  & lt; Title & gt; QWR & LT; / Title & GT;
& lt; / Head & gt;
& lt; Body & gt;
  & lt; Form Action = "index.php" & gt;
    & lt; Input Type = "Text" Placeholder = "ENTER First Num" & gt;
    & lt; Input Type = "Text" Placeholder = "ENTER Second Num" & gt;
    & lt; Button Type = "Submit" & gt; Send Information & LT; / Button & GT;
  & lt; / form & gt;
& lt; / body & gt;
& lt; / html & gt;

Answer 1, Authority 100%

Started file index.php

& lt;? php
Echo (int) $ _ post ['first']. "& lt; br & gt;";
echo (int) $ _ post ['second'];
? & gt;
  & lt;! DOCTYPE HTML & GT;
  & lt; HTML LANG = "EN" & GT;
  & lt; Head & gt;
    & lt; Meta Charset = "UTF-8" & gt;
    & lt; Title & gt; QWR & LT; / Title & GT;
  & lt; / Head & gt;
  & lt; Body & gt;
    & lt; Form Method = "POST" Action = "index.php" & gt;
 // or action = '', or at all without action
      & lt; Input Type = "text" name = "first" placeholder = "ENTER First Num" & gt;
      & lt; Input Type = "text" name = "second" placeholder = "ENTER Second Num" & gt;
      & lt; Button Type = "Submit" & gt; Send Information & LT; / Button & GT;
    & lt; / form & gt;
  & lt; / body & gt;
  & lt; / html & gt;

or with an external file, running file any, with the extension PHP or HTML | HTM :

& lt;! doctype HTML & gt;
  & lt; HTML LANG = "EN" & GT;
  & lt; Head & gt;
    & lt; Meta Charset = "UTF-8" & gt;
    & lt; Title & gt; QWR & LT; / Title & GT;
  & lt; / Head & gt;
  & lt; Body & gt;
    & lt; Form Method = "POST" ACTION = "Action.php" & gt;
      & lt; Input Type = "text" name = "first" placeholder = "ENTER First Num" & gt;
      & lt; Input Type = "text" name = "second" placeholder = "ENTER Second Num" & gt;
      & lt; Button type = "submit" & gt; Send Information & lt; / Button & gt;
    & lt; / form & gt;
  & lt; / body & gt;
  & lt; / html & gt;

file.php , must be in the folder with a starting file (index.php ), or elsewhere – then you need to correctly specify the path to it in the starting fala .

& lt;? php
  Echo (int) $ _ post ['first']. "& lt; br & gt;";
  echo (int) $ _ post ['second'];
  ? & gt;

Advanced:

PHP HTML formation scenarios forms http://coderhs.com/archive/php_send_form


Answer 2

in & lt; Form Action = "#" & gt; Script on the same page or link to a file with a script instead of #. If you want to use values ​​with field fields, they fall into an $ _post [] or $ _get [] array depending on what you pointed to Method.

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions