How can I utilize overly-violent PCs for character development / progressing the story?

I’m fairly new to D&D and especially DMing. I’ve started a new campaign with 2-3 people and more may be joining soon, which might make this question entirely useless to ask if the new players behave differently. The current players are more prone to violence than I was expecting. Two of the three choose violence over all other options most of the time.

I home brewed an open-world map with some complex characters and motives for them to explore, as well as an ongoing civil war, all wrapped into a post-magic-apocalyptic environment. What this means is that violence isn’t necessarily NOT the answer, it just makes the game boring as a DM to have all your NPCs hacked and slashed to bits by a goliath and barbarian who are more interested in combat than storytelling.

One example is they tried to attack a shop keeper to steal his flintlock pistol that they can’t afford to purchase. Luckily the bard of our group had just joined the game, and since I had already explained that this shop keeper was an ex-member of a mercenary group, he held his own until the bard could cast a spell to befriend the shopkeeper and stop the fighting. Luckily the bard player has DM’d for previous campaigns and has more experience with D&D, so he knows to not attack shopkeepers and perhaps takes the game more seriously.

Violence seems to be the option they’re most prone to choosing. While I don’t want to power-game them into a corner by making guards constantly spot them, or make the shop keepers over-powered warriors, how can I help guide them towards choosing alternative solutions to problems that don’t involve killing everything in their path?

  1. Should I have a discussion with them out of game about their characters actions (not ideal)?

  2. What type of scenarios can I place them in to potentially develop their characters away from that?

  3. Or, is this all a non-issue and I should just let them make their mistakes and get slaughtered / outlawed?

    I told them they could do whatever they want and this would be an open-world campaign.

Best way of writing PHP, progressing & acquiring simple inputs & outputs

As my first simple PHP project, I’ve created a simple project that allows you to just enter your name and two numbers, where it displays them on the page and stores them in a database. It consists of 3 files: index.php, db.php & process.php. I wonder whether I have created the code efficiently.

I’m curious about all the talk behind procedural PHP vs PDO. I initially used some deprecated PHP5 functions and was corrected by the stack overflow community, but this has left me confused as to what specifically I should learn with PHP as a beginner. It sounds like procedural and PDO are very different, and that I should only pick one and learn that.

So my questions are as follows:

  1. Is the coding in my project acceptable?
  2. Is it similar to how most PHP projects are built? (i.e. are most procedural or PDO)
  3. What should I learn as a beginner? (procedural or PDO?)
  4. Do you have any beginner advice?

Any advice here would be very much appreciated as I’m new to PHP. Thanks for any help here. The files and code (excluding HTML & CSS) are below:

index.php:

<?php include 'db.php'; ?>  <?php // Fetch data from db $  query = mysqli_query($  con, 'SELECT * FROM data'); ?>  <!-- create a loop (while there are results in the DB, spit them out) -->             <?php while ($  row = $  query->fetch_assoc()) : ?>                 <li><?php echo $  row['t_name'] ?> entered <?php echo $  row['t_firstNo'] ?> and <?php echo $  row['t_secondNo'] ?> (result =                      <?php                         $  first = $  row['t_firstNo'];                         $  second = $  row['t_secondNo'];                         $  result = $  first * $  second;                         echo $  result;                     ?>)</li>             <?php endwhile ?>  <!-- if bad input, get & display error -->             <?php if(isset($  _GET['error'])) : // if error variable is there ?>                 <?php echo $  _GET['error']; // get the error ?>             <?php endif ?> 

db.php:

<?php  // Connect $  con = mysqli_connect("localhost", "tnnick", "PHPprojects", "timesNumbers");  // Test Connection if (mysqli_connect_errno()) {     echo 'Failed: '.mysqli_connect_error(); }  ?> 

process.php:

<?php include 'db.php' ; ?>  <?php     if(isset($  _POST['submit'])) { // if form submitted         $  nickname = mysqli_real_escape_string($  con, $  _POST['nickname']); // get the inputs         $  firstNo = mysqli_real_escape_string($  con, $  _POST['firstNo']);         $  secondNo = mysqli_real_escape_string($  con, $  _POST['secondNo']);     } ?>  <?php // validate inputs if(!isset($  nickname) || $  nickname=='' || !isset($  firstNo) || $  firstNo=='' || !isset($  secondNo) || $  secondNo=='' ) {     // if invalid input, send error to index.php     $  error = 'Bad input - try again.'; // create error message     header("Location: index.php?error=".urlencode($  error)); // attach to URL & send to index.php     exit(); } else {     // insert into DB     $  putIntoDB = "INSERT INTO data (t_name, t_firstNo, t_secondNo) VALUES ('$  nickname','$  firstNo','$  secondNo')";      // check it inserted     if(!mysqli_query($  con, $  putIntoDB)) {         die('Error');     } else {         header("Location: index.php");         exit();     } } ?>