PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Sunday, January 23, 2022

[FIXED] Codeigniter add attribute to open_form_multipart

 January 23, 2022     codeigniter, database, forms, php     No comments   

Issue

We have a form that adds products to our database. We have here in a open_form_multipart for the images. We think that the problem is that it doesn't add our attributes.

error:

Error Number: 1048

Column 'product_foto' cannot be null

INSERT INTO products (product_naam, product_beschrijving, product_categorie, ophaal_plaats, product_foto, date_created, date_updated) VALUES ('', '', '', '', NULL, '2017-06-20', '2017-06-20')

Filename: models/Product_model.php

Line Number: 9

our code is in the view:

<?php
echo $this->session->flashdata('msg');
echo form_open_multipart('name="product_foto"');
echo form_upload('file');
echo form_submit('upload', 'Upload');
?>

Solution

You need to follow conventions for defining form.

Documentation

Your code should be:

$arr = array('name' => 'product_foto');
echo form_open_multipart('', $arr);

form_open_multipart([$action = ''[, $attributes = array()[, $hidden = array()]]])

Parameters:

$action (string) – Form action/target URI

string $attributes (array) – HTML attributes

$hidden (array) – An array of hidden fields’ definitions Returns: An HTML multipart form opening tag

Return type: string

Note: Action is set blank so that the the form will submit to the same page.



Answered By - Pupil
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing