Home php Action for Form on PHP

Action for Form on PHP

Author

Date

Category

There is a form of recall with simple capping

& lt;? php
session_start ();
if ($ _ POST ['submit']) {
  if ($ _ post ['res'] == $ _session ['res']) {
  } else {
    $ _Session ['Mes'] = '& lt; p & gt; Dan is an invalid answer! & Lt; / p & gt;';
    HEADER ("Location: index.php");
    exit ();
  }
}
$ a = Rand (1.10);
$ B = Rand (1.10);
$ _Session ['res'] = $ A + $ B;
? & gt;
& lt; Form Action = "Vidguki-Form-result.php" Method = "POST" id = "Form-Vidguki" & gt;
& lt; Input Name = "Author" Placeholder = "Your _" Class = "Form-Name" maxlength = "34" OnKeypress = "Return Isnotmax (EVENT)" Required / & gt; & lt; br & gt;
& lt; Textarea Name = "Text" Placeholder = "Your VIDGUK" Class = "Form-Message" maxlength = "500" OnKeypress = "Return Isnotmax (Event)" Required & gt; & lt; / textarea & gt; & lt; br & gt;
& lt;? php echo $ a. '+'. $ b. '=';? & gt; & lt; input type = "text" name = "res" / & gt;
& lt; input name = "submit" class = "Form-BTN" Type = "submit" value = "Written Vіdguk" / & gt;
& lt; / form & gt;
& lt;? php
Echo $ _Session ['Mes'];
Unset ($ _ session ['mes']);
? & gt;

How to properly write an action in a block condition when checking Captch?
If the Captcha is correct, it is necessary to pass the data in vidguki-form-result.php
If not the right, then display messages on this page

vidguki-form-result.php:

include ("block / db.php");
if (isset ($ _ POST ['Author'])) {$ Author = $ _Post ['Author']; if ($ author == '') {$ author = 'anonymes';}}
if (isset ($ _ POST ['text'])) {$ text = $ _post ['text']; if ($ text == '') {unset ($ text);}}
? & gt;
& lt; div id = "content-index" & gt;
  & lt; div id = "name-menu" & gt;
    & lt;? php
    if (ISSET ($ Author) & amp; & amp; isset ($ text))
    {
      $ resultaddvidguk = mysql_query ("INSERT INTO VIDGUKI (Author, Text) Values ​​('$ Author', '$ Text')");
      if ($ resultaddvidguk == 'true') {echo "& lt; h3 & gt; ryakuєmo for your questionnaire! Your Vіdguk is the spirit of negative for us! & lt; / h3 & gt;";}
      else {echo "& lt; h3 & gt; Pomelka! Vіdguk does not bow doda! & lt; / h3 & gt;";}
    }
    ELSE.
    {
      echo "& lt; h3 & gt; vi-of-postovili not all of the fields of this Vіdguk not boiled publisan! & lt; / h3 & gt;";
    }
    ? & gt;
  & lt; / div & gt;
  & lt; div id = "vidguk-btn-nazad" & gt;
    & lt; p & gt; & lt; a href = "vidguki.php" & gt; turn to Vіdgukіv & lt; / a & gt; & lt; / p & gt;
  & lt; / div & gt;
& lt; / div & gt;

Answer 1

& lt;? php
session_start ();
if ($ _ POST ['submit']) {
  if ($ _ post ['res'] == $ _session ['res']) {
    include ("block / db.php");
    if (isset ($ _ POST ['Author'])) {$ Author = $ _Post ['Author']; if ($ author == '') {$ author = 'anonymes';}}
    if (isset ($ _ POST ['text'])) {$ text = $ _post ['text']; if ($ text == '') {unset ($ text);}}? & gt;
    & lt; div id = "content-index" & gt;
      & lt; div id = "name-menu" & gt;
        & lt;?
        if (ISSET ($ Author) & amp; & amp; isset ($ text))
        {
          $ resultaddvidguk = mysql_query ("INSERT INTO VIDGUKI (Author, Text) Values ​​('$ Author', '$ Text')");
          if ($ resultaddvidguk == 'true') {
            Echo "& lt; h3 & gt; ryakuєmo for your questionnaire! Your Vіdguk is a shower of negative for us! & lt; / h3 & gt;";
          } else {
            ECHO "& LT; H3 & GT; Pomelka! Vіdguk is not a buoy doda! & lt; / h3 & gt;";
          }
        } else {
          echo "& lt; h3 & gt; vi-of-postovili not all of the fields of this Vіdguk not boiled publisan! & lt; / h3 & gt;";
        }
        ? & gt;
      & lt; / div & gt;
      & lt; div id = "vidguk-btn-nazad" & gt;
        & lt; p & gt; & lt; a href = "vidguki.php" & gt; turn to Vіdgukіv & lt; / a & gt; & lt; / p & gt;
      & lt; / div & gt;
    & lt; / div & gt;
  & lt;?} else {
    $ _Session ['Mes'] = '& lt; p & gt; Dan is an invalid answer! & Lt; / p & gt;';
    HEADER ("Location: index.php");
    exit ();
  }
} else {
  $ a = Rand (1.10);
  $ B = Rand (1.10);
  $ _Session ['res'] = $ A + $ B;? & Gt;
  & lt; form action = "" Method = "POST" id = "Form-Vidguki" & gt; 
& lt; Input Name = "Author" Placeholder = "Your _" Class = "Form-Name" maxlength = "34" OnKeypress = "Return Isnotmax (EVENT)" Required / & gt; & lt; br & gt;
   & lt; Textarea Name = "Text" Placeholder = "Your VIDGUK" Class = "Form-Message" maxlength = "500" OnKeypress = "Return Isnotmax (Event)" Required & gt; & lt; / textarea & gt; & lt; br & gt;
   & lt;? php echo $ a. '+'. $ b. '=';? & gt; & lt; input type = "text" name = "res" / & gt;
   & lt; input name = "submit" class = "Form-BTN" Type = "submit" value = "Written Vіdguk" / & gt;
   & lt; / form & gt;
& lt;?}
Echo $ _Session ['Mes'];
Unset ($ _ session ['mes']);
? & gt;

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