<?php require_once('Connections/myConn.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  if (PHP_VERSION < 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"])) && ($_POST["MM_insert"] == "form1")) {
  $insertSQL = sprintf("INSERT INTO logins (username, password, name, lastname, emailadd) VALUES (%s, %s, %s, %s, %s)",
                       GetSQLValueString($_POST['username'], "text"),
                       GetSQLValueString($_POST['password'], "text"),
                       GetSQLValueString($_POST['name'], "text"),
                       GetSQLValueString($_POST['lastname'], "text"),
                       GetSQLValueString($_POST['email'], "text"));

  mysql_select_db($database_myConn, $myConn);
  $Result1 = mysql_query($insertSQL, $myConn) or die(mysql_error());

  $insertGoTo = "signup2.php";
  if (isset($_SERVER['QUERY_STRING'])) {
    $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
    $insertGoTo .= $_SERVER['QUERY_STRING'];
  }
  header(sprintf("Location: %s", $insertGoTo));
}
?>
<!DOCTYPE html>
<html lang="en">
    <head>
		<meta charset="UTF-8" />
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> 
		<meta name="viewport" content="width=device-width, initial-scale=1.0"> 
        <title>Signup - iMusicJam</title>
        
        <link rel="shortcut icon" href="../favicon.ico"> 
        <link rel="stylesheet" type="text/css" href="css/style1.css" />
		<script src="js/modernizr.custom.63321.js"></script>
		
		<style>	
			@import url(http://fonts.googleapis.com/css?family=Raleway:400,700);
			body {
				background: #7f9b4e url(images/bg5.jpg) no-repeat center top;
				-webkit-background-size: cover;
				-moz-background-size: cover;
				background-size: cover;
			}
			.container > header h1,
			.container > header h2 {
				color: black;
				text-shadow: 0 1px 1px rgba(0,0,0,0.7);
			}
		</style>
    </head>
    <body>
        <div class="container">
		
			
            <div class="codrops-top">
                <a href="index4.php">
                    <strong>&laquo; LOGIN </strong>
                </a>
               
              <span class="right">
                	
                    <a href="index.php">
                        <strong>Back to the Home Page</strong>
                    </a>
                </span>
            </div>
			
			<header>
			
				<h1><img src="images/folder.png" width="70" height="70">I <strong>MUSIC</strong>JAM</h1>
				<h2>Explore The Latest Community of Artists, Bands, & Music</h2>
				

				
				
		  </header>
			
			<section class="main">
			  <form ACTION="<?php echo $editFormAction; ?>" METHOD="POST" class="form-4" name="form1">
		        <h1><img src="images/floopy.png" width="29" height="29"> Register</h1>
				    <p>
				        <label for="login">Username</label>
				        <input type="text" name="username" placeholder="Username" required>
				    </p>
                    
                     <p>
				        <label for="login">Name</label>
				        <input type="text" name="name" placeholder="Name" required>
				    </p>
                    
                     <p>
				        <label for="login">LastName</label>
				        <input type="text" name="lastname" placeholder="Lastname" required>
				    </p>
				    <p>
				        <label for="password">Password</label>
				        <input type="password" name='password' placeholder="Password" required> 
				    </p>
                    
                <p>
		          <label for="email">Email</label>
				        <input type="text" name='email' placeholder="Email" required> 
			    </p>

				    <p>
				        <input type="submit" name="submit" value="Signup!">
				    </p>
				    <input type="hidden" name="MM_insert" value="form1">       
				</form>​
			</section>
			
        </div>
    </body>
</html>