Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!
  • Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • You can also use markdown to share your code. When using markdown your code will be automatically converted to BBCode. For help with markdown check out the markdown guide.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.


    To learn more about how to use our BBCode feature, please click here.

    Thank you, Code Forum.

PHP Buttons does not work to submit or reset my data that needs to be saved

thehen

Coder
I have a php file that get my data from sql( it is getting the info), but when try so save new info or reset it does nothing when pressing the buttons, I have try a few ways, but can not win with this. I know my uppercase and lowercase for PHP is not correct, will fix it later.

PHP:
<?php include_once 'header.php'?>

<?php

    $mes="";
        
    if(isset($_GET['mes'])){
        
        $mes=$_GET["mes"];
    }

    $sql = mysqli_query($pdo,"SELECT * FROM api_currency ");

    $row = mysqli_fetch_array($sql);

    do{

        $NOMICS_API  = $row['NOMICS_API']; 
        $COINGECKO_API  = $row['COINGECKO_API'];
        $COINMARKETCAP_API  = $row['COINMARKETCAP_API'];
        $CURRENCY_API  = $row['CURRENCY_API'];
        $CONVERT_TO  = $row['CONVERT_TO'];

    }while($row = mysqli_fetch_array($sql));

  
    // Parse the form data and add inventory item to the system
    if (isset($_POST['submit'])) {
        
        $NOMICS_API  = $_POST['NOMICS_API'];
        $COINGECKO_API  = $_POST['COINGECKO_API'];
        $COINMARKETCAP_API  = $_POST['COINMARKETCAP_API'];
        $CURRENCY_API  = $_POST['CURRENCY_API'];
        $CONVERT_TO  = $_POST['CONVERT_TO'];

        $sql = mysqli_query($pdo,"UPDATE api_currency SET NOMICS_API ='$NOMICS_API', COINGECKO_API ='$COINGECKO_API',
        COINMARKETCAP_API ='$COINMARKETCAP_API', CURRENCY_API ='$CURRENCY_API', CONVERT_TO ='$CONVERT_TO' WHERE ID = '1' ");
    
        header("location: api&currency.php?mes=2");
 
    }
    
    function do_alert($msg){
        echo '<script type="text/javascript">alert("' . $msg . '"); </script>';
    }


    if($mes==2){
        do_alert("Suksesvol bygevoeg");
    }
  

 ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
?>
HTML:
<style>
button,
[type=button],
[type=reset],
[type=submit] {
  -webkit-appearance: button;
}
button:not(:disabled),
[type=button]:not(:disabled),
[type=reset]:not(:disabled),
[type=submit]:not(:disabled) {
  cursor: pointer;
}
</style>
  <html>
  <body>
<div class="wrapper"> 
<div class="content-wrapper">
<section class="content">         
    <div class="content-header">
        <div class="container-fluid">
            <div class="row mb-2">
                <span class="info-box-icon bg-info elevation-1">
                    <iconify-icon icon="wpf:administrator" height="48" style="color: #FF0000"></span>
                        <div class="col-sm-6">
                            <h1 class="mb-2">API & Geldeenheid Opstelling</h1>
                                <p>Verskaf asseblief Vereiste veld (*)</p>
                        </div><!-- /.col -->
          
            </div><!-- /.row -->
        </div><!-- /.container-fluid -->
    </div>
        
    <div class="card-body">       
        <div class="form-group">
            <label for="exampleInputRounded0">Nomics API </label>
                <input type="text" name="NOMICS_API" class="form-control rounded-pill" id="exampleInputBorder" placeholder=".rounded-0" value="<?php echo $NOMICS_API; ?>" required /> 
        </div>
        <div class="form-group">
            <label for="exampleInputRounded0">Coingrecko API </label>
                <input type="text" name="COINGECKO_API" class="form-control rounded-pill" id="exampleInputBorder" placeholder=".rounded-0" value="<?php echo $COINGECKO_API; ?>" required /> 
        </div>
        <div class="form-group">
            <label for="exampleInputRounded0">CoinMarketCap API </label>
                <input type="text" name="COINMARKETCAP_API" class="form-control rounded-pill" id="exampleInputBorder" placeholder=".rounded-0" value="<?php echo $COINMARKETCAP_API; ?>" required /> 
        </div>
        <div class="form-group">
            <label for="exampleInputRounded0">Wisselkoers API(Geldeenheid)</label>
                <input type="text" name="CURRENCY_API" class="form-control rounded-pill" id="exampleInputBorder" placeholder=".rounded-0" value="<?php echo $CURRENCY_API; ?>" required /> 
        </div>
        <div class="form-group">
            <label for="exampleInputRounded0">Skakel om na</label>
                <input type="text" name="CONVERT_TO" class="form-control rounded-pill" id="exampleInputBorder" placeholder=".rounded-0" value="<?php echo $CONVERT_TO; ?>" required /> 
        </div>
    </div>       

        <div class="row mb-2">
            <div class="user-panel mt-3 pb-3 mb-3 d-flex">
                <button type="button" name="submit" style="margin:35px" class="btn btn-block btn-outline-success btn-lg">Dien in</button>
                </div>
                
                <div class="user-panel mt-3 pb-3 mb-3 d-flex">
                <button type="reset" style="margin:35px" position="relative" class="btn btn-block btn-outline-danger btn-lg">Herstel</button>
            </div>
        </div>
        
</section>   
 </div>
 </div>
JavaScript:
<script>
            jQuery(document).ready(function(){
                
                jQuery('#basicTable').DataTable({
                    responsive: true
                });
                
                var shTable = jQuery('#shTable').DataTable({
                    "fnDrawCallback": function(oSettings) {
                        jQuery('#shTable_paginate ul').addClass('pagination-active-dark');
                    },
                    responsive: true
                });
                
                // Show/Hide Columns Dropdown
                jQuery('#shCol').click(function(event){
                    event.stopPropagation();
                });
                
                jQuery('#shCol input').on('click', function() {

                    // Get the column API object
                    var column = shTable.column($(this).val());
 
                    // Toggle the visibility
                    if ($(this).is(':checked'))
                        column.visible(true);
                    else
                        column.visible(false);
                });
                
                var exRowTable = jQuery('#exRowTable').DataTable({
                    responsive: true,
                    "fnDrawCallback": function(oSettings) {
                        jQuery('#exRowTable_paginate ul').addClass('pagination-active-success');
                    },
                    "ajax": "ajax/objects.txt",
                    "columns": [
                        {
                            "class":          'details-control',
                            "orderable":      false,
                            "data":           null,
                            "defaultContent": ''
                        },
                        { "data": "name" },
                        { "data": "position" },
                        { "data": "office" },
                        { "data": "salary" }
                    ],
                    "order": [[1, 'asc']]
                });
                
                // Add event listener for opening and closing details
                jQuery('#exRowTable tbody').on('click', 'td.details-control', function () {
                    var tr = $(this).closest('tr');
                    var row = exRowTable.row( tr );
            
                    if ( row.child.isShown() ) {
                        // This row is already open - close it
                        row.child.hide();
                        tr.removeClass('shown');
                    }
                    else {
                        // Open this row
                        row.child( format(row.data()) ).show();
                        tr.addClass('shown');
                    }
                });
              
                
                // DataTables Length to Select2
                jQuery('div.dataTables_length select').removeClass('form-control input-sm');
                jQuery('div.dataTables_length select').css({width: '60px'});
                jQuery('div.dataTables_length select').select2({
                    minimumResultsForSearch: -1
                });
    
            });
            
            function format (d) {
                // `d` is the original data object for the row
                return '<table class="table table-bordered nomargin">'+
                    '<tr>'+
                        '<td>Full name:</td>'+
                        '<td>'+d.name+'</td>'+
                    '</tr>'+
                    '<tr>'+
                        '<td>Extension number:</td>'+
                        '<td>'+d.extn+'</td>'+
                    '</tr>'+
                    '<tr>'+
                        '<td>Extra info:</td>'+
                        '<td>And any further details here (images etc)...</td>'+
                    '</tr>'+
                '</table>';
            }
        </script>
        
        
      

        
        
        <script>
            jQuery(document).ready(function(){
              
                // Basic Form
                jQuery("#basicForm").validate({
                    highlight: function(element) {
                        jQuery(element).closest('.form-group').removeClass('has-success').addClass('has-error');
                    },
                    success: function(element) {
                        jQuery(element).closest('.form-group').removeClass('has-error');
                    }
                });
              
                // Error Message In One Container
                jQuery("#basicForm2").validate({
                    errorLabelContainer: jQuery("#basicForm2 div.errorForm")
                });
              
                // With Checkboxes and Radio Buttons
                
                jQuery('#genderError').attr('for','gender');
                jQuery('#intError').attr('for','int[]');
                
                jQuery("#basicForm3").validate({
                    highlight: function(element) {
                        jQuery(element).closest('.form-group').removeClass('has-success').addClass('has-error');
                    },
                    success: function(element) {
                        jQuery(element).closest('.form-group').removeClass('has-error');
                    }
                });
                
                jQuery("#basicForm4").validate({
                    highlight: function(element) {
                        jQuery(element).closest('.form-group').removeClass('has-success').addClass('has-error');
                    },
                    success: function(element) {
                        jQuery(element).closest('.form-group').removeClass('has-error');
                    },
                    ignore: null
                });
                
                // Validation with select boxes
                jQuery("#flowers, #fruits").select2({
                    minimumResultsForSearch: -1
                });
              
            });
        </script>

    </body>
</html>
<?php include_once 'footer.php'?>
 

Attachments

  • api&currency.zip
    2.7 KB · Views: 0
The submit and reset buttons work inside a form, not a section. Bad HTML code.
I am not going to wade through the jquery to see if you are trying to collect the data and send it via ajax. Are you?
 

New Threads

Latest posts

Buy us a coffee!

Back
Top Bottom