Post Your Favorite Code

liunx

Guest
Go ahead and post your favorite html code, remeber to incluse what it does to though! The good thing about this is just that everybody can share really cool html codes and get some at random!<!--content-->What?? :confused:<!--content--><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><br />
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"><!--content--><opinion type="personal" content="Say What?!" action="ignore" /><!--content-->cmon people!!! this is a good thread... i just wish i had html to show... im dumb<!--content-->my favourite code is this:<br />
<br />
<html><br />
<body><br />
<table><br />
<tr><br />
<td><br />
<font size="+1"><br />
<p><b>This is my code!</font></b><br />
</td><br />
</tr><br />
</table><br />
</body><br />
</html><br />
<br />
*waits for Charles to storm into this thread*:p<!--content-->this is mine.... <table>ooo, im a table!</table><!--content-->Originally posted by Da Warriah <br />
<p><b>This is my code!</font></b><br />
<br />
you people are weak... are you going to tell me that not one of you has learned html or gotten tips by looking at others' code???<br />
<br />
tight-asses, get over it. everyone learns from everyone else...<br />
<br />
here's mine for creating a login page with php/mysql...<br />
<br />
use it, learn from it, change it, who cares???<!--content-->index.php<br />
<br />
[? if (!$HTTP_POST_VARS['submit']) { ?]<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
"]<br />
[input type="text" name="uid" value="user"][br]<br />
[input type="password" name="pass"][br]<br />
[input type="submit" name="submit" value="LogIn"]<br />
<br />
<br />
<br />
<br />
<br />
<br />
[? } else {<br />
<br />
$connect = mysql_connect("localhost", USER, PASSWORD);<br />
$select = mysql_select_db(DATABASE, $connect);<br />
<br />
$query = "SELECT * FROM TABLE WHERE uid= \"$uid\" AND pass= \"$pass\"";<br />
$result = mysql_query($query, $connect);<br />
<br />
// if row exists - login/pass is correct<br />
if (mysql_num_rows($result) == 1) {<br />
<br />
// initiate a session<br />
session_start();<br />
<br />
// register the user's ID and permission level<br />
session_register("SESSION_UID");<br />
session_register("SESSION_SITE");<br />
list($uid, $pass, $site) = mysql_fetch_row($result);<br />
$SESSION_UID = $uid;<br />
$SESSION_SITE = $site;<br />
<br />
// redirect to main menu page<br />
header("Location:$SESSION_SITE");<br />
mysql_free_result ($result); <br />
<br />
// close connection<br />
mysql_close($connection);<br />
<br />
} else {<br />
<br />
// redirect to error page<br />
header("Location:error.php");<br />
exit;<br />
<br />
} } ?]<!--content-->[? if (!$HTTP_POST_VARS['submit']) { ?]<br />
this says that if there is no value for 'submit', display all the code within the first set of brackets.<br />
<br />
[form name="form" method="post" action="[? echo $PHP_SELF ?]"] <br />
this says that once the 'submit' button is pressed to reload the same page. but now there is a value for 'submit', so it will skip the first section and start reading everything below [? } else { ?] .<br />
<br />
$connect = mysql_connect("localhost", USER, PASSWORD);<br />
$select = mysql_select_db(DATABASE, $connect);<br />
<br />
$query = "SELECT * FROM TABLE WHERE uid= \"$uid\" AND pass= \"$pass\"";<br />
$result = mysql_query($query, $connect);<br />
this opens a connection to your mysql server and runs a query to check to see if the user id and password match. replace USER, PASSWORD, DATABASE, and TABLE with your actual values.<br />
<br />
// initiate a session<br />
session_start();<br />
<br />
// register the user's ID and permission level<br />
session_register("SESSION_UID");<br />
session_register("SESSION_SITE");<br />
list($uid, $pass, $site) = mysql_fetch_row($result);<br />
$SESSION_UID = $uid;<br />
$SESSION_SITE = $site;<br />
to pass variables between pages and to validate that the person trying to access your client's site has the privileges to do so, you need to create a session.<br />
<br />
the other parts not listed are commented as to what they do.....<!--content-->so now you've got the initial login page set-up, but now you need to keep unauthorized people from accessing your client's site (stored in variable $SESSION_SITE).<br />
<br />
at the beginning of the page, you need to add a couple of lines of php code that check to see if a session has been initiated and who initiated it.<br />
<br />
the code to do this is provided below....<br />
<br />
some_clients_page.php<br />
<br />
[?<br />
<br />
session_start();<br />
if(!session_is_registered("SESSION_UID"))<br />
{<br />
header("Location:error.php");<br />
exit;<br />
}<br />
<br />
?]<!--content-->[?<br />
<br />
session_start();<br />
if(!session_is_registered("SESSION_UID"))<br />
{<br />
header("Location:error.php");<br />
exit;<br />
}<br />
<br />
this basically says that if no session has been initiated by SESSION_UID, then the person will be redirected to an error page.<br />
<br />
if everyting validates, then they will be able to view all the code below....<!--content-->maybe no one is posting their favorite code because HTML doesn't HAVE codes. There isn't much that is interesting and you won't learn anything special this way. What you want is javascript.<!--content-->
 
Back
Top