Blanke pagina na login
Ik zit met een klein probleempje, ik ben een systeem aan het ontwikkelen, en uiteraard zit daar een login aan vast ;).
Helaas krijg ik continu een blanke pagina te zien na het versturen van het inlogformulier.. door de (blanke) pagina een keer te refreshen en de formuliergegevens opnieuw te verzenden (zoals de browser vraagt) ben ik daarna wel ingelogd.. het grootste probleem: ik kan de oplossing niet vinden :/
loginfunctie
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<?php
function login()
{
$this->data['title'] = "Inloggen";
//validate form input
$this->form_validation->set_rules('identity', 'Gebruikersnaam', 'required');
$this->form_validation->set_rules('password', 'Wachtwoord', 'required');
if ($this->form_validation->run() == true)
{
//check to see if the user is logging in
//check for "remember me"
$remember = (bool) $this->input->post('remember');
if ($this->ion_auth->login($this->input->post('identity'), $this->input->post('password'), $remember))
{
//if the login is successful
//redirect them back to the home page
$this->session->set_flashdata('message', $this->ion_auth->messages());
redirect('/', 'refresh');
}
else
{
//if the login was un-successful
//redirect them back to the login page
$this->session->set_flashdata('message', $this->ion_auth->errors());
redirect('auth/login', 'refresh'); //use redirects instead of loading views for compatibility with MY_Controller libraries
}
}
else
{
//the user is not logging in so display the login page
//set the flash data error message if there is one
$this->data['message'] = (validation_errors()) ? validation_errors() : $this->session->flashdata('message');
$this->data['identity'] = array('name' => 'identity',
'id' => 'identity',
'type' => 'text',
'value' => $this->form_validation->set_value('identity'),
);
$this->data['password'] = array('name' => 'password',
'id' => 'password',
'type' => 'password',
);
$this->_render_page('auth/login', $this->data);
}
}
?>
function login()
{
$this->data['title'] = "Inloggen";
//validate form input
$this->form_validation->set_rules('identity', 'Gebruikersnaam', 'required');
$this->form_validation->set_rules('password', 'Wachtwoord', 'required');
if ($this->form_validation->run() == true)
{
//check to see if the user is logging in
//check for "remember me"
$remember = (bool) $this->input->post('remember');
if ($this->ion_auth->login($this->input->post('identity'), $this->input->post('password'), $remember))
{
//if the login is successful
//redirect them back to the home page
$this->session->set_flashdata('message', $this->ion_auth->messages());
redirect('/', 'refresh');
}
else
{
//if the login was un-successful
//redirect them back to the login page
$this->session->set_flashdata('message', $this->ion_auth->errors());
redirect('auth/login', 'refresh'); //use redirects instead of loading views for compatibility with MY_Controller libraries
}
}
else
{
//the user is not logging in so display the login page
//set the flash data error message if there is one
$this->data['message'] = (validation_errors()) ? validation_errors() : $this->session->flashdata('message');
$this->data['identity'] = array('name' => 'identity',
'id' => 'identity',
'type' => 'text',
'value' => $this->form_validation->set_value('identity'),
);
$this->data['password'] = array('name' => 'password',
'id' => 'password',
'type' => 'password',
);
$this->_render_page('auth/login', $this->data);
}
}
?>
loginformulier
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<form action="" method="post" accept-charset="utf-8">
<div class="form-group has-feedback">
<input type="text" class="form-control" placeholder="Gebruikersnaam" name="<?php echo $identity['name']; ?>"/>
<span class="glyphicon glyphicon-user form-control-feedback"></span>
</div>
<!-- -->
<div class="form-group has-feedback">
<input type="password" class="form-control" placeholder="Wachtwoord" name="<?php echo $password['name']; ?>"/>
<span class="glyphicon glyphicon-lock form-control-feedback"></span>
</div>
<div class="row">
<div class="col-xs-8">
<div class="checkbox icheck">
<label>
<input type="checkbox" value="1" id="remember"> Onthouden
</label>
</div>
</div><!-- /.col -->
<div class="col-xs-4">
<button type="submit" class="btn btn-primary btn-block btn-flat">Inloggen</button>
</div><!-- /.col -->
</div>
</form>
<div class="form-group has-feedback">
<input type="text" class="form-control" placeholder="Gebruikersnaam" name="<?php echo $identity['name']; ?>"/>
<span class="glyphicon glyphicon-user form-control-feedback"></span>
</div>
<!-- -->
<div class="form-group has-feedback">
<input type="password" class="form-control" placeholder="Wachtwoord" name="<?php echo $password['name']; ?>"/>
<span class="glyphicon glyphicon-lock form-control-feedback"></span>
</div>
<div class="row">
<div class="col-xs-8">
<div class="checkbox icheck">
<label>
<input type="checkbox" value="1" id="remember"> Onthouden
</label>
</div>
</div><!-- /.col -->
<div class="col-xs-4">
<button type="submit" class="btn btn-primary btn-block btn-flat">Inloggen</button>
</div><!-- /.col -->
</div>
</form>
Ohja, ik gebruik CodeIgniter :)
Gewijzigd op 17/07/2015 19:18:23 door Jelle Hi
Op regel 40 en 44 staat een komma teveel.
De error_reporting op E_ALL werkt helaas niet (geplaatst op de index.php), krijg nog steeds een een blanke pagina :/
Daarnaast kan het de moeite lonen om de redirects tijdelijk uit te commenten om te kijken of hiervoor mogeijk fouten geproduceerd werden die je niet ziet omdat je meteen wordt geredirect.
Daarnaast zou je stapsgewijs in je code die()-statements kunnen zetten om te zien welk pad door je if-else statement wordt gekozen en welke er voor problemen zorgt zodat je steeds beter op het daadwerkelijke probleemgebied in kunt zoomen / deze af kunt bakenen.
En dan is het een kwestie van data naar je scherm dumpen om te zien wat er inhoudelijk misgaat.
Gewijzigd op 17/07/2015 22:04:08 door Thomas van den Heuvel
Roep je de functie wel aan?
Want dat laat je niet zien in je code.
@Eddy de index.php van CodeIgniter roept de functie aan (url: /auth/login), leek me lichtelijk overbodig om die code ook te posten, dus helaas geen heldere zaterdagochtendoplossing ;(
Dan wordt het dus, net als Thomas zegt, her en der wat echo's kunnen plaatsen kom te kijken waar je wel/niet komt.
Ik heb diverse echo's geplaatst om te kijken waar hij vast liep, nu blijkt dat alles werkt tot aan de redirect. Ik heb al geprobeerd om de redirect te vervangen voor header('Location: url'); alleen dat werkte helaas ook niet..
Iemand nog suggesties? Zou een beetje vervelend zijn dat ik continu na een login de pagina moet refreshen om echt in te loggen :/
Bestaat de function redirect() wel?
Ik laad een stukje eerder in de code de url-helper van CodeIgniter in, redirect() is daar een functie van. Verder werkt het volgende ook niet..
Waarschijnlijk heb je output voor de header(), en dan doet ie het niet.
Ik ga inderdaad maar eens nalopen of er output voor de header() staat. Alleen het vreemde is, als ik de blanke pagina refresh, stuurt hij me wel door, dus dan lijkt de redirect()/header() wel te werken(?) #iksnaphetnietmeer
Kan je in de serverlogfile kijken?
In de logfile waarin ik toegang tot heb (via DirectAdmin) staat niets, echt helemaal niets (misschien klopt dat ook niet helemaal). Verder is het een account op een reseller pakket dus kan ik verder niet bij de server.