Answer the question
In order to leave comments, you need to log in
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>';
}
}
require "rb.php";
R::setup( 'mysql:host=localhost;dbname=test_db',
'mysql', '123' );
<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
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>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question