PHP
Name:
Anonymous
2012-01-07 17:53
Is there a cleaner way to do this?
<?php
if ($this->session->userdata('logged_in') != '') {
echo "Welcome, ".$this->session->userdata('logged_in')."<br/>";
echo anchor('login/logout/', ' Log Out');
}
else {
echo "<p>";
echo form_open('login');
echo "<label for='username'>Username:</label>";
echo "<input id='username' type='text' name='username' />";
echo "<label for='password'>Password:</label>";
echo "<input id='password' type='password' name='password' />";
echo "<input type='submit' value='Login' />";
echo "</form>";
echo "<br/><br/><br/><br/><br/><br/><br/><br/><br/>";
echo 'It is: ' . date('l jS F Y g:i:s A e ');
echo "</p>";
}
?>
Name:
Anonymous
2012-01-07 17:58
http://www.yesodweb.com/
the word Yesod (יסוד) means foundation in Hebrew.
Name:
Anonymous
2012-01-07 17:59
Maybe you should ask your rabbi?
Name:
Anonymous
2012-01-07 19:53
python
Name:
2
2012-01-07 20:07
Name:
Anonymous
2012-01-07 22:25
>php
>clean
Name:
Anonymous
2012-01-08 14:40
nah PHP doesn't get much better than that, you should remove the br's though and use styles instead
Name:
Anonymous
2012-01-08 14:47
>>5
You know that lead developer of Yesod, Michael Snoyman, ... here's his Google Plus profile:
https://plus.google.com/116553865628071717889/posts
What is he wearing on his head?
Name:
Anonymous
2012-01-08 14:49
Name:
Anonymous
2012-01-08 14:53
Name:
5
2012-01-08 20:46
>>8
That's a kippah, headgear worn by orthodox Jewish men. But that's cool as I'm a jew-loving capitalist.
Name:
Anonymous
2012-01-08 21:57
why would you wrap an html block so that each line is echo'd out... i thought in php you could just include a block of html
Name:
Anonymous
2012-01-09 0:06
<?php if ($this->session->userdata('logged_in') != ''): ?>
Welcome, <?php echo $this->session->userdata('logged_in'); ?><br/>
<?php echo anchor('login/logout', ' Log Out'); ?>
<?php else: ?>
<p>
<?php echo form_open('login'); ?>
<label for="username">Username:</label>
<input id="username" type="text" name="username" />
<label for="password">Password:</label>
<input id="password" type="password" name="password" />
<input type="submit" value="Login" />
</form>
<br/><br/><br/><br/><br/><br/><br/><br/><br/>
It is: <?php echo date('l jS F Y g:i:s A e '); ?>
</p>
<?php endif; ?>
Name:
Anonymous
2012-01-09 0:12
>>13
on furthernote, this code should go into your view. Your view shouldn't have access to the session or user data.
A better way to do it would be like this:
<?php if ($logged_in): ?>
Welcome, <?php echo $username; ?>
Name:
Anonymous
2012-01-09 0:14
also you are using CodeIgniter which is shit in itself.
Name:
Anonymous
2012-01-09 0:33
I think this is what you are looking for OP.
(write-html-tree-to-stdout
(if (not (eq? ((userdata (session this)) "logged_in") ""))
`(text "Welcome, " ,((userdata (session this)) "logged_in") (br)
,(anchor "login/logout" " Log Out"))
`(p ,((form "login") (label ((for "username")) "Username:")
(input ((id "username") (type "text") (name "username")))
(label ((for "password")) "Password:")
(input ((id "password") (type "password") (name "password")))
(input ((type "submit") (value "Login"))))
,(times 9 '(br))
(text "It is: " ,(data "l jS F Y g:i:s A e ")))))
Name:
Anonymous
2012-01-09 0:41
Name:
Anonymous
2012-01-09 1:21
>>11
That's a kippah, headgear worn by orthodox Jewish men. But that's cool as I'm a jew-loving capitalist.
How does it stay in place?
Name:
Anonymous
2012-01-09 1:24
>>16
I can't tell if I'm horrified or I love it.