logo
down
shadow

How do I insert into table form data with user id in laravel?


How do I insert into table form data with user id in laravel?

By : user2950745
Date : November 17 2020, 11:58 AM
it fixes the issue You can always get the current authenticated user by Auth::user(). And you can also modify the $data array before passing it to create. Here's how you do it:
code :
$data['author_id'] = Auth::user()->id;
News::create($data);
protected $fillable = array('title', 'body', 'author_id);


Share : facebook icon twitter icon
How to use INSERT...SELECT to insert data form one table to another based on form input

How to use INSERT...SELECT to insert data form one table to another based on form input


By : user3470782
Date : March 29 2020, 07:55 AM
hop of those help? I have situation when i want to add data from column formCompany, formPlace in tabel1 based on input from form into table2 column formCompany, formPlace. Something like this: , First off
Fix the SQL injection hole
code :
$formCompany = mysql_real_escape_string($_POST['formCompany']);
$formPlace = mysql_real_escape_string($_POST['formPlace']);
$formOffer = mysql_real_escape_string($_POST['formOffer']);
$sql="INSERT INTO table2  
      (formCompany, formPlace, formOffer) 
      SELECT table1.formCompany, table1.formPlace, '$formOffer' "
        //All insertions happen here ^^^^^^^^^^^^^^^^^^
      ." FROM table1 
        WHERE formCompany LIKE '%$formCompany%' 
          AND formPlace LIKE '%$formPlace%' ";
How to insert a field of data in mysql from another table, based from user input from a form?

How to insert a field of data in mysql from another table, based from user input from a form?


By : Rafal Stapinski
Date : March 29 2020, 07:55 AM
fixed the issue. Will look into that further I am developing a system in which people can be added to a database using mysql and php. The basis of my form is that an administrator can add person-types and person-roles, and these are applied to the user when their details are entered in the form. For example, if this system was applied to a school environment the person type could be a teacher, or a cook, and the person role could be a parent, for the person type does not exclude the person role. I have had various problems with this system for that the foreign keys don't update as my system uses MYISAM type tables, but if I use INNODB tables my data entry will not work. I am seeking ways in which I can use queries for the meantime to get this working as it is for a university project, and my deadline is ever looming. However I do mean to get this system working, so will seek ways to get it fully functioning a bit later in the year. I have javascript in place for error handling, and php blocks of code to help prevent against sql injection attacks. , I think the problem is here
code :
// drawing the information from the Person_Type table.
$sql9 = "(SELECT Person_Type_ID
             FROM Person_Type pt
            WHERE pt.Person_Type_Value_Description =  $Person_Type_Value_Description)";
$result = @mysql_query($sql9);

//inserting into the person table. **All filed work except for the Person_Type_ID
$qry = "INSERT INTO Person 
    (Person_Type_ID, Create_Date, Modify_Date, First_Name, Surname, DOB, Gender,
     Allergies, Dietry_Requirements, Disabilities, Medicine_Requirements, 
     username,password) 
  VALUES('$sql9', NOW(), NOW(), '$First_Name', '$Surname', '$DOB', '$Gender', 
    '$Allergies', '$Dietry_Requirements', '$Disabilities', '$Medicine_Requirements', 
    '$username', '$password')" ;
$result = @mysql_query($qry);
$result = @mysql_query($sql9);
$row = mysql_fetch_assoc( $result );
$personTypeID = intval( $row['Person_Type_ID'] );

