header('location: ./'); redirects to the current folder. Since 99% of LAMP
configuration loads index.php first, it redirects to index.php.
The header was from the previous code i guess.
I was redirecting from index.php to login.php if no session, and when the login
process was ok, header was redirecting to ./, aka index.php. Since now session
was set, user was logged in.
Now, since the loginprocess is inside the index, and login.php being only the
HTML to render the login form, there is no need for it anymore you're right.
Remi
Le 8 mars 2013 à 22:02, "Jeff (iUI Noob)" <[email protected]> a écrit :
> Hey Remi,
>
> I like this simple Login approach. As the web-app that I'd like a login for
> is for online only, this works great.
> Just one question: What is the purpose of the header('location: ./'); in
> the index.php file? It seems to work fine without it.
>
> On Monday, February 25, 2013 5:04:12 PM UTC-7, Remi Grumeau wrote:
> Here is a URL to test:
> http://www.remi-grumeau.com/labs/sandbox/login/
>
> and an archive of the PHP files
> http://www.remi-grumeau.com/labs/sandbox/login/login-iui.zip
>
> Note that this is not offline-capable.
>
> Remi
>
> Le 26 févr. 2013 à 00:06, Hello Gurus <[email protected]> a écrit :
>
>> Again, about login process, it depends what you need.
>> If you need to get some pages generated by a login/pass once or if you have
>> a strong server-side token system, doing this in JS might be ok.
>> If you need a "strong“ session-based process, since session is only
>> initialized unload, you need to reload the document (or navigate to a new
>> document).
>>
>> Otherwise, it means each single request from the device to the server needs
>> to ship ident/pass. Not very good to me...
>> That's why the ajax-based form management is not very good for login.
>> Perfect for search box, or regular form management.
>>
>> A very good implementation, to me, would be an index.php checking for
>> $_SESSION.
>> if empty, include a login.php which only contains a login screen/form. This
>> form posts to index.php which set the $_SESSION if a ident & pass are given
>> via $_POST. If ok, then it sets the $_SESSION and continue the index code.
>> Code could look like : (i say “could" since i'm not giving a test, i'm
>> typing it in the mail)
>>
>> <?php
>> session_start();
>> if(
>> isset($_POST['ident']) && !empty($_POST['ident']) &&
>> isset($_POST['pass']) && !empty($_POST['pass'])
>> ) {
>> // do what you need to test & give access or not based on ident & pass
>> values
>> if(login_process==true) {
>> $_SESSION['ident']=$_POST['ident'];
>> }
>> }
>>
>> if(!$_SESSION['ident']) {
>> include_once('login.php');
>> exit;
>> }
>>
>> // the rest of your project as logged
>>
>> ?>
>>
>> For an online-only process.
>>
>> Sad news for Alex, it looks like you want things to be offline-capable. In
>> this case, the authentication process needs to work offline too. So login &
>> pass should be in offline database or localStorage.
>> Since a crypto lib wouldn't be any help since decryption key would be
>> offline too (aka on the device), you have no other choice but to use hashed
>> datas locally.
>> That's another story bro…
>> A lib like http://caligatio.github.com/jsSHA/ might be very helpful !
>>
>>
>> Remi
>>
>> Le 25 févr. 2013 à 21:44, Henrique Luis de Souza <[email protected]> a
>> écrit :
>>
>>> Hi,
>>>
>>> Your path to action is the problem:
>>>
>>> try
>>>
>>> action="/shaw/myform.php"
>>>
>>> or
>>>
>>> action="./myform.php"
>>>
>>> =)
>>>
>>> 2013/2/25 Alex Larente <[email protected]>
>>> I'm fairly new to PHP and iui and i've managed to get stuck.
>>>
>>> When the form submits, it doesn't properly open up myform.php
>>> I think something is blocking the way when it tries to submit.
>>>
>>> The form is located at:
>>> http://alexlarente.com/shaw/ShawLinks.html#_testemail
>>>
>>> but when I click submit it goes to a blank page at:
>>> http://alexlarente.com/shaw/ShawLinks.html#___2__
>>>
>>> How do I try to fix this?
>>>
>>> This is my HTML
>>> <!-- Testing sending a customer an email -->
>>> <ul id="testemail" title="Email Customer">
>>> <form id="emailtest" title="Test Email" class="panel" name="My Form"
>>> action="myform.php" method="POST">
>>>
>>> <fieldset>
>>> <div class="row">
>>> <label>CX Email</label>
>>> <input type="text" name="cxemail" >
>>> </div>
>>> <div class="row">
>>> <label>Tech ID</label>
>>> <input type="text" name="techid" >
>>> </div>
>>> </fieldset>
>>> <input type="submit" class="whiteButton" >
>>>
>>> </form>
>>> </ul>
>>>
>>> This is my php file
>>>
>>> <html>
>>> <body>
>>>
>>> The customers email is <?php echo $_POST["cxemail"]; ?>! <br>
>>> You are tech number <?php echo $_POST["techid"]; ?>.
>>>
>>> </body>
>>> </html>
>>>
>>>
>>>
>>> --
>>> You received this message because you are subscribed to the Google Groups
>>> "iPhoneWebDev" group.
>>> To unsubscribe from this group and stop receiving emails from it, send an
>>> email to [email protected].
>>> To post to this group, send email to [email protected].
>>> Visit this group at http://groups.google.com/group/iphonewebdev?hl=en.
>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>
>>>
>>>
>>>
>>> --
>>> You received this message because you are subscribed to the Google Groups
>>> "iPhoneWebDev" group.
>>> To unsubscribe from this group and stop receiving emails from it, send an
>>> email to [email protected].
>>> To post to this group, send email to [email protected].
>>> Visit this group at http://groups.google.com/group/iphonewebdev?hl=en.
>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>
>>>
>>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "iPhoneWebDev" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/iphonewebdev?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
--
You received this message because you are subscribed to the Google Groups
"iPhoneWebDev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/iphonewebdev?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.