客户注册未将信息添加到phpmyadmin

时间:2019-01-14 03:06:01

标签: php html web

我有一个客户注册页面,当我输入文本时,该页面不会转移到我的数据库中;当用户输入他们的详细信息时,我希望将他们的详细信息输入到我的数据库中,我已经查看了我的代码,但没有注意到错误我可能错过了一些东西或忘记了一些东西。我想知道是否有人可以帮助我。

Php Myadmin

<?php 
$con = mysqli_connect("localhost","Marcus","***********","electronicshub",);?>

<!-- Header -->
	<?php
		$active='Account';
		include("includes/header.php");
	?>

<!-- Shop -->
	<div id="content"><!-- #content Begin -->
		<div class="container"><!-- container Begin -->
			<div class="col-md-12"><!-- col-md-12 Begin -->
				<ul class="breadcrumb"><!-- breadcrumb Begin -->
					<li>
						<a href="index.php">Home</a>
					</li>
					<li>
						Register
					</li>
				</ul><!-- breadcrumb Finished -->
			</div><!-- col-md-12 Finished -->
			<div class="col-md-3"><!-- col-md-3 Begin -->
	 			<?php
	 				include("includes/sidebar.php");
	 			?>
			</div><!-- col-md-3 Finished -->
			<div class="col-md-9"><!-- col-md-9 Begin -->
				<div class="box"><!-- box Begin -->
					<div class="box-header"><!-- box-header Begin -->
						<center><!-- center Begin -->
							<h2> Register A New Account </h2>
						</center><!-- center Finished -->
						<form action="customer_register.php" method="post" enctype="multipart/form-data"><!-- form Begin -->
							<div class="form-group"><!-- form-group Begin -->
								<label> Your Name</label>
								<input type="text" class="form-control" name="c_name" required></input>
							</div><!-- form-group Finished -->
							<div class="form-group"><!-- form-group Begin -->
								<label>Your Email</label>
								<input type="text" class="form-control" name="c_email" required></input>
							</div><!-- form-group Finished -->
							<div class="form-group"><!-- form-group Begin -->
								<label>Your Password</label>
								<input type="password" class="form-control" name="c_pass" required></input>
							</div><!-- form-group Finished -->
							<div class="form-group"><!-- form-group Begin -->
								<label>Your Country</label>
								<input type="text" class="form-control" name="c_country" required></input>
							</div><!-- form-group Finished -->
							<div class="form-group"><!-- form-group Begin -->
								<label>Your City</label>
								<input type="text" class="form-control" name="c_city" required></input>
							</div><!-- form-group Finished -->
							<div class="form-group"><!-- form-group Begin -->
								<label>Your Contact</label>
								<input type="text" class="form-control" name="c_contact" required></input>
							</div><!-- form-group Finished -->
							<div class="form-group"><!-- form-group Begin -->
								<label>Your Address</label>
								<input type="text" class="form-control" name="c_address" required></input>
							</div><!-- form-group Finished -->
							<div class="form-group"><!-- form-group Begin -->
								<label>Your Profile Picture</label>
								<input type="file" class="form-control" name="c_image" required></input>
							</div><!-- form-group Finished -->


							<div class="text-center"><!-- text-center Begin -->
								<button type="submit" name="register" class="btn btn-primary">
								<i class="fa fa-user-md"></i> Register
								</button>
							</div><!-- text-center Finished -->
						</form><!-- form Finished -->
					</div><!-- box-header Finished -->
				</div><!-- box Finished -->
			</div><!-- col-md-9 Finished -->
		</div><!-- container Finished-->
	</div><!-- #content Finished -->

<!-- Footer -->
	 <?php
	 	include("includes/footer.php");
	 ?>







<script src="js/jquery-331.min.js"></script>
<script src="js/bootstrap-337.min.js"></script>

</body>
</html>

<?php
	if(isset($_POST['register'])){
		$c_name = $_POST['c_name'];
		$c_email = $_POST['c_email'];
		$c_pass = $_POST['c_pass'];
		$c_country = $_POST['c_country'];
		$c_city = $_POST['c_city'];
		$c_contact = $_POST['c_contact'];
		$c_address = $_POST['c_address'];
		$c_image = $_FILES['c_image']['name'];
		$c_image_tmp = $_FILES['c_image']['tmp_name'];
		$c_ip = getRealIpUser();
		move_uploaded_file($c_image_tmp,"customer/customer_images/$c_image");
		$insert_customer = "insert into customers (customer_name,customer_email,customer_pass,customer_country,customer_city,customer_contact,customer_image,customer_ip) values ('$c_name','$c_email','$c_pass','$c_country','$c_city','$c_contact','$c_address','$c_image','$c_ip')";
		$run_customer = mysqli_query($con,$insert_customer);
		$sel_cart = "select * from cart where ip_add='$c_ip'";
		$run_cart = mysqli_query($con,$sel_cart);
		$check_cart = mysqli_num_rows($run_cart);
		if($check_cart>0){
			$_SESSION['customer_email']=$c_email;
			echo "<script>alert('You Have Been Register Successfully')</script>";
			echo "<script>window.open('checkout.php','_self')</script>";
		}else{
			
			$_SESSION['customer_email']=$c_email;
			echo "<script>alert('You Have Been Register Successfully')</script>";
			echo "<script>window.open('index.php','_self')</script>";
		}
	}
?>

1 个答案:

答案 0 :(得分:0)

经过大约3个小时的调试,我解决了我的问题,这只是一个简单的错误,我忘记了phpmyadmin中的一个值,并将其添加到我的代码中,并且现在可以正常使用了。

$insert_customer = "insert into customers (customer_name,customer_email,customer_pass,customer_country,customer_city,customer_contact,customer_address,customer_image,customer_ip) values ('$c_name','$c_email','$c_pass','$c_country','$c_city','$c_contact','$c_address','$c_image','$c_ip')";