routes.php
Código PHP:
Route::get('/', function()
{
return View::make('hello');
});
Route::get('/login', function()
{
return View::make('login.login');
});
Route::post('/registrar','RegistrarController@registrar');
Código PHP:
<?php
class RegistrarController extends BaseController
{
public function registrar()
{
$usuario = Input::get('usuario');
$password = Hash::make(Input::get('password'));
$email = Input::get('email');
$rules = array(
'usuario' =>
array('required', 'min:3','max:20','alpha_dash','required'),
'password'=>
array('required', 'min:6','max:50','alpha_dash','required'),
'email'=>
array('required','email')
);
$validator = Validator::make(Input::all(), $rules);
if ($validator->fails())
{
return Redirect::to('login')->withInput()->withErrors($validator);
}
$user = Usuario::where('nombre', '=', $usuario)->orWhere('correo','=',$email)->first();
if (is_null($user))
{
return Redirect::to('login')->with('msg','Te has registrado correctamente');
$user = new Usuario;
$user->nombre = $usuario;
$user->password = $password;
$user->correo = $email;
$user->fecha_ingreso=time();
$user->ip=Request::getClientIp();
$user->save();
}
else
{
echo "a";
//return Redirect::to('login')->with('msg','El nombre de usuario o el email ya está en uso');
}
}
}
?>
Código PHP:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang='es'>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Login</title>
<!-- Estilos CSS -->
{{ Html::style('css/estilos.css') }}
<!--<link rel="stylesheet" type="text/css" href="estilos/estilos.css" />-->
<!--<script type="text/javascript" src="js/jquery.js"></script>-->
<!--<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>-->
{{ Html::script('js/jquery.js') }}
{{ Html::script('js/funciones.js') }}
<!--<script src="js/jquery.js"></script>
<script type="text/javascript" src="js/funciones.js"></script>-->
<!--Slider-->
{{ Html::style('css/slider.css') }}
<!--Google Analytics-->
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-39366535-1']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
</head>
<body>
@include('login.nav')
<div id="wrap">
<div id="center_wrap">
<div id="menu_l">
<div class="slider">
<input type="radio" name="slide_switch" id="id1"/>
<label for="id1">
{{Html::image('img/slider/slider2.png','',array('width'=>'100'))}}
</label>
{{Html::image('img/slider/slider2.png')}}
<!--Lets show the second image by default on page load-->
<input type="radio" name="slide_switch" id="id2" checked="checked"/>
<label for="id2">
{{Html::image('img/slider/slider0.png','',array('width'=>'100'))}}
</label>
{{Html::image('img/slider/slider0.png')}}
<input type="radio" name="slide_switch" id="id3"/>
<label for="id3">
{{Html::image('img/slider/slider1.png','',array('width'=>'100'))}}
</label>
{{Html::image('img/slider/slider1.png')}}
<input type="radio" name="slide_switch" id="id4"/>
<label for="id4">
{{Html::image('img/slider/slider3.png','',array('width'=>'100'))}}
</label>
{{Html::image('img/slider/slider3.png')}}
<input type="radio" name="slide_switch" id="id5"/>
<label for="id5">
{{Html::image('img/slider/slider4.png','',array('width'=>'100'))}}
</label>
{{Html::image('img/slider/slider4.png')}}
</div>
</div><!--menu_r-->
<div id="menu_r">
<div id="wrap_registro">
<div id="registro">
{{ Form::open(array('url' => 'registrar','method'=>'post','class'=>'form')) }}
<!--<form class="form" name="form_registro" method="post" action="procesa_registro.php">-->
<div class="seccion_input">
<p class="field">
{{Form::text('usuario','', array('maxlength'=>'50','class'=>'input','placeholder'=>'Usuario'))}}
<!--<input type="text" name="nombre" placeholder="Usuario" maxlength="50" class="input">-->
<i class="icon-user icon-large"></i>
</p>
</div>
<div class="seccion_input">
<p class="field">
{{Form::password('password','',array('maxlength'=>'50','class'=>'input'))}}
<!-- <input type="password" name="password" placeholder="Contraseña" maxlength="50" class="input">-->
<i class="icon-lock icon-large"></i>
</p>
</div>
<div class="seccion_input">
<p class="field">
{{Form::email('email','',array('maxlength'=>'50','class'=>'input','placeholder'=>'Correo electrónico'))}}
<!--<input type="text" name="correo" placeholder="Correo electrónico" maxlength="50" class="input">-->
<i class="icon-envelope icon-large"></i>
</p>
</div>
<!--<input type="submit" value="Registrarse" class="input_login">-->
{{Form::submit('Registrarse',array('class'=>'input_login'))}}
<!--</form>-->
{{ Form::close() }}
<span style='color:white;'>
{{$msg}}
</span>
</div><!--#Registro-->
</div><!--#Wrap_Registro-->
</div><!--menu_l-->
</div><!--center_wrap-->
</div><!--Wrap-->
@include('login.footer')
</body>
</html>
¿Qué puedo hacer?
Saludos.