title: Insert two inputs into one column in mySQL with PHP
body: <p>I am a beginner to php and mySQL and I am currently using dreamweaver for the GUI to help me learn. </p>
  
  <p>I am trying to create a member registration form to register users into database. 
  What I aim to do is to have the username be generated from the first and last name of the user. For example: First name: John, Last name: Smith. username will automatically be generated as john.smith (disregarding the capital)</p>
  
  <p>I read about concatenating in php and came up with the code:</p>
  
  <pre><code>GetSQLValueString($_POST['firstname'], "text").GetSQLValueString('.'.$_POST['lastname'], "text"),
  </code></pre>
  
  <p>However, when I checked the stored data in mySQL it returns firstname'.lastname. i.e. john'.smith. (Notice the extra apostrophe following the firstname)</p>
  
  <p>This was my source: <a href="http://forums.phpfreaks.com/index.php?topic=294444.0" rel="nofollow">http://forums.phpfreaks.com/index.php?topic=294444.0</a>, the original poster mentioned that he modified some code that dreamweaver used. But I can't figure out which one to change.</p>
  
  <p>See below for my existing code so far: </p>
  
  <pre><code>&lt;?php require_once('../Connections/connSQL.php'); ?&gt;
  &lt;?php
  if (!function_exists("GetSQLValueString")) {
  function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
  {  if (PHP_VERSION &lt; 6) {
  $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  }
  
  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
  
   switch ($theType) {
  case "text":
    $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
    break;    
  case "long":
  case "int":
    $theValue = ($theValue != "") ? intval($theValue) : "NULL";
    break;
  case "double":
    $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
    break;
  case "date":
    $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
    break;
  case "defined":
    $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
    break;
    }
      return $theValue;
   }
  }
  
    $editFormAction = $_SERVER['PHP_SELF'];
  if (isset($_SERVER['QUERY_STRING'])) {
    $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
  }
  
  if ((isset($_POST["MM_insert"])) &amp;&amp; ($_POST["MM_insert"] == "form1")) {
    $insertSQL = sprintf("INSERT INTO member (m_firstname, m_lastname, m_username, m_password, m_workphone, m_address) VALUES (%s, %s, %s, %s, %s, %s)",
                         GetSQLValueString($_POST['firstname'], "text"),
                         GetSQLValueString($_POST['lastname'], "text"),
                         GetSQLValueString($_POST['firstname'], "text").GetSQLValueString(' .'.$_POST['lastname'], "text"),
                         GetSQLValueString($_POST['password'], "text"),
                         GetSQLValueString($_POST['passwordcheck'], "text"),
                         GetSQLValueString($_POST['address'], "text"));
  </code></pre>