Jump to content

DEVILofDARKNESS

Members
  • Posts

    502
  • Joined

  • Last visited

    Never

Everything posted by DEVILofDARKNESS

  1. now I write every piece of my scripts on my own, but I see often people using a program like drupal, joomla, ... So I was wondering, is it better that I keep writing my own scripts, which ofcourse also trains me a bit, or would I maybe grab to some of those applications that can do the most for you? And if I would use so, which is the best for php and mysql?
  2. Now I'm using loads of tables to get everything in the right place. But that makes the code a bit of a mess, instead I would like to use div's with CSS, but how can you say in css the following: <table border='0' height='100%' width='100%'> <tr><td><table border='0' height='100%' width='50%'></td><td><table border='0' height='100%' width='50%'></td></tr> <tr>.....</tr> </table> I don't know how you can say a certain element should have that height relative to the computer screen.?
  3. But I would use a sticky sidebar, which scrolls with you. So The content in your sidebar is the same as the content in your footer?
  4. You mean I just should include my config file in the checkuserid.php script?
  5. Okay, What is the best to navigate, -a sticky sidebar or -a sticky footer (both ofcourse with CSS)
  6. You can do this, but you can also store some parameters in cookies or sessions, depending on how many in the same time their are needed, but url-encoding if ofcourse safer as plain-view.
  7. Okay the function didn't work at all , but I saw somewhere this: <?php session_start(); require_once 'config.php'; // our database settings $conn = mysql_connect($dbhost,$dbuser,$dbpass) or die('Error connecting to mysql'); mysql_select_db($dbname); $query = sprintf("SELECT id FROM users WHERE UPPER(username) = UPPER('%s')", mysql_real_escape_string($_SESSION['username'])); $result = mysql_query($query); list($userID) = mysql_fetch_row($result); if(!$userID) { // not logged in! header('Location: login.php'); ?> Why would this work(and it does), but the script I made doesn't? The script I wrote even don't have to connect to the database so its faster. <?php if(isset($_SESSION['userid'])){ $userid = $_SESSION['userid']; $query = "SELECT nation_id FROM users WHERE user_id = '$userid'"; $result = mysql_query($query); list($nationid) = mysql_fetch_row($result); }else{ header('location:./login.php'); } ?> I really don't get why I'm not redirected. If I use print_r($_SESSION), I get the right userid, but if I just print $_SESSION['userid'] it contains nothing!?
  8. this is not the right place to post this thread! I think you should post it in Website Critique
  9. should I make a function of it? functions.php <?php function checkuserid(){ if(isset($_SESSION['userid'])){ $userid = $_SESSION['userid']; if(isset($_SESSION['nationid'])){ $nationid = $_SESSION['nationid']; }elseif(isset($_GET['nationid'])){ $nationid = $_GET['nationid']; }else{ $query = "SELECT nation_id FROM users WHERE user_id = '$userid'"; $result = mysql_query($query); list($nationid) = mysql_fetch_row($result); } }else{ header('location:./login.php'); } } ?>
  10. array([userid] => 19 .... So the userid is set, the nationid isn't, but why won't the script give the $userid to the page if I include checkuserid.php in that page?
  11. Okay I had made a php script to check if a user is valid. I include it in every page, except the homepage,login and register ofcourse, but I found out that $userid and $nationid, don't contain a value, altough I'm not redirected to the loginpage... Can somebody please say what I've done wrong? checkuserid.php <?php if(isset($_SESSION['userid'])){ $userid = $_SESSION['userid']; if(isset($_SESSION['nationid'])){ $nationid = $_SESSION['nationid']; }elseif(isset($_GET['nationid'])){ $nationid = $_GET['nationid']; }else{ $query = "SELECT nation_id FROM users WHERE user_id = '$userid'"; $result = mysql_query($query); list($nationid) = mysql_fetch_row($result); } }else{ header('location:./login.php'); } ?>
  12. Yeah I agree with Ken2k7. But I think these tables are good enough right now. Thanks everybody
  13. Okay, I've made a register-page, but if I test it out on my localhost, it always add two nations, two users (all with the same name but with a different id). I can't see why it inserts 2 rows each time so what is wrong, or how can I figure this out? <?php session_start(); require_once './config.php'; $page = $_GET['page']; $prev = $_SESSION['prev']; if(isset($_POST['page1'])){ header('location:./register.php?page=2'); }elseif(isset($_POST['page2leader'])){ if($_POST['regradiolead']){ $_SESSION['regradiolead'] = $_POST['regradiolead']; header('location:./register.php?page=31'); }else{ header('location:./register.php?page=32'); } }elseif(isset($_POST['page2civilian'])){ header('location:./register.php?page=32'); }elseif(isset($_POST['page31'])){ $_SESSION['nationname'] = $_POST['nationname']; $_SESSION['username'] = $_POST['username']; $_SESSION['pass'] = $_POST['password']; header('location:./register.php?page=41'); }elseif(isset($_POST['page32'])){ $_SESSION['regradiociv'] = $_POST['regradiociv']; header('location:./register.php?page=42'); }elseif(isset($_POST['page41'])){ header('location:./login.php'); }elseif(isset($_POST['page42'])){ $_SESSION['username'] = $_POST['username']; $_SESSION['pass'] = $_POST['password']; header('location:./register.php?page=52'); }elseif(isset($_POST['page52'])){ header('location:./login.php'); } ?> <html> <head><title>Register -- Europia</title></head> <body> <?php switch($page){ case 1: echo "It's the end of year 9 from the galactic calendar, after 9 year of peace, a new generation of leaders has been born, ready to overthrow the current leaders and ready to rule over the world. You're one of these born leaders and you have the power and the knowledge to start an own nation. Maybe you're rich enough to buy right now a region, or maybe you will have to wait and take your chance later. You have 150 Salidrian-Zet (Salidrian-Zet (S~Z) is the currency In Europe since year 1), IF YOU THINK YOUR READY<br><form action='' method='post'><input type='submit' name='page1' value='GO ON'></form>"; $_SESSION['prev'] = 1; break; case 2: if($prev=='1'){ $query = "SELECT * FROM regions WHERE in_use = 'No'"; $result = mysql_query($query); echo "<form action='' method='POST'><table border='0'><form action='' method='POST'>"; echo "<tr><td>Name</td><td> </td></tr>"; while($regions = mysql_fetch_array($result)){ echo "<tr><td>" . $regions['region_name'] . "</td><td><input type='radio' name='regradiolead' value='" . $regions['region_id'] . "'></td></tr>"; } echo "<tr><td colspan='2'>If nothing appears above this text it means that all regions are in use, you can now do two things, 1) Wait untill their are added new regions and be verry fast to take them (just go away) 2) You can start as a civilian of someone else his nation and plan a tactic to do a coup! (CIVILIAN)</td></tr>"; echo "<tr><td><input type='submit' name='page2leader' value='LEADER'></td><td><input type='submit' name='page2civilian' value='CIVILIAN'></td></tr></form>"; $_SESSION['prev'] = 2; }else{ echo 'Please Start from page 1!'; } break; case 31: if($prev == '2'){ echo "<form action='' method='POST'><table border='0'><form action='' method='POST'>"; echo "<tr><td>Nation Name:</td><td><input type='text' name='nationname'></td></tr> <tr><td>User Name:</td><td><input type='text' name='username'></td></tr> <tr><td>Password:</td><td><input type='password' name='password'></td></tr> <tr><td colspan='2'><input type='submit' name='page31' value='GO ON'></td></tr>"; echo "</table></form>"; $_SESSION['prev'] = 31; }else{ echo "Please Start From Page 1"; } break; case 32: if($prev == '2'){ echo "<form action='' method='POST'><table border='0'><form action='' method='POST'>"; $query = "SELECT * FROM regions WHERE in_use = 'Yes'"; $result = mysql_query($query); while($regions = mysql_fetch_array($result)){ echo "<tr><td>" . $regions['region_name'] . "</td><td><input type='radio' name='regradiolead' value='" . $regions['region_id'] . "'></td></tr>"; } $result = mysql_query($query); echo "<tr><td colspan='2'><input type='submit' name='page32' value='FINISH'></td></tr>"; echo "</table></form>"; $_SESSION['prev'] = 32; }else{ echo "Please Start From Page 1"; } break; case 41: if($prev == '31'){ $nationname = $_SESSION['nationname']; $regionid = $_SESSION['regradiolead']; $username = $_SESSION['username']; $pass = $_SESSION['pass']; $password = md5('f4lcon$€' . $pass . 'l1ve€$'); $query = "INSERT INTO nations(nation_name,nation_capital,leader) VALUES ('$nationname','$regionid','1')"; $result = mysql_query($query); $query = "SELECT nation_id FROM nations WHERE nation_name = '$nationname'"; $result = mysql_query($query); list($nationid) = mysql_fetch_row($result); $query = "UPDATE regions SET nation_id = '$nationid' WHERE region_id='$regionid'"; $result = mysql_query($query); $query = "UPDATE regions SET in_use = 'Yes' WHERE region_id='$regionid'"; $result = mysql_query($query); $query = "INSERT INTO users(user_name,user_pass,nation_id,leader,money) VALUES ('$username','$password','$nationid','Yes','150')"; $result = mysql_query($query); $query = "SELECT user_id FROM users WHERE user_name = '$username'"; $result = mysql_query($query); list($userid) = mysql_fetch_row($result); $query = "UPDATE nations SET leader = '$userid' WHERE nation_id='$nationid'"; $result = mysql_query($query); echo "<form action='' method='POST'><table border='0'><form action='' method='POST'>"; echo "<tr><td>Okay, All is updated, and your ready to rule over your brand new nation!<br>The only thing that you have to do is login and Play!!</td></tr> <tr><td><input type='submit' name='page41' value='LOGIN'></td></tr>"; echo "</table></form>"; }else{ echo "Please Start From Page 1"; } break; case 42: if($prev == '32'){ echo "<form action='' method='POST'><table border='0'><form action='' method='POST'>"; echo "<tr><td>User Name:</td><td><input type='text' name='username'></td></tr> <tr><td>Password:</td><td><input type='password' name='password'></td></tr> <tr><td colspan='2'><input type='submit' name='page42' value='FINISH'></td></tr>"; echo "</table></form>"; $_SESSION['prev'] = 42; }else{ echo "Please Start From Page 1"; } break; case 52: if($prev == '42'){ $username = $_SESSION['username']; $pass = $_SESSION['pass']; $password = md5('f4lcon€$' . $pass . 'l1ve€$'); $nationid = $_SESSION['regradiociv']; $query = "INSERT INTO users(user_name,user_pass,nation_id,leader,money) VALUES ('$username','$password','$nationid','No','150')"; $result = mysql_query($query); echo "<form action='' method='POST'><table border='0'><form action='' method='POST'>"; echo "<tr><td>Okay, All is updated, and your ready to start your live as a civillian. Just login and Play!!</td></tr> <tr><td><input type='submit' name='page52' value='LOGIN'></td></tr>"; echo "</table></form>"; }else{ echo "Please Start From Page 1"; } break; default: echo "Oops, you have to go to <a href='./register.php?page=1'>page 1</a> to register!."; break; } ?> </body> </html>
  14. Okay, because I have a lot of trouble with header('location') (headers are already sent,...) I want to know if there is some kind of equivalent, which can pass these problems. Probably not, but I hope there is one.
  15. I think it's normalized, although I can't use foreign keys because I used MyIsam as storage engine instead of InnoDB, which is the only one that can handle foreign keys in PhpMyadmin. I just ask this question, because In my previous projects I just started with the code and from time to time I had to change whole the databse. And I want to make it as much easy as it can.
  16. One thing I see that can be wrong is the following: { $good_data[$field] = strip_tags(trim($value)); } why do you use {}? if it isn't needed And like you can see in your own code their are some braces with a blue color, it means that it stands alone,!
  17. I really would install Wamp(Windows, Apache, Mysql, PHP) or Xampp(Windows-Linux-Macintosh; Apache, Mysql, PHP, Perl) It is really easy to understand the installer and it is all installed without the need to set it up all apart.
  18. Okay, I started over completely with my idea of browsergame, because the mysql-tables sucked and it was terrible to make a code to generate the right value. So my question is: Are these good tables? NATIONS nation_id nation_name nation_capital nation_money leader_id PACTS user_id1 user_id2 pact_type WEAPONS weapon_id wepaon_name weapon_price TECHNOLOGIES technology_id technology_name technology_price REGIONS region_id region_name nation_name RESEARSHED technology_id nation_id REGION_WEAPONS region_id weapon_id ammount USERS user_id user_name user_pass nation_id leader <= "Yes" or "No"
  19. I think it's a lot easier for those guys, if they had something to searsh in (like the code) so they can say what you've done wrong, or you have to add.
  20. DEVILofDARKNESS

    python?

    Okay, I just want to make desktop applications, that run both on linux(ubuntu) and on windows (XP) Which language is designed for this? Python? C/C++? Perl? I'm currently making my desktop apps with bash, which is ofcourse not the same, and I want to make real,(good) ones; Thanks
×
×
  • 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.