Jump to content

sjthetechguy

New Members
  • Posts

    5
  • Joined

  • Last visited

Everything posted by sjthetechguy

  1. Hi, I have this code which adds a record in databse. I have created a firms_edit.php and I am not sure what changes i make on this code which will edit the database entry using the id <?php include("./includes/functions_security.php"); include("./includes/functions_and_variables.php"); include("./includes/header-and-navigation.php"); ?> <div class="container-fluid"> <div class="row"> <div class="col-sm-12"> <div class="card"> <div class="card-header"> <h5>Add Firm</h5> </div> <form class="form theme-form" method="POST" action="" autocomplete="off"> <div class="card-body"> <div class="row"> <div class="col"> <div class="mb-3 row"> <label class="col-sm-3 col-form-label">Legal Business Name</label> <div class="col-sm-9"> <input class="form-control" type="text" name="addfirm_legal_name" required> </div> </div> <div class="mb-3 row"> <label class="col-sm-3 col-form-label">Business Name</label> <div class="col-sm-9"> <input class="form-control" type="text" name="addfirm_business_name" required> </div> </div> <div class="mb-3 row"> <label class="col-sm-3 col-form-label">Address</label> <div class="col-sm-9"> <input class="form-control" type="text" name="addfirm_address" required> </div> </div> <div class="mb-3 row"> <label class="col-sm-3 col-form-label">City</label> <div class="col-sm-9"> <input class="form-control" type="text" name="addfirm_city" required> </div> </div> <div class="mb-3 row"> <label class="col-sm-3 col-form-label">State</label> <div class="col-sm-9"> <input class="form-control" type="text" name="addfirm_state" required> </div> </div> <div class="mb-3 row"> <label class="col-sm-3 col-form-label">PIN</label> <div class="col-sm-9"> <input class="form-control" type="text" name="addfirm_pin" required> </div> </div> <div class="mb-3 row"> <label class="col-sm-3 col-form-label">Country</label> <div class="col-sm-9"> <input class="form-control" type="text" name="addfirm_country" required> </div> </div> <div class="mb-3 row"> <label class="col-sm-3 col-form-label">Phone</label> <div class="col-sm-9"> <input class="form-control" type="text" name="addfirm_phone" required> </div> </div> </div> </div> </div> <br> <div class="card-footer text-end"> <div class="col-sm-9 offset-sm-3"> <button class="btn btn-primary" type="submit" name="submitaddfirm">Submit</button> <input class="btn btn-light" type="reset" value="Cancel"> </div> </div> </form> </div> </div> </div> </div> <?php // 1. Below PHP code adds the firm to the database ?> <?php $addfirmsuccessfully_alert = ""; $addfirmunsuccessful_alert = ""; if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } // Check if the form is submitted if ($_SERVER["REQUEST_METHOD"] == "POST") { // Retrieve form data $addfirm_legalname = $_POST['addfirm_legal_name']; $addfirm_businessname = $_POST['addfirm_business_name']; $addfirm_address = $_POST['addfirm_address']; $addfirm_city = $_POST['addfirm_city']; $addfirm_state = $_POST['addfirm_state']; $addfirm_pin = $_POST['addfirm_pin']; $addfirm_country = $_POST['addfirm_country']; $addfirm_phone = $_POST['addfirm_phone']; // Prepare the SQL query $sqladdfirm = "INSERT INTO firms (firm_legalname, firmbusinessname, firmbusiness_addresss, firmbusiness_city, firmbusiness_state, firmbusiness_pin, firmbusiness_phone, firmbusiness_country) VALUES (?, ?, ?, ?, ?, ?, ?, ?)"; $stmtaddfirm = $conn->prepare($sqladdfirm); $stmtaddfirm->bind_param("ssssssss", $addfirm_legalname, $addfirm_businessname, $addfirm_address, $addfirm_city, $addfirm_state, $addfirm_pin, $addfirm_phone, $addfirm_country); // Execute the query if ($stmtaddfirm->execute()) { $addfirmsuccessfully_alert = "Firm added successfully"; } else { $addfirmunsuccessful_alert = "Error: " . $stmtaddfirm->error; } } ?> <?php include("./includes/footer.php"); include("./includes/scripts.php"); ?>
  2. Hi, lets say that I have a database table called clients and it has columns id, name, email I have another table called Projects which has databse records and it fetches the record from clients table to sselect client. After i have added the project record against the client. I can see that the Projects table has the data. Now, later on if i go to the client manager and i change the spelling or email address. I dont see any change of spelling name of client or email on the projects table. How to make it work, so that when i update something from a central place, everything everywhere gets updated?
  3. Hi, I have created a PHP dashboard backend application. I dont want any search engines or websites to index or display my internal php web application on their search results. How can I do that?
  4. Hi, I have this code, which is working ok to add an entry into the database. Need help with the following: 1.it also adds a empty record when i submit the form blank - whoich I dont want 2. I have 3 columns in table, id, offices and country. - I want the entry to be made into database if the offices doesnt already exist into the databse. <?php include("./functions.php"); include("../includes/header_internal.php"); include("../includes/sidebar_internal.php"); if ($_SERVER['REQUEST_METHOD']==='POST'){ $nameoffice = $_POST["officeinput"]; // Insert the data into the database $queryoffice = "INSERT INTO firmoffice (offices) VALUES ('$nameoffice')"; mysqli_query($conn, $queryoffice); } ?> <div class="page-body"> <br><br> <div class="card"> <div class="card-header"> <h5>Add Office</h5> </div> <form class="form theme-form" method="post" action="offices.php"> <div class="card-body"> <div class="row"> <div class="col"> <div class="mb-3 row"> <label class="col-sm-3 col-form-label">Office Name</label> <div class="col-sm-9"> <input class="form-control" type="text" name="officeinput"> </div> </div> <div class="card-footer text-end"> <div class="col-sm-9 offset-sm-3"> <button class="btn btn-primary" type="submit">Add Office</button> <input class="btn btn-light" type="reset" value="Cancel"> </div> </div> </form> </div> </div> <!-- Zero Configuration Starts--> <div class="col-sm-12"> <div class="card"> <div class="card-header pb-0 card-no-border"> <h3>Zero Configuration</h3><span>DataTables has most features enabled by default, so all you need to do to use it with your own tables is to call the construction function:<code>$().DataTable();</code>.</span><span>Searching, ordering and paging goodness will be immediately added to the table, as shown in this example.</span> </div> <div class="card-body"> <div class="table-responsive"> <table class="display" id="basic-1"> <thead> <tr> <th>Offices</th> <th>Country</th> </tr> </thead> <tbody> <tr> <td>Tiger Nixon</td> <td>System Architect</td> <td>Edinburgh</td> <td>61</td> <td>2011/04/25</td> <td>$320,800</td> <td> <ul class="action"> <li class="edit"> <a href="#"><i class="icon-pencil-alt"></i></a></li> <li class="delete"><a href="#"><i class="icon-trash"></i></a></li> </ul> </td> </tr> </tbody> </table> </div> </div> </div> <!-- Zero Configuration Ends--> <?php include("../includes/scripts.php"); include("../includes/footer_internal.php"); ?>
  5. Hi, I have this code written, when I input and submit the form, it doesnt post on the databse. Please note that the functions.php file already includes the database connection <?php include("./functions.php"); include("../includes/header_internal.php"); include("../includes/sidebar_internal.php"); ?> <div class="page-body"> <br><br> <div class="card"> <div class="card-header"> <h5>Add Office</h5> </div> <form class="form theme-form"> <form method="post" action="offices.php"> <div class="card-body"> <div class="row"> <div class="col"> <div class="mb-3 row"> <label class="col-sm-3 col-form-label">Office Name</label> <div class="col-sm-9"> <input class="form-control" type="text" name="officeinput"> </div> </div> <div class="card-footer text-end"> <div class="col-sm-9 offset-sm-3"> <button class="btn btn-primary" type="submit">Add Office</button> <input class="btn btn-light" type="reset" value="Cancel"> </div> </div> </form> </div> </div> <?php if (isset($_POST['submit'])) { include("../externalconnectors/database_variables/database_and_databse_tables.php"); $nameoffice = $_POST["officeunput"]; // Insert the data into the database $queryoffice = "INSERT INTO firmoffices (offices) VALUES ('$nameoffice')"; mysqli_query($conn, $queryoffice); } ?> <?php include("../includes/scripts.php"); include("../includes/footer_internal.php"); ?>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.