<?php
session_start();
require_once 'en/php/class.user.php';
require_once "SystemController/DbConnection.php";
$reg_user = new User();
$msg = "";
$email = "";
$username = "";
$fname = "";
$lname = "";
$mobile = "";
$referrer = "";

if(isset($_GET['ref'])){
    $referrer = $_GET['ref'];
}
$db_handle= new DbConnection();
if(isset($_POST['email'])){


$email = $_POST['email'];

$fname = $_POST['fname'];
$lname = $_POST['lname'];
$username = $_POST['username'];
$mobile = $_POST['phone'];
$password = $_POST['password'];
$confirm = $_POST['password2'];
$currency = $_POST['currency'];


$date = date('Y-m-d h:i:s');
$status = 0;


    
  
$stmt = $reg_user->runQuery("SELECT * FROM members WHERE email=:email");
  
  $stmt->execute(array(":email"=>$email));
  
  $row = $stmt->fetch(PDO::FETCH_ASSOC);
  
  
  
  if($stmt->rowCount() > 0 )
  {
    $msg = "<div class='alert alert-danger mx-auto'><strong><i class='fa fa-info-circle'></i> Email or Username already exists! Please, try another one!</strong></div>";
          
        
        
  }elseif($password != $confirm){
    $msg = "<div class='alert alert-danger mx-auto'>
            
    <strong><i class='fa fa-info-circle'></i> Passwords do not match, please check and try again </strong>
  </div>";
  }
  else
  {
    if($reg_user->create($fname,$lname,$username,$email,$password,$date,$status,$mobile,$referrer,$currency))
    {     
      $id = $reg_user->lasdID();
      
      $db_handle->insertRecord("INSERT INTO account_balance(userID,balance) VALUES (?,?)", "ii", array($id, 0));


     // $_SESSION['email'] = $email;
    //  $_SESSION['id'] = $id;
    //  $_SESSION['username'] = $id;
//header("location: login");
      $messag = '<div style="font-family:Times new roman,HelveticaNeue-Light,Arial,sans-serif;background-color:#404040">
<table align="center" width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#EAFFF5">
<tbody>
<tr>
<td>
<table align="center" width="770px" border="0" cellspacing="0" cellpadding="0" bgcolor="#EAFFF5" style="width:750px!important">
<tbody>
<tr>
<td>
<table width="690" align="center" border="0" cellspacing="0" cellpadding="0" bgcolor="#EAFFF5">
<tbody>
<tr><td colspan="3" height="10"></td></tr>
<tr>
<td colspan="3" height="80" align="center" border="0" cellspacing="0" cellpadding="0" bgcolor="#EAFFF5" style="padding:
0;margin:0;font-size:0;line-height:0">
<table width="690" align="center" border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td width="30"></td>
<td valign="top" align="center" style="padding:0;margin:0;font-size:0;line-height:0"><a href="https://spcxinvs.com//" target="_blank"><img src="https://spcxinvs.com/trading/images/pionex_logo.png" width="300"  alt="SpaceX Tesla Investments Trades"></a></td>
<td width="30"></td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr>
<td colspan="3" align="center">
<table width="630" align="center" border="0" cellspacing="0" cellpadding="0">
<tbody>

<tr><td colspan="3" height="10"></td></tr>
</tbody>
</table>
</td>
</tr>

<tr bgcolor="#FFFFFF">
<td width="10" bgcolor="#EAFFF5"></td>
<td>
<table width="570" align="center" border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td colspan="4" align="center">&nbsp;</td>
</tr>
<tr>
<tr>
<td colspan="3" height="40"></td></tr><tr><td colspan="5" align="left">
<p style="color:#404040;font-size:40px;line-height:68px;font-weight:lighter;padding:0;margin:0">Hello ' .$fname.',</p>
</td>
</tr>
</tr>
<tr>
<tr>
<td colspan="3" height="40"></td></tr><tr><td colspan="5" align="left">
<p style="color:#404040;font-size:34px;line-height:58px;font-weight:lighter;padding:0;margin:0">Welcome to SpaceX Tesla Investments Trades. and thanks for signing up! You are one step closer to fincancial freedom.</p>
</td>
</tr>
</tr>
<tr>
<td width="10"></td>
<tr>
<td colspan="3" height="40"></td></tr><tr><td colspan="5" align="center">
<p style="color:#404040;font-size:42px;line-height:70px;font-weight:bold;padding:0;margin:0">NEXT STEP</p>
</td>
</tr>

<tr>
<td colspan="3" height="40"></td></tr><tr><td colspan="5" align="left">
<p style="color:#404040;font-size:34px;line-height:58px;font-weight:lighter;padding:0;margin:0">Please login to your account with your email address to get started.</p>
</td>
</tr>
<tr>
<td align="center">
<div style="text-align:center;width:100%;padding:40px 0">
<table align="center" cellpadding="0" cellspacing="0" style="margin:0 auto;padding:0">
<tbody>
<tr>
<td align="center" style="margin:0;text-align:center"><a href="https://spcxinvs.com/trading/login.php" style="font-size:22px;font-family:HelveticaNeue-Light,Arial,sans-serif;line-height:22px;text-decoration:none;color:#ffffff;font-weight:bold;border-radius:2px;background-color:#BC27F6;padding:20px 40px;display:block" target="_blank">Login</a></td>
</tr>
</tbody>
</table>
</div>
</td>
</tr>
<td width="10"></td>
</tr>
<tr>
<td width="10"></td>
<tr>
<td colspan="3" height="40"></td></tr><tr><td colspan="5" align="left">
<p style="color:#404040;font-size:34px;line-height:58px;font-weight:lighter;padding:0;margin:0">If you didnt create an account using this email address, please ignore this email or unsubscribe.</p>
</td>
</tr>
<td width="10"></td>
</tr>
<tr>
<td width="10"></td>
<tr>
<td colspan="3" height="40"></td></tr><tr><td colspan="5" align="left">
<p style="color:#404040;font-size:34px;line-height:58px;font-weight:lighter;padding:0;margin:0">Best Regards!</p>
</td>
</tr>
<td width="10"></td>
</tr>
<tr>
<td width="10"></td>
<td width="10"></td>
</tr>
<tr>
<td colspan="5" height="40" style="padding:0;margin:0;font-size:0;line-height:0"></td>
</tr>
<tr>

<td width="10"></td>
<td width="10"></td>
</tr>
<tr>
<td colspan="5" height="30" style="padding:0;margin:0;font-size:0;line-height:0"></td>
</tr>
<tr>
<td width="10"></td>
<td width="10"></td>
</tr>
<tr>
<td colspan="4">&nbsp;</td>
</tr>
</tbody>
</table>
<table width="570" align="center" border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td>
<h2 style="color:#404040;font-size:22px;font-weight:bold;line-height:26px;padding:0;margin:0">&nbsp;</h2>

</td>
</tr>
<tr>
</tr><tr><td>&nbsp;</td>
</tr></tbody></table></td>
<td width="10" bgcolor="#EAFFF5"></td>
</tr>
</tbody>
</table>
<table align="center" width="750px" border="0" cellspacing="0" cellpadding="0" bgcolor="#EAFFF5" style="width:750px!important">
<tbody>
<tr>
<td>
<table width="630" align="center" border="0" cellspacing="0" cellpadding="0" bgcolor="#EAFFF5">
<tbody>
<tr><td colspan="2" height="10"></td></tr>
<tr>
<td width="360" valign="top">
<div style="color:#404040;font-size:12px;line-height:12px;padding:0;margin:0">&copy; 2025 SpaceX Tesla Investments Trades. All rights reserved.</div>
<div style="line-height:5px;padding:0;margin:0">&nbsp;</div>
<div style="color:#404040;font-size:12px;line-height:12px;padding:0;margin:0">Atlanta, United States.</div>
</td>
<td align="right" valign="top">
<span style="line-height:20px;font-size:10px"><a href="https://www.facebook.com/" target="_blank"><img src="https://i.imgbox.com/BggPYqAh.png" alt="fb"></a>&nbsp;</span>
<span style="line-height:20px;font-size:10px"><a href="https://twitter.com/" target="_blank"><img src="https://i.imgbox.com/j3NsGLak.png" alt="twit"></a>&nbsp;</span>
<span style="line-height:20px;font-size:10px"><a href="https://plus.google.com/" target="_blank"><img src="https://i.imgbox.com/wFyxXQyf.png" alt="g"></a>&nbsp;</span>
</td>
</tr>
<tr><td colspan="2" height="5"></td></tr>

</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</div>';
            $subject = "Welcome to SpaceX Tesla Investments Trades.";
            
            
            // To send HTML mail, the Content-type header must be set
$headers[] = 'MIME-Version: 1.0';
$headers[] = 'Content-type: text/html; charset=iso-8859-1';

// Additional headers

$headers[] = 'From: customer<support@spcxinvs.com>';


// Mail it
mail($email, $subject, $messag, implode("\r\n", $headers));
            

       header("location: login.php");
            

    }
    else
    {
      echo "Sorry , Query could no execute...";
    }
}
}
?>

