New to PHP/SQL trying really hard getting there :). Now everything worked out for me to try and connect a form to my SQL database. But only the PHP redirect won't work.
I tried and red a lot of things about the redirect, like: the space you need to watch before the ':', there should be no content loaded before the redirect. All kept to this rules.
Now I was even doubting it was my server so I tried a different page with just the redirect and seems to work Yay...
The only difference I now do compared to an empty page is that I create some variables first and use the redirect in an if-statement.
Can't find the issue since all the echo's when a record is inserted or updated in SQL-DB is just working fine.
<?php include('db-connect.php');
session_start();  $_SESSION['brand_name'] = $_POST['brand'];
$_SESSION['brand_label'] = $_POST['label'];   $_SESSION['brand'] =
$_SESSION['brand_name'].".".$_SESSION['brand_label'];
$brand_name = $_SESSION['brand_name'];    $brand_label =
$_SESSION['brand_label'];     $brand = $_SESSION['brand'];     ?> <?php
if (isset($_POST['submit_form_1'])) {
   $sqlinsert = "INSERT INTO `brands` (brand, brand_name, brand_label) VALUES ('$brand', '$brand_name', '$brand_label')"; $sqlupdate = "UPDATE brands SET brand_label='$brand' WHERE brand_name='$brand'";
   if (!mysqli_query($db_connection, $sqlinsert))      {
           if  (!mysqli_query($db_connection, $sqlupdate))
           {   
               $submitmessage = 'Record failed to update or insert!';
           }
           else
           {
               // $submitmessage = "Record is succesfully updated";
               header("Location: Form2.php");
               die();
           }       }   else        {           // $submitmessage = "Record is succesfully inserted";           header("Location: Form2.php");          die();      } } ?> <?php
include 'header.php'; ?>
 <table class="main-container" border="0" cellspacing="0"
 cellpadding="0">   <tr>     
     <td>Select a brand to edit:<br />
       <form action="Form1.php" method="post">
         <select name="brand" id="brand" onchange="populate(this)">
           <option value="">--Please select option--</option>
           <option value="cheaptickets">brand1</option>
           <option value="vayama">brand2</option>
         </select>
         <select name="label" id="label">
           <option value="">--Please select option--</option>
          <option value="cheaptickets">test1</option>
           <option value="vayama">test2</option>
         </select>
         <br />
         <br />
         <input type="submit" value="Select this template!" name="submit_form_1" />
       </form>
       <span id="info-message">
         <?php
           echo $submitmessage;
           ?>
       </span>
       </td>   </tr> </table>
 <?php include 'footer.php'; ?>
db-connect.php contains following:
<?php DEFINE ('db_host', '*******'); DEFINE ('db_user', '*******'); DEFINE ('db_pswd', '*******'); DEFINE ('db_name', '*******');
$db_connection = mysqli_connect(db_host, db_user, db_pswd, db_name);
?>
Checked the following things:
- DB-connection ✓check
- When not using redirect message works fine ✓check
- No content on page loaded before the redirect ✓check
- Record gets inserted or updated in SQL-DB ✓check
- Redirect works on page with nothing but the redirect ✓check
Any clever one can tell me what am I doing wrong? Thanks
 
     
     
    