Jump to content

Is my code good ? pls have a look...


jd2007

Recommended Posts

<?php session_start();
header("Cache-control: private");
?>

<html>
<head>
<title>Nintendo ROMS</title>
<style type="text/css">
body
{
background-color:#00CCFF;
}
#logo
{
position:absolute;
top:0px;
left:0px;
index:0
}
#login
{
position:absolute;
top:0;
left:700;
background-color:#003366;
min-width: 320px;
min-height: 99px;
}
#logged
{
position:absolute;
top:0;
left:700;
background-color:#003366;
min-width: 320px;
min-height: 100px;
}
#username
{
position:absolute;
top:25;
left:25;
font-weight:bold;
color:#FFFFFF;
}
#username_input
{
position:absolute;
top:25;
left:99;
border-right-style:solid;
border-right-color:#000066;
border-bottom-style:solid;
border-bottom-color:#000066;
border-top-style:solid;
border-top-color:#000066;
border-left-style:solid;
border-left-color:#000066;
}
#password
{
position:absolute;
top:45;
left:25;
font-weight:bold;
color:#FFFFFF;
}
#password_input
{
position:absolute;
top:45;
left:99;
border-right-style:solid;
border-right-color:#000066;
border-bottom-style:solid;
border-bottom-color:#000066;
border-top-style:solid;
border-top-color:#000066;
border-left-style:solid;
border-left-color:#000066;
}
#login_button
{
position:absolute;
top:33;
left:250;
width:60;
height:25;
background-color:#00CCCC;
border-style:groove;
border-color:#333333;
}
#guest
{
position:absolute;
top:0;
left:800;
z-index:2;
color:#FFFF99;
}
a.a
{
position:absolute;
top:70;
left:755;
color:#FFCC00;
}
a.b
{
position:absolute;
top:70;
left:850;
color:#FFCC00;
}
#add
{
position:relative;
top:60;
left:0;
border-style:solid;
border-color:#660066;
padding-top:30px;
padding-bottom:30px;
padding-left:30px;
}
#gname
{
position:absolute;
top:60;
left:30;
}
#gname_input
{
position:absolute;
top:60;
left:135;
border-top-style:solid;
border-top-color:##C0C0C0;
border-left-style:solid;
border-left-color:##C0C0C0;
border-right-style:solid;
border-right-width:3;
border-right-color:#333366;
border-bottom-style:solid;
border-bottom-width:3;
border-bottom-color:#333366;
}
#grom
{
position:absolute;
top:85;
left:30;
}
#grom_input
{
position:absolute;
top:85;
left:135;
border-top-style:solid;
border-top-color:##C0C0C0;
border-left-style:solid;
border-left-color:##C0C0C0;
border-right-style:solid;
border-right-width:3;
border-right-color:#333366;
border-bottom-style:solid;
border-bottom-width:3;
border-bottom-color:#333366;
}
#glink
{
position:absolute;
top:60;
left:295;
}
#glink_input
{
position:absolute;
top:60;
left:445;
border-top-style:solid;
border-top-color:##C0C0C0;
border-left-style:solid;
border-left-color:##C0C0C0;
border-right-style:solid;
border-right-width:3;
border-right-color:#333366;
border-bottom-style:solid;
border-bottom-width:3;
border-bottom-color:#333366;
}
#glang
{
position:absolute;
top:85;
left:295;
}
#glang_select
{
position:absolute;
top:85;
left:370;
}
#logged1
{
position:absolute;
top:18;
left:30;
font-size:large;
color:#FFFFFF;
font-style:italic;
}
#logged2
{
position:relative;
top:42;
left:30;
font-size:large;
color:#FFFFFF;
font-style:italic;
}
#navbar
{
position:absolute;
top:99;
left:0;
background-color:#FF3366;
min-width:1030;
max-height:37;
}
a.navbar2
{
font-weight:bold;
color:#FFCCCC;
}
</style>

</head>
<body>

<!--logo-->
<img  id="logo" src="images/logo.png" alt="Nintendo ROMS Logo" width="700" height="100">



