There is a form of review with a simple captcha

<?php session_start(); if($_POST['submit']){ if($_POST['res'] == $_SESSION['res']){ }else{ $_SESSION['mes'] = '<p>Дан неверный ответ!</p>'; header("Location: index.php"); exit(); } } $a = rand(1,10); $b = rand(1,10); $_SESSION['res'] = $a + $b; ?> <form action="vidguki-form-result.php" method="post" id="form-vidguki"> <input name="author" placeholder="ВАШЕ ІМ'Я" class="form-name" maxlength="34" onkeypress="return isNotMax(event)" required /><br> <textarea name="text" placeholder="ВАШ ВІДГУК" class="form-message" maxlength="500" onkeypress="return isNotMax(event)" required></textarea><br> <?php echo $a. ' + ' .$b. ' = ';?><input type="text" name="res" /> <input name="submit" class="form-btn" type="submit" value="НАПИСАТИ ВІДГУК " /> </form> <?php echo $_SESSION['mes']; unset($_SESSION['mes']); ?> 

How to write an action in the condition block when checking captcha? If the captcha is correct, you must transfer the data to vidguki-form-result.php. If not, then display the messages on this page.

vidguki-form-result.php:

 include ("block/db.php"); if (isset($_POST['author'])) {$author = $_POST['author']; if ($author == '') {$author='Аноним';}} if (isset($_POST['text'])) {$text = $_POST['text']; if ($text == '') {unset($text);}} ?> <div id="content-index"> <div id="name-menu"> <?php if (isset($author) && isset($text)) { $resultaddvidguk = mysql_query ("INSERT INTO vidguki (author,text) VALUES ('$author','$text')"); if ($resultaddvidguk == 'true') {echo "<h3>ДЯКУЄМО ЗА ВАШУ ДУМКУ ! ВАШ ВІДГУК ДУЖЕ ВАЖЛИВИЙ ДЛЯ НАС !</h3>";} else {echo "<h3>ПОМИЛКА ! ВІДГУК НЕ БУВ ДОДАНИЙ !</h3>";} } else { echo "<h3>ВИ ЗАПОВНИЛИ НЕ ВСІ ПОЛЯ ТОМУ ВІДГУК НЕ БУВ ОПУБЛІКОВАН !</h3>"; } ?> </div> <div id="vidguk-btn-nazad"> <p><a href="vidguki.php">ПОВЕРНУТИСЯ ДО ВІДГУКІВ</a></p> </div> </div> 

    1 answer 1

     <?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='Аноним';}} if (isset($_POST['text'])) {$text = $_POST['text']; if ($text == '') {unset($text);}}?> <div id="content-index"> <div id="name-menu"> <? if (isset($author) && isset($text)) { $resultaddvidguk = mysql_query ("INSERT INTO vidguki (author,text) VALUES ('$author','$text')"); if ($resultaddvidguk == 'true') { echo "<h3>ДЯКУЄМО ЗА ВАШУ ДУМКУ ! ВАШ ВІДГУК ДУЖЕ ВАЖЛИВИЙ ДЛЯ НАС !</h3>"; }else{ echo "<h3>ПОМИЛКА ! ВІДГУК НЕ БУВ ДОДАНИЙ !</h3>"; } }else{ echo "<h3>ВИ ЗАПОВНИЛИ НЕ ВСІ ПОЛЯ ТОМУ ВІДГУК НЕ БУВ ОПУБЛІКОВАН !</h3>"; } ?> </div> <div id="vidguk-btn-nazad"> <p><a href="vidguki.php">ПОВЕРНУТИСЯ ДО ВІДГУКІВ</a></p> </div> </div> <?}else{ $_SESSION['mes'] = '<p>Дан неверный ответ!</p>'; header("Location: index.php"); exit(); } }else{ $a = rand(1,10); $b = rand(1,10); $_SESSION['res'] = $a + $b;?> <form action="" method="post" id="form-vidguki"> <input name="author" placeholder="ВАШЕ ІМ'Я" class="form-name" maxlength="34" onkeypress="return isNotMax(event)" required /><br> <textarea name="text" placeholder="ВАШ ВІДГУК" class="form-message" maxlength="500" onkeypress="return isNotMax(event)" required></textarea><br> <?php echo $a. ' + ' .$b. ' = ';?><input type="text" name="res" /> <input name="submit" class="form-btn" type="submit" value="НАПИСАТИ ВІДГУК " /> </form> <?} echo $_SESSION['mes']; unset($_SESSION['mes']); ?> 
    • Comments are not intended for extended discussion; conversation moved to chat . - Nicolas Chabanovsky