PHP Mysql Insert only works in Chrome

Asked

Viewed 69 times

-1

I have a page with a form where is inserted name, project, etc... only when I click the form Submit in Firefox or IE does not work, But in Chrome works normally.

OBS:

1- I had an old bank. When I change to this old address Insert works in both browsers.

2- I have another page that updates the data and works normally for all browsers, the problem is only the insertion of data using IE and Firefox.

3-I’m using a library for db php mysql: https://github.com/joshcam/PHP-MySQLi-Database-Class

The problem would be in the code, in the bank or in the browser?

EDIT: Code:

function action_adddb () {
    global $db;

    $data = Array(
        'prname' => $_POST['prname'],
        'members' => $_POST['members']
    );

    $id = $db->insert ('users', $data);


    header ("Location: page_insert.php");
    exit;
}

$db = new Mysqlidb ('nomedohost', 'username', 'senha', 'nomedobanco');
if ($_GET) {
    $f = "action_".$_GET['action'];
    if (function_exists ($f)) {
        $f();
    }
}


<form name ="form1" class=" form-horizontal" action='page_insert.php?action=<?php echo $action?>' method=post>

<input type=hidden name='id' value='<?php echo $data['id']?>'>

<input class="form-control" type=text name='prname' required placeholder='Project Name' value="<?php echo $data['prname']?>">
<input class="form-control" type=text name='members' required placeholder='Members (First and Middle name)' value='<?php echo $data['members']?>'>
<input id="submit" name="submit" type="submit" value="Create"  class="btn btn-primary text-center btn-block">

</form>
  • To help you better, post your code in the post.

  • @Alissonacioli I edited with part of the code

  • Gives some SQL error?

  • @fernandoandrade no error

2 answers

0

Try to use the code:

function action_adddb () {
    global $db;

    $data = Array(
        'prname' => $_POST['prname'],
        'members' => $_POST['members']
    );

    $id = $db->insert ('users', $data);


    header ("Location: page_insert.php");
    exit;
}

$db = new Mysqlidb ('nomedohost', 'username', 'senha', 'nomedobanco');
if (isset($_GET['action']) && !empty($_GET['action'])) {
    $f = "action_".trim($_GET['action']);
    if (function_exists ($f)) {
        $f();
    }
}


<form name ="form1" class=" form-horizontal" action='page_insert.php?action=<?php echo $action?>' method="post">

<input class="form-control" type="text" name='prname' placeholder='Project Name' value="<?php echo $data['prname']?>" required>
<input class="form-control" type="text" name='members' placeholder='Members (First and Middle name)' value='<?php echo $data['members']?>' required>

<input id="submit" name="submit" type="submit" value="Create" class="btn btn-primary text-center btn-block">

<input type=hidden name='id' value='<?php echo $data['id']?>'>

</form>

If not, tell him if he updates the page after clicking the button Create and if in the url it enters the file page_insert.php with the query string ?action=nome_acao

-1

I solved the problem, it was a date field (which I did not mention in the above code), I just took it out and ran again

  • As you have found the solution, you may, if you wish, close the question, or post an appropriate response. I say this thinking of future users who will read your question.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.