Skip to main content
Participating Frequently
May 7, 2020
Answered

POST SUCCESS BUT NO DATA IN DB

  • May 7, 2020
  • 3 replies
  • 1405 views

Hi guys, please assist me, I am posting to the database from my website and the success message and page is showing, however when I look into the database nothing shows, what could be the matter!? 

    This topic has been closed for replies.
    Correct answer osgood_

    which line of code exactly if i may ask?


    I'm not providing all of the solution but a streamlined one so you get the idea when using mysqli (I've set down to 'eMail'  in the $_POST[] array list).

     

    1. Add the name attribute 'insert' to your form button:
    <input type="submit" name="insert" value="Insert">

     

    2. Connect to your database: (use your connection details):

    <?php $conn = new mysqli('hostServerName' , 'username' , 'password' , 'databaseName');?>

     

    3. Insert the form data into your database.

     

    <?php
    // Insert form data IF the form submit button with the name of 'insert' is clicked
    if(isset($_POST['insert'])) {
    $MemberID = $conn->real_escape_string($_POST['whatever2']);
    $title = $conn->real_escape_string($_POST['Title']);
    $fname = $conn->real_escape_string($_POST['FName']);

    $lname = $conn->real_escape_string($_POST['LName']);

    $identityNumber = $conn->real_escape_string($_POST['Identity_Number']);

    $dateOfBirth = $conn->real_escape_string($_POST['Date_Of_Birth']);

    $nationality = $conn->real_escape_string($_POST['Nationality']);

    $citizenship = $conn->real_escape_string($_POST['Citizenship']);

    $cell = $conn->real_escape_string($_POST['Cell']);

    $eMail = $conn->real_escape_string($_POST['eMail]);

    $conn->query("INSERT INTO borrower
    (Member_Id, Title, FName, LName, Identity_Number, Date_Of_Birth, Nationality, Citizenship, Cell, eMail)
    VALUES
    ('$MemberID', '$title', '$fname', '$lname', '$identityNumber', '$dateOfBirth', '$nationality',  '$citizenship',  '$cell', '$eMail')
    ");

    $insertSuccessful = 'true';

    }

    if(isset($insertSuccessful)) {

    header("Location: to.php?whatever2= $MemberID");

    }

    ?>

    3 replies

    BenPleysier
    Community Expert
    Community Expert
    May 7, 2020

    Another happy email harvester:

    [Image removed]

     

    Wappler is the DMXzone-made Dreamweaver replacement and includes the best of their powerful extensions, as well as much more!
    Nancy OShea
    Community Expert
    Community Expert
    May 7, 2020

    Ben,

    The system is still broken.  Please report bad screen names in the Back Room under Needs a Name Change

    Adobe Staff will take it from there.

     

    Nancy O'Shea— Product User & Community Expert
    BenPleysier
    Community Expert
    Community Expert
    May 7, 2020

    Thanks, Nancy, have reported it.

    Wappler is the DMXzone-made Dreamweaver replacement and includes the best of their powerful extensions, as well as much more!
    Nancy OShea
    Community Expert
    Community Expert
    May 7, 2020

    It's impossible to say where your failure is occuring without some error reporting.

    Did you create the update script yourself?

     

     

    Nancy O'Shea— Product User & Community Expert
    Participating Frequently
    May 7, 2020

    yes i did, i realise my page is not passing the error to the user, instead it goes straight to the success page but does not actually load the data onto the database, this error all started when i had to switched to mysqi and had to use trigger-error,  because i loaded onto my live server and it kept refusing to continue  until i replaced mysqli_error() with trigger-error, here is the code below, please assist??

     

    if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "borrower_reg")) {
    $MemberID = $_POST['whatever2'];
    $insertSQL = sprintf("INSERT INTO borrower (Member_ID, Title, FName, LName, Identity_No, Date_Of_Birth, Nationality, Citizenship, Cell, Email, Dependants, Gender, Marital_Status, Spouse, M_Date, M_Place, M_Regime, S_Employer, S_Occupation, S_Workno, Residential, Postal, Employer, Emp_Address, Position, Emp_Since, Salary, Salary_Date, Emp_Tel, Emp_Type, Bank_Name, Account_Name, Account_Number, Account_Type, Branch_Name, Branch_Code, Password, RFName, RLName, RFAddress, RContact, RRelationsip) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
    GetSQLValueString($_POST['whatever2'], "text"),
    GetSQLValueString($_POST['Title'], "text"),
    GetSQLValueString($_POST['FName'], "text"),
    GetSQLValueString($_POST['LName'], "text"),
    GetSQLValueString($_POST['Identity_No'], "text"),
    GetSQLValueString($_POST['Date_Of_Birth'], "date"),
    GetSQLValueString($_POST['Nationality'], "text"),
    GetSQLValueString($_POST['Citizenship'], "text"),
    GetSQLValueString($_POST['Cell'], "text"),
    GetSQLValueString($_POST['eMail'], "text"),
    GetSQLValueString($_POST['Dependants'], "int"),
    GetSQLValueString($_POST['Gender'], "text"),
    GetSQLValueString($_POST['Marital'], "text"),
    GetSQLValueString($_POST['SpouseName'], "text"),
    GetSQLValueString($_POST['M_Date'], "date"),
    GetSQLValueString($_POST['M_Place'], "text"),
    GetSQLValueString($_POST['M_Regime'], "text"),
    GetSQLValueString($_POST['S_Employer'], "text"),
    GetSQLValueString($_POST['S_Occupation'], "text"),
    GetSQLValueString($_POST['SWorkno'], "text"),
    GetSQLValueString($_POST['Residential'], "text"),
    GetSQLValueString($_POST['Postal'], "text"),
    GetSQLValueString($_POST['employer'], "text"),
    GetSQLValueString($_POST['emp_address'], "text"),
    GetSQLValueString($_POST['position'], "text"),
    GetSQLValueString($_POST['emp_since'], "date"),
    GetSQLValueString($_POST['Salary'], "text"),
    GetSQLValueString($_POST['salary_date'], "text"),
    GetSQLValueString($_POST['emp_tel'], "text"),
    GetSQLValueString($_POST['Emp_Type'], "text"),
    GetSQLValueString($_POST['Bank_Name'], "text"),
    GetSQLValueString($_POST['Account_Name'], "text"),
    GetSQLValueString($_POST['Account_Number'], "text"),
    GetSQLValueString($_POST['Account_Type'], "text"),
    GetSQLValueString($_POST['Branch_Name'], "text"),
    GetSQLValueString($_POST['Branch_Code'], "text"),
    GetSQLValueString($_POST['psw'], "text"),
    GetSQLValueString($_POST['RFName'], "text"),
    GetSQLValueString($_POST['RLName'], "text"),
    GetSQLValueString($_POST['RAddress'], "text"),
    GetSQLValueString($_POST['RContact'], "text"),
    GetSQLValueString($_POST['RRelationship'], "text"));

    mysqli_select_db(dbconnect(), $database_connection1);
    $Result1 = mysqli_query(dbconnect(), $insertSQL) or trigger_error(dbconnect()->error."[$insertSQL]");

    header(sprintf("Location:to.php?whatever2= $MemberID"));}

    ?>

    Legend
    May 7, 2020

    'this error all started when i had to switched to mysqi'

     

    That code wont work with mysqli - its old outdated Deamweaver code, which you can't mix in with the new mysqli

    Community Expert
    May 7, 2020

    Without seeing the script we can only guess.  But what I would assume is happening is that your script is testing true but in fact, there is an error in your db query thus the DB query is failing, but the script is getting a result of true passed to it.

    Participating Frequently
    May 7, 2020

    yes indeed you are right, sorry about that, i realise my page is not passing the error to the user, instead it goes straight to the success page but does not actually load the data onto the database, this error all started when i had to switched to mysqi and had to use trigger-error,  because i loaded onto my live server and it kept refusing to continue  until i replaced mysqli_error() with trigger-error, here is the code below, please assist??

     

    if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "borrower_reg")) {
    $MemberID = $_POST['whatever2'];
    $insertSQL = sprintf("INSERT INTO borrower (Member_ID, Title, FName, LName, Identity_No, Date_Of_Birth, Nationality, Citizenship, Cell, Email, Dependants, Gender, Marital_Status, Spouse, M_Date, M_Place, M_Regime, S_Employer, S_Occupation, S_Workno, Residential, Postal, Employer, Emp_Address, Position, Emp_Since, Salary, Salary_Date, Emp_Tel, Emp_Type, Bank_Name, Account_Name, Account_Number, Account_Type, Branch_Name, Branch_Code, Password, RFName, RLName, RFAddress, RContact, RRelationsip) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
    GetSQLValueString($_POST['whatever2'], "text"),
    GetSQLValueString($_POST['Title'], "text"),
    GetSQLValueString($_POST['FName'], "text"),
    GetSQLValueString($_POST['LName'], "text"),
    GetSQLValueString($_POST['Identity_No'], "text"),
    GetSQLValueString($_POST['Date_Of_Birth'], "date"),
    GetSQLValueString($_POST['Nationality'], "text"),
    GetSQLValueString($_POST['Citizenship'], "text"),
    GetSQLValueString($_POST['Cell'], "text"),
    GetSQLValueString($_POST['eMail'], "text"),
    GetSQLValueString($_POST['Dependants'], "int"),
    GetSQLValueString($_POST['Gender'], "text"),
    GetSQLValueString($_POST['Marital'], "text"),
    GetSQLValueString($_POST['SpouseName'], "text"),
    GetSQLValueString($_POST['M_Date'], "date"),
    GetSQLValueString($_POST['M_Place'], "text"),
    GetSQLValueString($_POST['M_Regime'], "text"),
    GetSQLValueString($_POST['S_Employer'], "text"),
    GetSQLValueString($_POST['S_Occupation'], "text"),
    GetSQLValueString($_POST['SWorkno'], "text"),
    GetSQLValueString($_POST['Residential'], "text"),
    GetSQLValueString($_POST['Postal'], "text"),
    GetSQLValueString($_POST['employer'], "text"),
    GetSQLValueString($_POST['emp_address'], "text"),
    GetSQLValueString($_POST['position'], "text"),
    GetSQLValueString($_POST['emp_since'], "date"),
    GetSQLValueString($_POST['Salary'], "text"),
    GetSQLValueString($_POST['salary_date'], "text"),
    GetSQLValueString($_POST['emp_tel'], "text"),
    GetSQLValueString($_POST['Emp_Type'], "text"),
    GetSQLValueString($_POST['Bank_Name'], "text"),
    GetSQLValueString($_POST['Account_Name'], "text"),
    GetSQLValueString($_POST['Account_Number'], "text"),
    GetSQLValueString($_POST['Account_Type'], "text"),
    GetSQLValueString($_POST['Branch_Name'], "text"),
    GetSQLValueString($_POST['Branch_Code'], "text"),
    GetSQLValueString($_POST['psw'], "text"),
    GetSQLValueString($_POST['RFName'], "text"),
    GetSQLValueString($_POST['RLName'], "text"),
    GetSQLValueString($_POST['RAddress'], "text"),
    GetSQLValueString($_POST['RContact'], "text"),
    GetSQLValueString($_POST['RRelationship'], "text"));

    mysqli_select_db(dbconnect(), $database_connection1);
    $Result1 = mysqli_query(dbconnect(), $insertSQL) or trigger_error(dbconnect()->error."[$insertSQL]");

    header(sprintf("Location:to.php?whatever2= $MemberID"));}

    ?>