<!--login/logged area-->
<?php

if ($_SESSION["username"])
{
echo "<div id=login>";
echo "<div id=logged1><b>Hi, $_SESSION[username]</b></div>
      <div id=logged2><b>You have $_SESSION[credits] download credits.</b></div>";
echo "</div>";       
}
else 
{
echo "
<h4 id=guest>Welcome, Guest !</h4>
<form id=login method='post' action='loggingin.php'>
<label for=username id=username>Username:</label><input id=username_input type='text' name='login_username'><br><br>
<label for=password id=password>Password:</label><input id=password_input type='password' name='login_password'><br><br>
<input type='submit' id='login_button' value='Log In'>
</form><br><br>
<span ><a class='a' href='register.html'>Register Here</a></span>
<span ><a class='b' href=''>Forgot Your Login ?</a></span>";
}

?>
</span>
<div id='navbar'><pre>  <a id='navbar2' href='#add'><b>Add A ROM</b></a> | <a id='navbar2' href='about.php'>About</a> | <a id='navbar2' href='faq.php'>FAQ</a>  </pre></div>
<!--game list-->
<?php 
echo $_GET["add"];
echo $_GET["error3"];
echo $_GET["var10"];
echo $_GET["var11"];
echo $_GET["not"];
echo $_GET["no"];
echo $_GET["mf"];
echo $_GET["ue"];
echo $_GET["nv"];
echo $_GET["nf"];
$top=160;
if (!$_SESSION["username"])

