Latest Web Development Posts

Dani 1,760

You might be familiar with the dreaded blank page when your PHP script doesn't work.

Here's how to spit out errors to the screen, instead of getting just a blank page, as well as logging errors to a file.

Dani 1,760

There are two ways to write to a file in PHP. You can either open a stream, and write to it in parts, or you can use file_put_contents() which is much more convenient, with the trade off being that it takes up much more memory, and is not ideal if you want to send a lot of data upstream.

Dani 1,760

If you need your PHP script to redirect to a different website, you can send an HTTP header to do that.

Remember, header() must be called before any actual output is sent, which includes not just HTML, but blank lines, etc.. as well.

Hello Frds,

select box option add new state in add.already same state in condition check already exist using php pdo.please help me.

Why do people answer the question seven years ago?

$days_ago = date('Y-m-d', strtotime('-15 days', strtotime(date('Y-m-d'))));

Dani 1,760

This code dynamically generates a clear 1x1 pixel.

Hello to you all.

I want to import an excel with four spreadsheets into 4 grid views.
So far so good.
But I also wan the grid view on load to check if the line values already exist on the database.

What's the best apprach to add this collumn to the grid view?

Regards,

RL

Hi,

I have a form which consists a dynamic dependent dropdown and I want to maintain the entered data into the fields after the form is saved or edited.

For an example:
<input type="text" name="serial" value="<?php echo $serial;?>">

Similary i need to get the value in my dropdown as well. Hope there is a solution for this. Below is my code.

ajax.js
$(document).ready(function() {
    $("#brand").change(function() {
    var Brand_ID = $(this).val();
    if(Brand_ID != "") {
      $.ajax({
        url:"SR.php",
        data:{b_id:Brand_ID},
        type:'POST',
        success:function(response) {
          var resp = $.trim(response);
          $("#model").html(resp);
        }
      });
    } else {
      $("#model").html("<option value=''>----Select Model----</option>");
    }
  });
});
Dropdown
    $Connection = mysqli_connect('localhost','root','','sris');

<form class="form-horizontal style-form" action="update.php" method="post">
<div class="form-group">
        <label class="col-sm-2 control-label">Brand</label>
    <div class="col-sm-4">
        <select name="Brand" id="brand" class="form-control" value="<?php echo $Brand; ?>" >
                        <option value=''>----Select Brand----</option>
                          <?php 
                                $sql = "select * from brand";
                                    $res = mysqli_query($Connection, $sql);
                                        if(mysqli_num_rows($res) > 0) {
                                    while($row = mysqli_fetch_object($res)) {
                                        echo "<option value='".$row->ID."'>".$row->Name."</option>";
                                    }
                                }
                            ?>
        </select>
    </div>

        <label class="col-sm-2 control-label">Model</label>
    <div class="col-sm-4">
        <select name="Model" id="model" class="form-control" value="<?php echo $Model; ?>" >
            <option>----Select Model----</option></select>
                <?php
                if(isset($_POST['b_id'])) {
                  $sql = "select * from model where Brand_ID =".mysqli_real_escape_string($Connection, $_POST['b_id']);
                  $res = mysqli_query($Connection, $sql);
                  if(mysqli_num_rows($res) > 0) {
                    echo "<option value=''>----Select Model----</option>";
                    while($row = mysqli_fetch_object($res)) {
                      echo "<option value='".$row->ID."'>".$row->Name."</option>";
                    }
                  }
                  exit();
                }
                ?>
    </div>
</div>
</form>

Yep,create your own website and start publishing it.

Dani 1,760

Sorry I'm confused by your question.

You created four select boxes: one asking to select state, one district, one city, one town. You want to change the other three each time you change the state select box, is this correct?

I think what you're asking is similar to what we do at https://www.daniweb.com/community/contribute where, based on the forum selected, the topic types change. For example, if you select a programming forum, posting a code snippet is an option, but if you select a hardware forum, for example, a code snippet is no longer an option.

Do you have any experience with jQuery? I see you tagged this thread AJAX. Are you needing to retrieve the items from the select box dynamically or can the list of all possible combinations exist in the JS file?

NodeJS & MYSQL are the BackEnd part or processing part of the App

white ReactJS provide the Front End or View part to the App. To integrate all these, best way is to create API with NodeJS+MySQL and use it in the ReactJS app

I wront a similar answer at hashnode: https://hashnode.com/post/how-can-use-react-js-node-js-mysql-together-cjdlfbukh01vqn9wuaucmng6h/answer/cjdlqtr05033l6iwtmbzubiok where I explained how to use these all together.

You above script is good, but it dones all operations i.e. CRUD at onces. To make it useable from Front end, you need to make API endpoints like /posts, /posts/100, /users, /users/pankaj etc. And then respond as per the request.