//inserting into the person table. **All filed work except for the Person_Type_ID
$qry = "INSERT INTO Person 
    (Person_Type_ID, Create_Date, Modify_Date, First_Name, Surname, DOB, Gender,
     Allergies, Dietry_Requirements, Disabilities, Medicine_Requirements, 
     username,password) 
  VALUES($personTypeID etc.
simple form submit by ajax in laravel and after, insert new row into existing table with data from submited form

simple form submit by ajax in laravel and after, insert new row into existing table with data from submited form


By : user2640632
Date : March 29 2020, 07:55 AM
I hope this helps you . First off, you need to return the data you just saved from your controller. You can use Laravels Response::json() for that.
code :
public function newClient(){
    if(Request::ajax()){
        // ....

        return Response::json($client);
    }
}
$.ajax({
    url:url,
    data:form.serialize(),
    type: 'POST',
    dataType: "json",
    success: function(data){
        console.log(data); // json of your laravel model
        console.log('Num: ', data.num); // access property
    }
});
Symfony 3.3 Insert user info into table along form data

Symfony 3.3 Insert user info into table along form data


By : shiming Mo
Date : March 29 2020, 07:55 AM
hop of those help? I wanted to actually insert user_id into database table without showing any options on the form, I have done this in the following manner.
code :
if ($form->isSubmitted() && $form->isValid()) {
        $em = $this->getDoctrine()->getManager();
        $user = $this->container->get('security.token_storage')->getToken()->getUser();
        $em->persist($brand);
        $brand->setUserId($user);
        $em->flush();
/* */
    }
How to insert data into two table by using one form in laravel

How to insert data into two table by using one form in laravel


By : user2022749
Date : March 29 2020, 07:55 AM
it should still fix some issue There are severals ways of inserting data into multiple tables, if you have relationship between user_info and doctor_info table you can use sync method:
code :
$user_info->doctorInfo()->sync([1, 2, 3]);
$user_info->doctorInfo()->save($data);
Related Posts Related Posts :
  • php curl headers do not return from website?
  • How to find out, if facebook ID is a user, group or page
  • Connect webhost database to android database
  • preg_match get div content with class
  • Upload multiple files in Laravel 4
  • Count array numbers in multidimensional array
  • PHP Date diff with a difference
  • Search Customer by custom field in Netsuite
  • Is it possible to hide/encode/encrypt php source code and let others have the system?
  • list items to be displayed using php code and array
  • check if row exists mysqli
  • PHP errors loading MySQL
  • setup PostgreSQL with Laravel in MAMP
  • PHP - CodeIgniter Notifications
  • Encrypting a password column in a SQL database
  • New to PHP, trying to extract information from another website
  • JavaScript AmChart to Image for Email
  • Is javascript validation enough to keep my forms secure?
  • Regex extract variables from [shortcode]
  • Download a .mp3 link and save it to computer with PHP
  • Error with the ereg_replace
  • Getting the fields attached to a bundle of an entity in Drupal
  • Php how to check multiple times (within `foreach`) if values from array exists in mysql?
  • MySQL and PHP parsing strange string
  • Pull specific data from multidimensional associative array
  • How to get the original URI extension using PHP Tonic?
  • Upload videos and images from Android to PHP server?
  • Unset a multidimensional array with another multidimensional array with values than key
  • Calling a user e-mail to add to a mailto link PHP
  • Why is override_function coming back as an undefined function
  • PHP mySQLi_fetch_all: iterate through each row
  • Using pow in php
  • What's wrong with my PHP Script? T_String issue
  • how to call a function of another file without including that file
  • is_rgb function in php
  • transform the numbers to letters using php
  • How to catch an exception from another class method PHP
  • PHP exec is blocked by ISP
  • PHP4 to PHP5 migration character encoding. latin1 vs utf8
  • Begin Transaction not defined
  • How much harm can a user do with xss on a page unique to them?
  • How to import data from a php file to javascript variable
  • PHP and Javascript - log complete workflow
  • When I echo !!! 0 it gives me a strange result
  • jquery ajax post dies after submit
  • How to upload file with curl on sftp server
  • Advanced search using a text input to search through only one category
  • Why do I get "Non-static method App\Models\Category::products() should not be called statically" in laravel
  • Stop notices from undefined indexes in arrays
  • PHP Excel Error when entering SUM function to a cell
  • laravel 4 eloquent eager load relation count
  • click submit in html and run php code
  • Extremely frustrating behavior with Internet Explorer, Bootstrap and Respond.js
  • Vkontakte vtag issues
  • Divide the number to a correct decimal
  • mysqli_insert_query not working
  • How to make a sitemap using zend framework 1
  • Laravel: array to Model with relationship tree
  • $_SERVER['DOCUMENT_ROOT'] vs $path = $_SERVER['DOCUMENT_ROOT']
  • What is the best way to store multiple checkbox values in the database and work with it later on
  • shadow
    Privacy Policy - Terms - Contact Us © ourworld-yourmove.org