{
include("connect.php");
for ($_id=1; $_id<9; $_id++) {
$query="SELECT name, worked, notworked, romno FROM games WHERE id='$_id'";
$result=mysql_query($query);
$row=mysql_fetch_row($result);
if (!$row)
{

}
else
{
$total=$row[1]+$row[2];
echo "<pre>  
<div style='position:absolute; top:$top; font-weight:bold;'><a href='downloadrom.php?id=$_id'>$row[0]</a></div> <div style='position:absolute; top:$top; left:235; font-weight:bold;'><a href='deletegames.php?var5=$_id'>[x]</a></div> <div style='position:absolute; top:$top; left:265; font-weight:bold;'><a href='editgames.php?vari=$_id'>[-]</a></div>    <div style='position:absolute; top:$top; left:325;font-weight:bold;'>$row[3]</div>    <div style='position:absolute; top:$top; left:375; font-weight:bold;'>This link worked for $row[1] out of $total people.</div>  <div style='position:absolute; top:$top; left:710; font-weight:bold;'>DID THIS LINK WORK FOR YOU ?</div> <div style='position:absolute; top:$top; left:945;font-weight:bold;'><a href='worked.php?var=$_id'>YES</a></div>      <div style='position:absolute; top:$top; left:975;font-weight:bold;'><a href='notworked.php?var2=$_id'>NO</a></div></pre>";
$top+=30;
}
}
}
else if ($_SESSION["admin"]==0)
{
include("connect.php");
for ($_id=1; $_id<10; $_id++) {
$query="SELECT name, worked, notworked, romno, link FROM games WHERE id='$_id'";
$result=mysql_query($query); 

$row = mysql_fetch_row($result);
if (!$row)
{

}
else
{
$total=$row[1]+$row[2];

//<span style='background-color:#CCCCCC;'>

echo "<pre>
  
<div style='position:absolute; top:$top; font-weight:bold;'><a href='downloadrom.php?id=$_id'>$row[0]</a></div><div style='position:absolute; top:$top; left:325;font-weight:bold;'>$row[3]</div>    <div style='position:absolute; top:$top; left:375; font-weight:bold;'>This link worked for $row[1] out of $total people.</div>  <div style='position:absolute; top:$top; left:710; font-weight:bold;'>DID THIS LINK WORK FOR YOU ?</div> <div style='position:absolute; top:$top; left:945;font-weight:bold;'><a href='worked.php?var=$_id'>YES</a></div>      <div style='position:absolute; top:$top; left:975;font-weight:bold;'><a href='notworked.php?var2=$_id'>NO</a></div></pre>";
$top+=30;
}
//</span>
//<br>
}
}
else if ($_SESSION["admin"]==1)
{
include("connect.php");
for ($_id=1; $_id<=9; $_id++) {
$query="SELECT name, worked, notworked, romno, link FROM games WHERE id='$_id'";
$result=mysql_query($query);
$row=mysql_fetch_row($result);

if (!$row)
{

}
else
{
$total=$row[1]+$row[2];
echo "<span style='font-weight:bold;'>";
echo "<pre>
   
<div style='position:absolute; top:$top; font-weight:bold;background-color:#C0C0C0;width:1000'><a href='downloadrom.php?id=$_id'>$row[0]</a></div> <div style='position:absolute; top:$top; left:235; font-weight:bold;'><a href='deletegames.php?var5=$_id'>[x]</a></div> <div style='position:absolute; top:$top; left:265; font-weight:bold;'><a href='editgames.php?vari=$_id'>[-]</a></div>    <div style='position:absolute; top:$top; left:325;font-weight:bold;'>$row[3]</div>    <div style='position:absolute; top:$top; left:375; font-weight:bold;'>This link worked for $row[1] out of $total people.</div>  <div style='position:absolute; top:$top; left:710; font-weight:bold;'>DID THIS LINK WORK FOR YOU ?</div> <div style='position:absolute; top:$top; left:945;font-weight:bold;'><a href='worked.php?var=$_id'>YES</a></div>      <div style='position:absolute; top:$top; left:975;font-weight:bold;'><a href='notworked.php?var2=$_id'>NO</a></div></div></pre>";
//echo "<br>";

echo "</span>";
$top+=30;
}
}
}
else
{

}
?>
<a name="add">
<?php
echo "<div id='add'>";
$error=$_GET["error"];
$error2=$_GET["error2"];
echo "<font color=red>".$error."</font>";
echo "<font color=red>".$error2."</font>";
$w=rand(1,10);
$w=substr($w,0,2);
$y=md5(rand(1,10));
$y=substr($w,0,2);
$z=$w.$y;
echo "
<form method='post' action='addarom.php?var3=$z'>
<label id=gname for=gname><b>Game Name:</b></label> <input id=gname_input type='text' name='gamename'>
<label id=glink for=glink><b>Game Download Link:</b></label> <input id=glink_input type='text' name='gamelink'><br><br>
<label id=grom for=grom><b>ROM Number:</b></label> <input id=grom_input type='text' name='gameromno'>
<label id=glang for=grom><b>Language:</b></label>"; 
$lang=array('English', 'Japanese', 'Other');
echo "<select id=glang_select name='language'>";
for ($i=0; $i<count($lang); $i++) {



echo "<option value=$lang[$i]>$lang[$i]</option>";



}
echo "</select>";
echo "<br><br>";

echo "<b>Enter this code</b> $z <b>here:</b>";
echo "<input type='text' name='scode'>";
        /*
        header ("Content-type: image/png");
        $img_handle = ImageCreate (230, 20) or die ("Cannot Create image");
        $back_color = ImageColorAllocate ($img_handle, 0, 10, 10);
        $txt_color = ImageColorAllocate ($img_handle, 233, 114, 191);
        ImageString ($img_handle, 31, 5, 5,  $z, $txt_color);
        ImagePng ($img_handle);
        */
echo "<input type='submit' value='Add'>";        
echo "</form>";
echo "</div>";
?>
</a>
</body>
</html>

 

is the code above good codes ? tell me what do you think ? since i'm not done with the styling , i'll put the css in another file later ? what can i do to make the above code object oriented ?

Link to comment
Share on other sites

Indenting your code would make it more readable.  There are many styles of indentation, for example:

 

while ($foo) {
  print "foo\n";
}
while ($foo)
{
  print "foo\n";
}

 

Otherwise it is very difficult to see where an "if" or "for" starts and ends.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.