<!DOCTYPE html>
<html lang="en">


<head>
<script src="//code.jivosite.com/widget/pfNW6yUA29" async></script>
    <meta charset="utf-8" />
    <title>SpaceX Tesla Investments Trades </title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />

    <!-- Favicon -->
    <link rel="shortcut icon" href="assets/img/favicon.png">

    <!-- Template CSS Files -->
    <link rel="stylesheet" href="css/font-awesome.min.css">
    <link rel="stylesheet" href="css/bootstrap.min.css">
    <link rel="stylesheet" href="css/magnific-popup.css">
    <link rel="stylesheet" href="css/select2.min.css">
    <link rel="stylesheet" href="css/style.css">
    <link rel="stylesheet" href="css/skins/orange.css">

    <!-- Live Style Switcher - demo only 
    <link rel="alternate stylesheet" type="text/css" title="orange" href="css/skins/orange.css" />
    <link rel="alternate stylesheet" type="text/css" title="green" href="css/skins/green.css" />
    <link rel="alternate stylesheet" type="text/css" title="blue" href="css/skins/blue.css" />-->
    <link rel="stylesheet" type="text/css" href="css/styleswitcher.css" />

    <!-- Template JS Files -->
    <script src="js/modernizr.js"></script>

</head>



<body>

	 <!-- SVG Preloader Starts -->
 <div id="preloader">
    <div id="preloader-content">
      
       <img id="logo" class="img-responsive" src="images/pionex_logo.png" alt="logo" width="">
    </div>
 </div>
 
 <!-- <div id="showSwitcher" class="styleSecondColor"><i class="fa fa-cog fa-spin"></i></div> -->
 <!-- Live Style Switcher Ends - demo only -->	<!-- Wrapper Starts -->
	<div class="wrapper">
		<!-- Header Starts -->
		
		<div class="container-fluid user-auth" style="height: 1000px;">
			<div class="hidden-xs col-sm-4 col-md-4 col-lg-4">
				<!-- Logo Starts -->
				<a class="logo" href="../index.html">
					<img id="logo-user" class="img-responsive" src="images/pionex_logo.png" alt="logo" width="150">
				</a>
				<!-- Logo Ends -->
				
			</div>
		    <div class="col-xs-12 col-sm-8 col-md-8 col-lg-8">
				<!-- Logo Starts -->
				<a class="visible-xs" href="../index.html">
					<img id="logo" class="img-responsive mobile-logo" src="images/pionex_logo.png" alt="logo" width="120">
				</a>
				<!-- Logo Ends -->
				<div class="form-container">
					<div>
						<!-- Section Title Starts -->
						<div class="row text-center">
							<h2 class="title-head hidden-xs">get <span>started</span></h2>
							<p class="info-form">Open account for free and start trading Bitcoins now!</p>
						</div>
						<!-- Section Title Ends -->
						<!-- Form Starts -->
						<form method="post" action="signup.php">
							<?php echo $msg; ?>
							<!-- Input Field Starts -->
							<div class="form-group">
								<input type="text" class="form-control" name="fname" value="" placeholder="First Name" required="required" />
							</div>
							<!-- Input Field Ends -->
							<!-- Input Field Starts -->
							<div class="form-group">
								<input type="text" class="form-control" name="lname" value="" placeholder="Last Name" required="required" />
							</div>
							<!-- Input Field Ends -->

							<!-- Input Field Starts -->
							<div class="form-group">
								<input type="email" class="form-control" name="email" value="" placeholder="E-mail" required="required" />
							</div>
							<!-- Input Field Ends -->
							<div class="form-group">
								<input type="text" class="form-control" name="phone" value="" placeholder="Phone Number" required="required" />
							</div>
							<!-- Input Field Starts -->
							<div class="form-group">
								<input type="text" class="form-control" name="username" value="" placeholder="Username" required="required" />
							</div>
							<div class="form-group">
							<select name="currency" class="form-control">
                                            <option value="$">USD</option>
                                            <option value="€">EUR</option>
                                            <option value="£">GRP</option>
                                            <option value="A$">AUD</option>
                                            <option value="C$">CAD</option>
                                        </select>
							</div>
							<!-- Input Field Ends -->
							<!-- Input Field Starts -->
							<div class="form-group">
								<input type="password" class="form-control" name="password" placeholder="Password" required="required" />
							</div>
							<!-- Input Field Ends -->
							<!-- Input Field Starts -->
							<div class="form-group">
								<input type="password" class="form-control" name="password2" placeholder="Confirm password" />
							</div>
							<!-- Input Field Ends -->
							<!-- Input Field Starts -->
							<div class="form-group">
								<input id="register_frm_uRef" disabled="disabled" type="hidden" value="Invited you:  N/A" type="text" class="form-control" placeholder="" />
							</div>
							<!-- Input Field Ends -->
							<b class="text-center"></b>
							<!-- Submit Form Button Starts -->
							<div class="form-group">
								<button class="btn btn-primary" type="submit" name="register_frm_btn">create account</button>
								<p class="text-center">already have an account ? <a href="login.php">Login</a>
							</div>
							<!-- Submit Form Button Ends -->
						</form>
						<!-- Form Ends -->
					</div>
				</div>
				<!-- Copyright Text Starts -->
				<!-- <p class="text-center copyright-text"><a href="templateshub.net">Templates Hub</a></p> -->
				<!-- Copyright Text Ends -->
			</div>
		</div>
		<!-- Template JS Files -->
		<script src="js/jquery-2.2.4.min.js"></script>
		<script src="js/bootstrap.min.js"></script>
		<script src="js/select2.min.js"></script>
		<script src="js/jquery.magnific-popup.min.js"></script>
		<script src="js/custom.js"></script>

		<!-- Live Style Switcher JS File - only demo -->
		<script src="js/styleswitcher.js"></script>

	</div>
	<!-- Wrapper Ends -->
</body>


</html>