Have you set the redirect-url correctly while setting up the payment gateway? as you mentioned 404, that means CCAvenue sent you successful payment response but is not under your control or something not defined.

I would recommend to use https://github.com/kishanio/CCAvenue-PHP-Library

Here in this library;

$ccavenue = new CCAvenueClient( '<merchant_id>', '<working_key>', '<redirect_url>' );

redirect_url should be the URL of your ccAvenueResponseHandler.php

Simplest way to use svg fime in HTML is to use it with img[src] tag likea regular Image.

If you wanna go advanced, you can paste the SVG code as well in the HTML (except the xml namespace part) and style with CSS; as almost all the components of SVG are CSS designable.

The use case with div; you can put the SVG as baackground-image and control the size by background-size and other related CSS properties.

Have you tried Postman, the collections are the cool way to organize API endpoints and provide a testing way.

It can also be your API testing tool

https://learning.getpostman.com/docs/postman/collections/creating_collections

Hai Frds,

My question is i have create select box using state,district,city and town.select state box click add option select box change text box add/edit in text box add tha value save in state select box. How do please help me

Many online compilers and such block the app from doing much more than basic operations. You should put this on a real server that you know can access the URL from. Also, you need to vardump() the variables on the reticent line if you can't see why it's doing that.

Here is my code :

https://paiza.io/projects/SUiG5qp_wttfcrQn-0Mwew?language=php FYI -> [index.htm -> LineNo : 781 & 782]

After successfully received payment response page return 404 error

The form & CC-Avenue Payment Gateway Request page working good, after customer paid the response page return 404 error.

How can i solve the error?

i have below code and i need to addd close button (x) on popover for each three popovers ,can any one help me how to do this

<div class="row">
            @*<div class="col-lg-1 popper" title="Note" data_toggle="popover">sdsda*@
            <div class="col-lg-1">
                <i class="ShowToolTip popper fa fa-eye LabTaskClass28  LabTaskClassforShowHideCol77"   title="No task result for note"  data_toggle="popover" style="/*! width: 1px !important; */"><span class="close-popover float-right text-danger "></span></i>
                <div class="popper-content" style="display:none">
                    <div class="form-group">
                        <label title="Task name">Task name
                        </label>
                            <input type="text"
                                   class="form-control">

                        <label title="Message">
                          Message
                        </label>
                        <input type="text"
                               class="form-control" placeholder="Limited to 100 Characters">
                        <button class="btn-save btn btn-primary btn-sm" style="background-color:maroon !important">Close</button>
                        <button class="btn-save btn btn-primary btn-sm" style="background-color:darkslategrey !important">SAve</button>
                    </div>
                    <button type="submit" class="btn btn-default btn-block">
                        Submit
                    </button>
                </div></div>

            <div class="col-lg-1">
                <i class="ShowToolTip popper fa fa-eye LabTaskClass28 LabTaskClassforShowHideCol77" title="No task result for review" data_toggle="popover" style="/*! width: 1px !important; */"></i>
                @*<div class="popper-content" style="display:none">My Review popover content goes here.</div>*@
                <div class="popper-content" style="display:none">
                    <div class="form-group">
                        <label title="Task name">
                            Task name
                        </label>
                        <input type="text"
                               class="form-control">

                        <label title="Message">
                            Messagessd
                        </label>
                        <input type="text"
                               class="form-control" placeholder="Limited to 100 Characters">
                        <button class="btn-save btn btn-primary btn-sm" style="background-color:maroon !important">Close</button>
                        <button class="btn-save btn btn-primary btn-sm" style="background-color:darkslategrey !important">SAve</button>
                    </div>
                    <button type="submit" class="btn btn-default btn-block">
                        Submit
                    </button>
                </div>

            </div>

            <div class="col-lg-1">
                <i class="ShowToolTip popper fa fa-eye LabTaskClass28 LabTaskClassforShowHideCol77" title="Warning" data_toggle="popover" style="/*! width: 1px !important; */"></i>
                @*<div class="popper-content" style="display:none">My Review popover content goes here.</div>*@
                <div class="popper-content" style="display:none">
                    <div class="form-group">
                        <label title="">
                            Task not complete yet to repeat
                        </label>
                        <button class="btn-save btn btn-primary btn-sm" style="background-color:maroon !important">Close</button>

                    </div>

                </div>

            </div>
                </div>

Firstly, You have to understand your target audience.
Secondly, You have to create your Website as well.
Thirdly, You need to create an images of your products to showcase your target audience.

Thanks. Hopefully it will help you:)

In your HTML code <table> not opened, table row <tr> not opened, invalid <input> tag without > - it should be something like

