Get data with POST in the same php page

0

Good, I would like to obtain data in the same php page, in a login, the problem is that when I enter the values in my login, I save them by POST, but it seems that it always saves me NULL.

.boxlogin{
				border-radius:4px;
				box-shadow: 2px 2px #d6d6d6;
				margin: 75px auto;
				width: 320px;
				-webki-border-radius:4px;
				-moz-border-radius:4px;
			}
			.btn{
				margin-top: 14px;
			}	
<html lang="en">
<head>
	<meta charser="UTF-8">
	
	<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
	<meta http-equiv="x-ua-compatible" content="ie=edge">
	<title>Document</title>
		
	
	<link rel="stylesheet" href="css/bootstrap.min.css">
	<link rel="stylesheet" href="css/font-awesome.min.css">
	<link rel="stylesheet" href="css/estilos.css">
	<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">	
	<script src="js/jquery.js"></script>
	<script src="~/js/bootstrap.min.js"></script>
	<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
	<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
	

</head>
<body>
	<header>
</header>
	<div class="jumbotron boxlogin">
		 
		<form method="post" name="flogin" id="flogin" action=""  >
		<label>Usuario:</label>
		<input type="text" name="username"     class="form-control">
		<label>Contraseña:</label>
		<input type="password" name="password"    class="form-control">

		<button name="btnClickI" type="button" class="btn btn-success" data-toggle="modal" data-target="#ingreso">Ingresar</button> 
		<a href="registro.php"><button value="btnClickR" type="button" class="btn btn-info">Registrar</button></a>
		 	
			 
			<?php	
			 
			if(!isset($_POST['btnClickI'])){
				 
				$username=isset($_POST['username'])?var_dump($_POST['username']):NULL;
				$password=isset($_POST['password'])?var_dump($_POST['password']):NULL;
				if( $username==NULL  or  $password==NULL   ) { 	
				       echo '<div id="ingreso" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
							<div class="modal-diolag">
								<div class="modal-content">
									<div class="modal-header">
										<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
									</div>
									<div class="modal-body">
									<h3>Por favor llenar todo los campos!</h3>									 
									</div>
								</div>
							</div>
				       	</div>';
				 
				}else{
					echo '<div id="ingreso" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
							<div class="modal-diolag">
								<div class="modal-content">
									<div class="modal-header">
										<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
									</div>
									<div class="modal-body">
										<h3>Enviando datos!...</h3>									 
									</div>
								</div>
							</div>
				       	</div>';
				}    	
			} 
			?>
		</form>
	</div>

	<script type="http://code.jquery.com/jquery-latest.js"></script>
	<script src="js/bootstrap.min.js"></script>
</body>
</html>
    
asked by Luis Fernando Vargas 25.10.2017 в 07:31
source

1 answer

1

Try to change your entry condition

if(!isset($_POST['btnClickI']))

Since it will happen when it has no value or the $ _POST ['btnClickI'] is not declared, that is to say when nothing has been sent through the form, therefore all effort to obtain the fields of the same after this condition will be in valde, leave it in positive

if(isset($_POST['btnClickI']))

And then you tell me how it went. Greetings

    
answered by 25.10.2017 в 15:40