L
L
laflare2021-06-07 13:35:43
PHP
laflare, 2021-06-07 13:35:43

RedBeanPHP not working at all?

red bean php not working The script should enter the entered data in the form into a table in the database, instead absolutely nothing happens, no errors, nothing. I don't know what to do, what is my mistake?

Script:

require "ConnectDB.php";

$data = $_POST;
if(isset($data["send__button"])) {
    $errors = array();
    if(trim($data['name']) == '') {
        $errors[] = 'Enter your name.';
    }
    if(trim($data['surname']) == '') {
        $errors[] = 'Enter your surname.';
    }
    if(empty($errors)) {
        $user = R::dispense('users');
        $user->name = $data['name'];
        $user->surname = $data['surname'];
        $user->reg_date = date("d.m.Y/H:i:s");
        R::store($user);
        echo '<p>Succes</p>';
        } else {
            echo '<p>Error: '.array_shift($errors).'</p>';
        }
    }


Database connection file:
require "rb.php";
  R::setup( 'mysql:host=localhost;dbname=test_db',
         'mysql', '123' );


The form:
<form method="POST">
    <input type="text" name="name" placeholder="Name">
    <input type="text" name="surname" placeholder="Surname">
    <button class="send__button" type="submit">Send</button>
</form>

Answer the question

In order to leave comments, you need to log in

2 answer(s)
G
galaxy, 2021-06-07
@laflare

if(isset($data["send__button"])) {
And where, one wonders, will send__button come from in $_POST? Why did you decide that the data is sent based on the class?

<button class="send__button" type="submit">Send</button>

O
Oleg Frolov, 2021-06-07
@Digiport

You may have caught a 500 error. See error.log

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question