Jump to content

Stalingrad

Members
  • Posts

    123
  • Joined

  • Last visited

Everything posted by Stalingrad

  1. Also, what would the variable $field be set as? Would I set that as the $petname variable? thanks!
  2. is that if statement sayign it has bad characters in it, or is it sayign that the field contains only a-z and _? thank you!
  3. Hi all! I am building a website, and the users can create a pet name. I only want them to be able to use letters, numbers and underscores in the names. How can I do this? Thanks! I would also be using this for the usernames as well. Here is my pet creation code: adopt.php: <?php session_start(); include("config536.php"); ?> <html> <head> <link rel="stylesheet" type="text/css" href="style.css" /> </head> <?php if(!isset($_SESSION['username'])) { echo "<banner></banner><ubar><a href=login.php>Login</a> or <a href=register.php>Register</a></ubar><content><center><font size=6>Error!</font><br><br>You are not Logged In! Please <a href=login.php>Login</a> or <a href=register.php>Register</a> to Continue!</center></content><content><center><font size=6>Messages</font><br><br></center></content>"; } if(isset($_SESSION['username'])) { echo "<banner></banner><nav>$shownavbar</nav><ubar>$ubear</ubar><content><center><font size=6>Adopt a Pet</font><br><br>"; $thedateis = date('F jS, Y'); $getpetid = $_GET['petid']; $adopt = $_POST['submit']; $petname = $_POST['petname']; $petgen = $_POST['gender']; $thebq = "SELECT * FROM pets WHERE petid='$getpetid'"; $theb = mysql_query($thebq); while($prr = mysql_fetch_array($theb)) { $pid = $prr['petid']; $species = $prr['pname']; $number = $prr['number']; } if(!isset($getpetid)) { $pq = "SELECT * FROM pets WHERE petid != '0'"; $p = mysql_query($pq); while($pr = mysql_fetch_array($p)) { $pid = $pr['petid']; $ptype = $pr['pname']; $im = $pr['pimage']; $number = $pr['number']; $limited = $pr['limited']; $types = $pr['types']; echo "<b>$ptype</b><br><a href=?petid=$pid><img src=/images/pets/$im></a><br>Number: $number<br><br>"; } } if(isset($getpetid)) { ?> <form action="<?php echo "$PHP_SELF"; ?>" method="POST"> Please select a Name: <input type="name" name="petname" maxlength="15"><br> Pet Gender: <select name="gender"><option value="female">Female</option><option value="male">Male</option><br><br><input type="submit" name="submit" value="Adopt Pet"></form> <?php $checkitq = mysql_query("SELECT * FROM userpets WHERE userpetname='$petname'"); $gcheckit = @mysql_num_rows($checkitq); $tq = "SELECT * FROM users WHERE username='$showusername'"; $t = mysql_query($tq); while($rw = mysql_fetch_array($t)) { $grabnum = $rw['pets']; } if(isset($adopt)) { if($grabnum >= "4") { echo "<font color=red>Error! You already have 4 pets.</font>"; } if($petname == "") { echo "<font color=red>Error! Please type in a name for your pet.</font>"; } if($qcheckit == "1") { echo "<font color=red>Error! That pet name already exists!</font>"; } if($gcheckit == "0" && $petname != "" && $grabnum < "4") { mysql_query("INSERT INTO userpets (owner, userpetname, userpetspecies, userpettype, petdatecreated, gender, strength, defence, health, level, booksread, smart, hunger) VALUES ('$showusername', '$petname', '$species', 'Normal', '$thedateis', '$petgen', '1', '1', '10', '1', '0', 'Normal', 'Full')"); mysql_QUERY("UPDATE users SET pets=pets+1 WHERE username='$showusername'"); echo "<font color=green>Success! Your pet has been created!</font>"; } } } } ?> </html> Thanks in advance for the help everyone!!
  4. Hi All! I've written up a script for my website. It\ is basically a virtual job quest. My queries are all correct it just isn't registering the variable for the session. It is $-SESSION[theid']. I want to be bale to use it in my table but I get an error. How do I write this in my SQL query for it to work. The page (when no errors), doesn't show my data. Here is my ocde: <?php session_start(); include("config536.php"); ?> <html> <head> <link rel="stylesheet" type="text/css" href="style.css" /> </head> <?php if(!isset($_SESSION['username'])) { echo "<ubar><a href=login.php>Login</a> or <a href=register.php>Register</a></ubar><content><center><font size=6>Error!</font><br><br>You are not Logged In! Please <a href=login.php>Login</a> or <a href=register.php>Register</a> to Continue!</center></content><content><center><font size=6>Messages</font><br><br></center></content>"; } if(isset($_SESSION['username'])) { echo "<nav>$shownavbar</nav><ubar><img src=/images/layout/player.gif><a href=status.php>$showusername</a>.......................<img src=/images/layout/coin.gif> $scredits</ubar><content><center><font size=6>Basic Quests</font><br><br>"; $startjob = $_POST['submit']; $jobq = "SELECT * FROM jobs WHERE username='$showusername'"; $job = mysql_query($jobq); $jobnr = mysql_num_rows($job); if($jobnr == "0") { ?> <form action="<?php echo "$PHP_SELF"; ?>" method="POST"> <input type="submit" name="submit" value="Start Job"></form> <?php } if(isset($startjob)) { $initemidq = "SELECT * FROM items ORDER BY RAND() LIMIT 1"; $initemid = mysql_query($initemidq); while($ir = mysql_fetch_array($initemid)) { $ids = $ir['itemid']; } mysql_query("INSERT INTO jobs (username, item, time, completed) VALUES ('$showusername', '$ids', 'None', 'No')"); $wegq = "SELECT * FROM items WHERE itemid='$ids'"; $weg = mysql_query($wegq); while($wg = mysql_fetch_array($weg)) { $im = $wg['image']; $nm = $wg['name']; $id = $wg['itemid']; } $_SESSION['theid'] = $id; echo "<font color=green>Success! You have started this Job!</font><br><br>Please bring me this item: <b>$nm</b><br><br><img src=/images/items/$im><br><br><br>"; echo $_SESSION['theid']; } if($jobnr == "1") { $finish = $_POST['finish']; $okgq = "SELECT * FROM items WHERE itemid='$yes'"; $ok = mysql_query($okgq); while($ya = mysql_fetch_array($ok)) { $okname = $ya['name']; $okid = $ya['itemid']; $okimage = $ya['image']; } echo "Where is my <b>$okname</b>?<br><br><img src=/images/items/$okimage><br><br><br>"; echo $_SESSION['theid']; ?> <form action="<?php echo "$PHP_SELF"; ?>" method="POST"> <input type="submit" name="finish" value="I have the Item"></form> <?php } } if(isset($finish)) { $cinq = "SELECT * FROM uitems WHERE theitemid='$_SESSION[theid]'"; $cin = mysql_query($cinq); $connr = mysql_num_rows($cin); if($connr != "0") { echo "<font color=green>Success! You have the item.</font>"; } else { echo "<font color=red>Error! You do not have my item!</font>"; } } ?> . I basically just want to know how I can set this session as a variable. Also..I have a user login on every page and I want to be able to destroy JUST THE "theid" session and NOT the username session. How would I do that too? thanks for the help in advance!
  5. THSI IS URGENT!! NEEDS TO BE DONE WITHIN NEXT FEW MINUTES! I HAVE BEEN WORKING ON IT FOR WEEKS NOW!!! I have a url get variable from the "uitems" table. it is stored in the url and carries over to the next page. I have tables: "uitems" and "items" the "items" table stors all of the info about the items. the "uitems" table stores where the item is for each certain user. I want to be able to grab the item information from the "items" table with the variable from the "uitems" table. the "uitems" table has the id stored from the "items" table. here: items - itemid > the id of the item i want to grab.\ uitems - item id (this is the unique id for the the USERSi tem uitems - theitemid - this is the id of the itemid from the items table/ all i have is the get variable in the url telling what the ITEMID is from the uitems table. i want to grab the items table rows from it with that. PLEASE HELP!! here is my code: bag.php: <?php session_start(); include("config536.php"); ?> <html> <head> <link rel="stylesheet" type="text/css" href="style.css" /> </head> <?php if(!isset($_SESSION['username'])) { echo "<ubar><a href=login.php>Login</a> or <a href=register.php>Register</a></ubar><content><center><font size=6>Error!</font><br><br>You are not Logged In! Please <a href=login.php>Login</a> or <a href=register.php>Register</a> to Continue!</center></content><content><center><font size=6>Inventory</font><br><br></center></content>"; } if(isset($_SESSION['username'])) { echo "<nav>$shownavbar</nav><ubar><img src=/images/layout/player.gif><a href=status.php>$showusername</a>.......................<img src=/images/layout/coin.gif> $scredits</ubar><content><center><font size=6>Inventory</font><br><br>"; $action = $_GET['action']; $gid = $_GET['usitemid']; $col = "4"; echo "<table border=0>"; echo "<tr>"; if(!isset($action)) { $irow = "SELECT * FROM uitems WHERE username='$showusername' AND location='1'"; $iquery = mysql_query($irow); while($ir = mysql_fetch_array($iquery)) { $uid = $ir['uitemid']; $iid = $ir['theitemid']; $iun = $r['username']; $il = $ir['location']; $tirow = "SELECT * FROM items WHERE itemid='$iid'"; $tiquery = mysql_query($tirow); while($tir = mysql_fetch_array($tiquery)) { $tiid = $tir['itemid']; $tin = $tir['name']; $tiim = $tir['image']; $tid = $tir['description']; $tirr = $tir['rarity']; $tit = $tir['type']; $tiu = $tir['uses']; $tis = $tir['strength']; $tide = $tir['defense']; $tih = $tir['heals']; echo "<td><center><a href=?action=view&usitemid=$uid><img src=/images/items/$tiim></a> ".$tir['name']."</center></td>"; $col--; if(!$col) { echo "</tr><tr>"; $col=4; } } } } if(isset($action)) { $iiwuery = "SELECT items.name, uitems.uitemid ". "FROM items, uitems ". "WHERE items.itemid = uitems.theitemid"; $tiresult = mysql_query($iiwuery) or die(mysql_error()); while($brow = mysql_fetch_array($tiresult)){ $cid = $brow['uitemid']; $cin = $brow['name']; } echo "$cid and $cin"; $qer = "SELECT * FROM items WHERE itemid='$cid'"; $tqer = mysql_query($qer); while($rune = mysql_fetch_array($tqer)) { $dtin = $rune['name']; $dtii = $rune['image']; $dtid = $rune['description']; $dtir = $rune['rarity']; $dtty = $rune['type']; echo "<b>$dtin</b><br><br><img src=/images/items/$dtii><br><i>$dtid</i><br><b>Rarity:</b> $dtir<br><b>Item Type:</b> $dtty<br><br><br>"; } } } ?> </html>
  6. thanks! how would i put the text underneath it?
  7. Hey guys! I've been having trouble with this all day. I'm wanting to display my results in rows. Like, 4 results in 1 row, then another 4, then another 4, etc. like this: IMAGE IMAGE IMAGE IMAGE IMAGE IMAGE IMAGE IMAGE IMAGE IMAGE IMAGE IMAGE I'm nto sure how to do that. I want to display pictures. Here is my code for the page: bag.php: <?php session_start(); include("config536.php"); ?> <html> <head> <link rel="stylesheet" type="text/css" href="style.css" /> </head> <?php if(!isset($_SESSION['username'])) { echo "<ubar><a href=login.php>Login</a> or <a href=register.php>Register</a></ubar><content><center><font size=6>Error!</font><br><br>You are not Logged In! Please <a href=login.php>Login</a> or <a href=register.php>Register</a> to Continue!</center></content><content><center><font size=6>Inventory</font><br><br></center></content>"; } if(isset($_SESSION['username'])) { echo "<nav>$shownavbar</nav><ubar><img src=/images/layout/player.gif><a href=status.php>$showusername</a>.......................<img src=/images/layout/coin.gif> $scredits</ubar><content><center><font size=6>Inventory</font><br><br>"; $action = $_GET['action']; $gid = $_GET['itemid']; $irow = "SELECT * FROM uitems WHERE username='$showusername'"; $iquery = mysql_query($irow); while($ir = mysql_fetch_array($iquery)) { $uid = $ir['uitemid']; $iid = $ir['theitemid']; $iun = $r['username']; $il = $ir['location']; $tirow = "SELECT * FROM items WHERE itemid='$iid'"; $tiquery = mysql_query($tirow); while($tir = mysql_fetch_array($tiquery)) { $tiid = $tir['itemid']; $tin = $tir['name']; $tiim = $tir['image']; $tid = $tir['description']; $tirr = $tir['rarity']; $tit = $tir['type']; $tiu = $tir['uses']; $tis = $tir['strength']; $tide = $tir['defense']; $tih = $tir['heals']; echo "<img src=/images/items/$tiim><br>$tin<br><br>"; } } } ?> </html> I have no errors, everything works great! It's just I'm not sure how to display them the way I want them. Right now they are displayed like this: IMAGE IMAGE IMAGE IMAGE Any help is greatly appreciated, thank you!
  8. I've tried like 100 different times, nothing works. I'm using a PHP based website. The folder is style.css where the CSS is displayed. It doesn't work. How do I get it to display within the php code. Here is my index.php: index.php: <?php session_start(); include("config536.php"); ?> <html><head><title> Hello World </title> <link href="style.css" rel="stylesheet" type="text/css"></head><body> <?php echo "<td class=\"banner\">Welcome!!</banner><td class=\"top\">Testing this!</top><td class=\"body\">Testing this again!!</body>";?> </body></html> the second like of the config files is including the style.css, so that isn't the problem. And teh config file exists. Here is my style.css file: style.css: <style><body>body { font-family: verdana; } .banner{font-size: 58px; color: #fff;} .top{font-size: 18px; color: red; } .body {font-size: 25px; color: green;} </body></style> This is my third time posting this within the past 6 months, guys, PLEASE solve this. I cannot continue my website anymore if this will not work!
  9. didn't work
  10. Hey guys! I've been having a huge problem with CSS. I've tried every way possible. It doesn't even take the CSS coding, I think. Here is the EXACT coding in style.css: banner{ font-size: 30px; font-color: black ;font-family: verdana; } top{ font-size: 8px; font-color: red; font-family: verdana; } body{ font-size: 14px; font-color: blue; font-family: verdana; } Ok I am using this with the index.php for now, just to get things to work, then I will use it for the whole site. Here is index.php: <?php session_start(); include("config.php"); ?> <html><head><title> Hello World </title> <link href="style.css" rel="stylesheet" type="text/css"></head><body> <?php echo "<td class=\"banner\">Welcome!!</banner><br><br><td class=\"top\">Testing this!</top><br><br><td class=\"body\">Testing this again!!</body>";?> </body></html> Now, I will show you the config file: <?php session_start(); include("style.css"); $con = mysql_connect("localhost","username","password"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("rockefel_db", $con); $showusername = $_SESSION['username']; $usergetquery = mysql_query("SELECT * FROM users WHERE username = '$showusername'"); while($ur = mysql_fetch_array($usergetquery)) { $suserid = $ur['userid']; $susuername = $ur['username']; $scredits = $ur['credits']; $sname = $ur['name']; $sage = $ur['age']; $ssignedup = $ur['signedup']; $slastseen = $ur['lastseen']; $sposts = $ur['posts']; $susertype = $ur['usertype']; $susershop = $ur['usershop']; $smainpet = $ur['mainpet']; $savatarcount = $ur['avatarcount']; $suseravatar = $ur['useravatar']; $sbanned = $ur['banned']; $suserlookup = $ur['userlookup']; } echo "<font face=verdana><font size=4><font color=black>This is a test... displaying...<br><br>$suserid<br>$scredits</font>"; ?> Okay. Can somebody please tell me how to fix this? thanks!
  11. Okay, I put his code in, and I click to login, and it just shows teh login again.
  12. Here is the code: <?php session_start(); $submit = $_POST['submit']; $lusername = $_POST['username']; $lpassword = $_POST['password']; $con = mysql_connect("localhost","ussername","password"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("database_name", $con); if(!isset($_POST['submit'])){ echo "<font size=6><fontface=verdana>Login</font>"; ?> <form action="<? echo "$PHP_SELF"; ?>" method="POST"> Username: <input type="text" name="username"><br> Password: <input type="password" name="password"><br><br> <input type="submit" name="submit" value="Log In"></form> <?php } if(isset($_POST['submit'])){ $get = mysql_query("SELECT count(userid) FROM users WHERE username='$lusername' and password='$lpassword'"); $theresult = mysql_result($get, 0); if($theresult != 1) { echo "<font face=verdana><font size=3><font color=red>Error! Invalid username and password combination.</font>"; } else { $_SESSION['username']; $display = $_SESSION['username']; echo "<font color=green><font face=verdana><font size=4>You are now Logged In, " .$_SESSION['username']. "</font>"; } } ?>
  13. Thanks for theh elp, but I triedt hat and the variable is still not displaying. It should say you are now loggedi n, username. But it just says, youa re now logged in, .
  14. Oh, okay guys! I got it to work, thank you! JUst one more thing Ig uess I can ask here... my session variable at the bottom, well near the bottom... how do I set the session variable as a variable? Thanks!
  15. Still doesn't work. I'm not sure what is wrong. I can't even check to see if my databse is working okay. I have phpmyadmin up and it's running okay.
  16. ahh thank you, but it's still not woroking. I typed in random letters and it still says logged in. When Ip ut in the ocrrect name and password, it says logged in but doesn't display the username (which is the session varible). thanks!
  17. Hi!I madea basic login for my site yesterday. It seemed to work fine yesterday but I tryed it last nite and now today and it's not working. =[ I'm not getting any errors, it's just that if I type in a random name and password it says you are now logged in when they're not even in the database. I login with a real nname and password, it says it is logged in but the session variable name isn't set. Here is the code: login.php: <?php session_start(); $con = mysql_connect("localhost","username","password"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("database_name", $con); if(!$submit) { echo "<font size=6><fontface=verdana>Login</font>"; ?> <form action="<? echo "$PHP_SELF"; ?>" method="POST"> Username: <input type="text" name="username"><br> Password: <input type="password" name="password"><br><br> <input type="submit" name="submit" value="Log In"></form> <?php } $submit = $_POST['submit']; $lusername = $_POST['username']; $lpassword = $_POST['password']; if($submit) { $get = mysql_query("SELECT count(userid) FROM users WHERE username='$lusername' and password='$lpassword'"); $theresult = mysql_result($get, 0); if($theresult == 1) { echo "<font face=verdana><font size=3><font color=red>Error! Invalid username and password combination.</font>"; } else { $_SESSION['username']; echo "<font color=green><font face=verdana><font size=4>You are now Logged In, " .$_SESSION['username']. "</font>";} } ?> I edited out my database information for security purposes... it connects fine. I did NOT add an error message for what happends when the login is wrong. If anybody can help, I would gratly appreciate it... thanks! =]
  18. I'm using cpanel to upload my stuff. I do NOT use any program, I create them myself. I'll show you both pages: style.css: banner{ font-size: 30px; font-color: black ;font-family: verdana; } top{ font-size: 8px; font-color: red; font-family: verdana; } body{ font-size: 14px; font-color: blue; font-family: verdana; } and now my index: index.php: <html><head><title> Hello World </title> <link href="style.css" rel="stylesheet" type="text/css"></head><body> <?php echo "<td class=\"banner\">Welcome to Hangeia!</banner><br><br><td class=\"top\">Testing this!</top><br><br><td class=\"body\">Testing this again!!</body>";?> </body></html> othing is working... I had this problem years ago, but I messed around with it and fixed it. I've googled eveyrthing today... nothing is working. thanks!
  19. i'[m not quite sure what you mean, but i think I remember putting something other than just <banner> . Do I put <td class=< "banner"> ? I tried that and nothing happened but I think I'm getting closer. Thanks!
  20. nope that didnt work im getting all of the same font, size and color
  21. thanks! i'll try it !
  22. what page dop i use the link on? I already tried that and it just displays the whole .css file... it displays the code. Where do I write that in the index file? thanks!
  23. Hey! My whole website was deleted at the beginning of the month, so I'm re making the entire site, well.. I'm having a HUGE problem with the CSS. I want the css page to be external. Ih ave a file named style.css here is the EXACT code on the style.css page: <style> banner{ font-size: 30px; font-color: black; font-family: verdana; } top{ font-size: 8px; font-color: red; font-family: verdana; } body{ font-size: 14px; font-color: blue; font-family: verdana; } </style> Now.. my website is PHP based, and I'm having trouble getting it to show up. Here is the page I want the css to work on (well, it will be all pages, but I only have index.php up so far). Here is the EXACT code for index.php (with exeption of my database user/password): <?php include("style.css"); echo "<banner>Welcome to Hangeia!</banner><br><br><top>Testing this!</top><br><br><body>Testing this again!!</body>"; ?> If anybody can please help me, I would really apreciate it, 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.