Jump to content

Proletarian

Members
  • Posts

    97
  • Joined

  • Last visited

Everything posted by Proletarian

  1. SEE IF YOU CAN SPOT THE DIFFERENCE. YOUR CODE... <?php include("include/session.php"); ?> <? if($session->logged_in){ echo "<h1>Logged In</h1>"; echo "Welcome <b>$session->username</b>, you are logged in. <br><br>" ."[<a href=\"userinfo.php?user=$session->username\">My Account</a>] " ."[<a href=\"useredit.php\">Edit Account</a>] "; if($session->isAdmin()){ echo "[<a href=\"admin/admin.php\">Admin Center Database</a>] "; echo "[<a href=\"etomitecomplete/admin/index.php\">Admin Center Files</a>] "; } echo "[<a href=\"process.php\">Logout</a>]"; } else{ ?> <h1>Login</h1> <? if($form->num_errors > 0){ echo "<font size=\"2\" color=\"#ff0000\">".$form->num_errors." error(s) found</font>"; } ?> <form action="process.php" method="POST"> <table align="left" border="0" cellspacing="0" cellpadding="3"> <tr><td>Username:</td><td><input type="text" name="user" maxlength="30" value="<? echo $form->value("user"); ?>"></td><td><? echo $form->error("user"); ?></td></tr> <tr><td>Password:</td><td><input type="password" name="pass" maxlength="30" value="<? echo $form->value("pass"); ?>"></td><td><? echo $form->error("pass"); ?></td></tr> <tr><td colspan="2" align="left"><input type="checkbox" name="remember" <? if($form->value("remember") != ""){ echo "checked"; } ?>> Remember me next time <input type="hidden" name="sublogin" value="1"> <input type="submit" value="Login"></td></tr> <tr><td colspan="2" align="left"><br><font size="2">[<a href="forgotpass.php">Forgot Password?</a>]</font></td><td align="right"></td></tr> <tr><td colspan="2" align="left"><br>Not registered? <a href="register.php">Sign-Up!</a></td></tr> </table> </form> <? } ?> YOUR FIXED CODE... <?php include("include/session.php"); ?> <?php if($session->logged_in){ echo "<h1>Logged In</h1>"; echo "Welcome <b>$session->username</b>, you are logged in. <br><br>" ."[<a href=\"userinfo.php?user=$session->username\">My Account</a>] " ."[<a href=\"useredit.php\">Edit Account</a>] "; if($session->isAdmin()){ echo "[<a href=\"admin/admin.php\">Admin Center Database</a>] "; echo "[<a href=\"etomitecomplete/admin/index.php\">Admin Center Files</a>] "; } echo "[<a href=\"process.php\">Logout</a>]"; } else{ ?> <h1>Login</h1> <?php if($form->num_errors > 0){ echo "<font size=\"2\" color=\"#ff0000\">".$form->num_errors." error(s) found</font>"; } ?> <form action="process.php" method="POST"> <table align="left" border="0" cellspacing="0" cellpadding="3"> <tr><td>Username:</td><td><input type="text" name="user" maxlength="30" value="<? echo $form->value("user"); ?>"></td><td><? echo $form->error("user"); ?></td></tr> <tr><td>Password:</td><td><input type="password" name="pass" maxlength="30" value="<? echo $form->value("pass"); ?>"></td><td><? echo $form->error("pass"); ?></td></tr> <tr><td colspan="2" align="left"><input type="checkbox" name="remember" <? if($form->value("remember") != ""){ echo "checked"; } ?>> Remember me next time <input type="hidden" name="sublogin" value="1"> <input type="submit" value="Login"></td></tr> <tr><td colspan="2" align="left"><br><font size="2">[<a href="forgotpass.php">Forgot Password?</a>]</font></td><td align="right"></td></tr> <tr><td colspan="2" align="left"><br>Not registered? <a href="register.php">Sign-Up!</a></td></tr> </table> </form> <?php } ?>
  2. Try chaning $dif = $cur_tm-$tm; to $dif = $tm - $cur_tm;. I'm going to take a wild guess and say that the reason you're getting -32xx is because you're subtracting a larger number (future time) from a smaller number (current time). Switching the variables around, you should get a positive result. If not, I dunno.
  3. It's funny cuz I'm coming at it from the opposite point as you. I learned C++ first and am now learning PHP. But you are right, learning a different language just to learn the concept of object oriented programming is counter-productive. I just have a bias towards my perspective.
  4. if ($your_url_exists && file_exists($your_url) == true) // DO NOT POST else // CONTINUE POSTING However you decide to implement the posting of the URL, you would put it in that ELSE block. Just because the condition tests false doesn't mean your application stops working.
  5. If you're testing a true/false condition, you really don't need an else if statement, because either it's true or it's not, so you just need an else block. Basically, the only time you would want an if...else if is if you're testing for multiple conditions. if condition A // then whatever for condition A else if condition B // then whatever for condition B else if condition C // then whatever for condition C else // default Since you're only testing for true/false, you just need an if...else. if true // then it's true else // it's obviously false Whatever you want. I don't know how your application is supposed to work. This part is your job to figure out.
  6. If you want to learn classes, I suggest learning C++. I find that classes in C++ make a lot more sense than in PHP (such as the "self" keyword). From there, it's an easy transition into PHP. And just to further your quest in education, and to emphasize my suggestion, check this page out: https://bugs.php.net/bug.php?id=30934
  7. You don't have to learn new code. Constants are essentially the same thing as variables, yes, except constants cannot change. They are just used in different contexts, and that's all you need to know; i. e., when to use what where for whatever reason.
  8. The point of inheritance is to specialize a base class. You can have multiple layers of inheritance, but it's generally not a good idea to extend more than 1 or 2 levels down.
  9. You're extending LifeForm from Animal, which is extended from Dog. You have your base class wrong. Basically, Dog is your LifeForm's ancestor, which means LifeForm can call those inherited properties from Dog. Animal should be your base class. Dog and LifeForm should extend animal. Now, Dod and LifeForm share an ancestor, but do not share each other's unique class properties.
  10. Is the value of Pi ever going to change?
  11. Actually, the suggestion I made wasn't well thought out. Instead, do this: if ($your_url_exists && file_exists($your_url) == true) { trigger_error('exists!'); } else { // continue posting } Don't use your function because there already is a function that does what you need; i.e., it's redundant.
  12. Change... if ($your_url_exists && http_file_exists($your_url) == true) { trigger_error('exists!'); } else if ($your_url_exists && http_file_exists($your_url) == false) { trigger_error('doesnt exist..'); } To... if ($your_url_exists && http_file_exists($your_url) == true) { trigger_error('exists!'); } else { // whatever code you have to continue posting } Also, I would rewrite your function like this... function http_file_exists($url) { if (file_exists($url)) { return true; } return false; }
  13. When in doubt, test your hypothesis.
  14. You're going to have to save your random variables on the server in a file or in a database and recall them when the user input is sent back for comparison.
  15. I'm curious. Why are you using a global $connection variable? Why not just pass it as a parameter? Also, I suggest changing your confirm_query($) function to return a value, instead of dying, so you can handle the error better when it fails.
  16. Are your mysql_query()'s returning TRUE or FALSE? Particularly, is the query with the UPDATE returning TRUE or FALSE? It's hard to tell what you're trying to do with all the HTML and PHP mixed together like it is and without comments. Try seperating the PHP into functions that can be called in the HTML so the HTML (presentation) isn't cluttered with PHP (execution). And add comments that explain what you're trying to accomplish with each line.
  17. Change... echo '<form action = "polls" method = "post">'; ...to... echo '<form action = "polls.php" method = "post">'; ...and see if that works.
  18. Find this line: <textarea name=\"overall_comments\" id=\"overall_comments\" cols=\"35\" rows=\"7\" value=".$line['english_overall_commnents'].'"></textarea> Do you see the extra apostrophe? value=".$line['english_overall_commnents'].'"></textarea> Do you see it now? It's highlighted red. commnents'].'"></textarea> Find this apostrophe and delete it and I'll bet it will work.
  19. Obviously, the class parameter is going to need a variable as its value. Your function would determine via a conditional statement whether this variable is "notranslate" or "notranslate error". Then however you execute the code you should get the results you want. PSUEDO CODE EXAMPLE function whatever(x) { if (x == true) { var = "notranslate"; } else { var = "notranslate error"; } return var; } class = whatever(x); // rest of code You find the x variable based on whatever check you are doing to determine what the styling should be. I hope this helps get you going in the right direction.
  20. Instead of... $prefix_length = 10; $steam_suffixchars = ($char_total - $prefix_length); $char_total = strlen($inputid); ...try... $prefix_length = 10; $char_total = strlen($inputid); $steam_suffixchars = ($char_total - $prefix_length);
  21. I'm not sure what your question is exactly, to be honest. If the height is 100%, then the height is 100% relative to the viewport size, plus margin, padding, and border values. That being said, I don't think you need to have "min-height:100%" if you have "height:100%". If you want the height to be a certain constant, then just remove the height values on the padding and margin properties (i.e., padding: 0, 1em, 0, 1em). I hope this helps.
×
×
  • 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.