if($result->num_rows > 0){
    echo '<table>';
    while ($row6 = $result->fetch_assoc()){
        //table code//
        echo '<tr>';
        echo '<td><input type="checkbox"  name="check[]" value="'.$cato.'" /></td>';
        echo '</tr>';
    }
    echo '</table>';
}

PHP code $cat better use filtered variable

$cat = filter_input(
    INPUT_POST
    ,'check'
    ,FILTER_VALIDATE_INT
    ,FILTER_REQUIRE_ARRAY
);

other variables also filtered eg

$price = filter_input(INPUT_POST,'price',FILTER_SANITIZE_STRING);
$pickup_date = filter_input(INPUT_POST,'pickup_date',FILTER_SANITIZE_STRING);
...

Do not pass user input variables direct to SQL query - its a potential SQL injection risk! Use prepared statement instead - prepare, bind_param, execute - read manual MySQLi bind param or PDO bind param

jack98 commented: thanks for responding, really appreciate it. :) +0

i have manage to insert my checkbox array data into database. the problem is when i check multiple checkbox only the first data in array is inserted in database. i need when i check multiple checkbox, all the data i have check insert into database.can someone help me?

this is my php code:

    <?php

    include ('connect.php');

 $cat = implode(',', $_POST['check']);

 if(isset($_POST['submit']))
  {

    for($i=0; $i<count($cat);$i++)
{
$p_id =$_GET ['sitter'];
$price = $_POST ['price'];
$pickup_date =$_POST ['pickup_date'];
$dropoff_date =$_POST ['dropoff_date'];
$numdays = $_POST ['numdays'];
$total =$_POST ['test'];

$sql2 = "INSERT INTO cat_sitter(sitter_fk,cat_fk, price, date_in, date_out,total_day, total)VALUES ('$p_id','" . $cat[$i] . "','$price','$pickup_date','$dropoff_date','$numdays', '$total')" or die ("Error inserting data into table");

if ($conn->query($sql2) === TRUE) {
    echo "<script language='javascript'>alert('Succesfully Book.')
        window.location.replace(\"book_page.php\");
    </script>";
}else{

    echo "error: " . $sql2 . "<br>" . $conn->error;
 }
 }
          }
     ?>

this is my html code:

<?php
      include ('connect.php');

   $sql = "SELECT cat_id,name,gender,health_status,neutered,breed,color,age FROM cat WHERE owner_fk = '$id'";
  $result3 = mysqli_query($conn,$sql);
  $row6 = mysqli_fetch_array($result3);
  $cato = $row6['cat_id'];
  $result = $conn-> query($sql);

     if ($result-> num_rows > 0) {
     while ($row6 = $result-> fetch_assoc()) {

        //table code//

       echo "<td>" ."<input type='checkbox'  name= 'check[]' value='$cato'". "</td>";
       echo "</tr>";
     }
       echo "</table>";
    }
     else{
     echo "0 result";
    }
      $conn-> close();

     ?>

Is that it? No code? Show your relevant code and on which does this happen.

Parse error: syntax error, unexpected '||' (T_BOOLEAN_OR) in php pdo

U can use BrowserSync with GulpJS it's very clean and nice tool

I see no line 36. Also line 16 looks suspect. Is it "Forgor" on purpose?

Im using MongoDB with PHP. Im making a check user exist using their email.It can be check, but when I enter the existing user and click the confirm button, it display the 'echo' and also display an error about converted document to int. Below is what the error say and my code.

ERROR
Fatal error: Uncaught Error: Call to a member function count() on null in C:\xampp\htdocs\project\OrgChart-master\OrgChart-master\resetPasswordSuccess.php:36 Stack trace: #0 {main} thrown in C:\xampp\htdocs\project\OrgChart-master\OrgChart-master\resetPasswordSuccess.php on line 36

CODE

<!-- MongoDB Conn With Email Check Function V1 (FUNCTIONING) -->
<!--Line 36 is at if($result==0)-->

<?php
        if(isset($_POST['registration']))
        {
            $registration = ($_POST['registration']);

            if(!empty($registration))
            {                
                $result = $db->collection1->findOne(array("registration"=>$registration));
                //print_r($result);
                if($result->count()==1)
                {
                    echo "Please Enter The Correct Username";
                    header('location: memberForgorPassword.php');
                    return false;
                }
                else if($result->count()==0)
                {
                    echo "Username Exist In Database";
                    header('location: resetPasswordSuccess.php');
                    return true;
                }
            }
        }
?>

Can you try framing that question again please as it doesn't make much sense as is I'm afraid?

already this phone number registration in alert msg how to display in php and mysql

I have couple of shipping methods DHL & FedEx, if selected products exits in cart show only selected shipping method, how to archive using shopping cart pricing rule or any other way to do this?