Jump to content

Shadowing

Members
  • Posts

    722
  • Joined

  • Last visited

Everything posted by Shadowing

  1. At the moment Im using XAMPP I"m a huge noob to all of this Other then having my local apache server, MYSQL database is there another tool I should be using as im developing someone told me that XAMPP is more for just displaying and testing out my webpage locally and isnt really for developing. I was looking at MYSQL workbench and it seems to be tools like this I should be using. Should I really just be using Mysql data base for developing? Or is there tools that are more user end friendly on flowcharts and database layout Any help with this would be most appreicated thanks
  2. ohhhhh Thanks Josh for taking the time out in seperating all that. lol that was an amazing comparision of all possible ways. that would of ate at me for ever for not knowing. I ran some test and this code works exactly how you said it would. ( preg_match('/^[^A-Za-z0-9]{5,20}$/',$_POST['Username']) ) { Maybe since im a noob im trying to understand it to deep to fast. but im affraid of making mistakes ha So its like i have to know every end to end situation.
  3. I'm a little confused exactly on how using this } works going to be hard to explain what im having problems with. I'm using JEdit for my editor and I notice if I click on one of these { it will put a box around where it ends there is 4 } at the bottom of the code by them selfs "on their own lines" and 2 in the middle by them selfs "on their own lines how does the code know which ones belong to which { appreicate any help in helping me understand this thanks this code is from a tutor online <? include_once("connect.php"); ?> <html> <body> <?php if(isset($_POST['Login'])) { if(!preg_match('/^[A-Za-z0-9]{5,20}$/',$_POST['Username'])){ // before we fetch anything from the database we want to see if the user name is in the correct format. echo "Invalid Username."; }else{ $query = "SELECT password,id,login_ip FROM users WHERE name='".mysql_real_escape_string($_POST['Username'])."'"; $result = mysql_query($query) or die(mysql_error()); $row = mysql_fetch_array($result); // Search the database and get the password, id, and login ip that belongs to the name in the username field. if(empty($row['id'])){ // check if the id exist and it isn't blank. echo "Account doesn't exist."; }else{ if(md5($_POST['password']) != $row['password']){ // if the account does exist this is matching the password with the password typed in the password field. notice to read the md5 hash we need to use the md5 function. echo "Your password is incorrect."; }else{ if(empty($row['login_ip'])){ // checks to see if the login ip has an ip already $row['login_ip'] = $_SERVER['REMOTE_ADDR']; }else{ $ip_information = explode("-", $row['login_ip']); // if the ip is different from the ip that is on the database it will store it if (in_array($_SERVER['REMOTE_ADDR'], $ip_information)) { $row['login_ip'] = $row['login_ip']; }else{ $row['login_ip'] = $row['login_ip']."-".$_SERVER['REMOTE_ADDR']; } } $_SESSION['user_id'] = $row['id'];// this line of code is very important. This saves the user id in the php session so we can use it in the game to display information to the user. $result = mysql_query("UPDATE users SET userip='".mysql_real_escape_string($_SERVER['REMOTE_ADDR'])."',login_ip='".mysql_real_escape_string($row['login_ip'])."' WHERE id='".mysql_real_escape_string($_SESSION['user_id'])."'") or die(mysql_error()); // to test that the session saves well we are using the sessions id update the database with the ip information we have received. header("Location: Sample.php"); // this header redirects me to the Sample.php i made earlier } } } } ?> <form id="form1" name="form1" method="post" action=""><center> GAME LOGIN <br /> <br /> Username: <input type="text" name="Username" id="Username" /> <br /> <br /> Password: <input type="password" name="password" id="password" /> <br /> <br /> <input type="submit" name="Login" id="Login" value="Login" /> </center> </form> </body> </html>
  4. wait (!preg_match('/^[^A-Za-z0-9]{5,20}$/' does turn it around and make it display invalid user name like it should (preg_match('/^[^A-Za-z0-9]{5,20}$/' acts like the ^ isnt even there so (preg_match('/^[^A-Za-z0-9]{5,20}$/' and (preg_match('/^[A-Za-z0-9]{5,20}$/' is giving the same results maybe php just doesnt let that get turned around like that? which makes sense there is no reason someone would use a double negitive like that anyways
  5. So wouldnt (!preg_match('/^[A-Za-z0-9]{5,20}$/' and (preg_match('/^[^A-Za-z0-9]{5,20}$/' be saying the same thing? cause (preg_match('/^[^A-Za-z0-9]{5,20}$/' doesnt work it comes up as invalid username. so its like the [^A-Za-z0-9] isnt making any affect at all
  6. I figure i should go ahead and mention this I notice if(!preg_match('/^[A-Za-z0-9]{5,20}$/',$_POST['Username'] and if(preg_match('/^[^A-Za-z0-9]{5,20}$/',$_POST['Username'] isnt the same thing. Not using the ! and putting the ^ by the A doesnt make it work. cause someone mention adding the ^ in that spot was the same thing as adding the ! before preg_match
  7. Nice Joe that fixed it Yah that makes total sense lol. so that was just a typo then on that tutor. good thing I decided to include the html. Honestly im glad all this happend. Cause now I understand this script way better now. where before it was really alien like to me when I started this thread lol. thanks alot guys seriously for taking the time out to help people like me on just getting started with Programing.
  8. My imput is Shadowing tried putting print_r($_POST['name']); in a few places i must be putting it in the wrong spot. sorry i know im getting spoon fed here <?php if(isset($_POST['Login'])) { print_r($_POST['name']); if(!preg_match('/^[A-Za-z0-9]{5,20}$/',$_POST['name'])){ // echo "Invalid Username."; }else{ Here is the code with the html with it <? include_once("connect.php"); ?> <html> <body> <?php if(isset($_POST['Login'])) { if(!preg_match('/^[A-Za-z0-9]{5,20}$/',$_POST['name'])){ // before we fetch anything from the database we want to see if the user name is in the correct format. echo "Invalid Username."; }else{ $query = "SELECT password,id,login_ip FROM users WHERE name='".mysql_real_escape_string($_POST['Username'])."'"; $result = mysql_query($query) or die(mysql_error()); $row = mysql_fetch_array($result); // Search the database and get the password, id, and login ip that belongs to the name in the username field. if(empty($row['id'])){ // check if the id exist and it isn't blank. echo "Account doesn't exist."; }else{ if(md5($_POST['password']) != $row['password']){ // if the account does exist this is matching the password with the password typed in the password field. notice to read the md5 hash we need to use the md5 function. echo "Your password is incorrect."; }else{ if(empty($row['login_ip'])){ // checks to see if the login ip has an ip already $row['login_ip'] = $_SERVER['REMOTE_ADDR']; }else{ $ip_information = explode("-", $row['login_ip']); // if the ip is different from the ip that is on the database it will store it if (in_array($_SERVER['REMOTE_ADDR'], $ip_information)) { $row['login_ip'] = $row['login_ip']; }else{ $row['login_ip'] = $row['login_ip']."-".$_SERVER['REMOTE_ADDR']; } } } } } } ?> <form id="form1" name="form1" method="post" action=""><center> GAME LOGIN <br /> <br /> Username: <input type="text" name="Username" id="Username" /> <br /> <br /> Password: <input type="password" name="password" id="password" /> <br /> <br /> <input type="submit" name="Login" id="Login" value="Login" /> </center> </form> </body> </html>
  9. Oh yah thats right cause Thorpe said i had the ('/[^A-Za-z0-9] instead of ('^/[A-Za-z0-9] which was cancling the ! out lol. I dont know why i was thinking i had to move the ^ and delete the ! lol cause that would put me back to where i was at. I tested this code out and it still says invalid username guess i can just switch the "else" around cause I do perfer it switched around to. it bugs me not knowing why this way doesnt work though or am I still in error? if(!preg_match('/^[A-Za-z0-9]{5,20}$/',$_POST['name'])){ // echo "Invalid Username."; }else{
  10. Joe thank you so much for taking the time out to explain to me in detail. was major help! My only problem now is i cant figure out how to test it to see if it works. When I type in bad characters it tells me Account doesn't exist. Like it should of course. why doesnt it echo both statements? or maybe its cause its still not working. here is my entire code for this <?php if(isset($_POST['Login'])) { if(preg_match('/^[A-Za-z0-9]{5,20}/',$_POST['name'])){ // before we fetch anything from the database we want to see if the user name is in the correct format. echo "Invalid Username."; }else{ $query = "SELECT password,id,login_ip FROM users WHERE name='".mysql_real_escape_string($_POST['Username'])."'"; $result = mysql_query($query) or die(mysql_error()); $row = mysql_fetch_array($result); // Search the database and get the password, id, and login ip that belongs to the name in the username field. if(empty($row['id'])){ // check if the id exist and it isn't blank. echo "Account doesn't exist."; }else{ if(md5($_POST['password']) != $row['password']){ // if the account does exist this is matching the password with the password typed in the password field. notice to read the md5 hash we need to use the md5 function. echo "Your password is incorrect."; }else{ if(empty($row['login_ip'])){ // checks to see if the login ip has an ip already $row['login_ip'] = $_SERVER['REMOTE_ADDR']; }else{ $ip_information = explode("-", $row['login_ip']); // if the ip is different from the ip that is on the database it will store it if (in_array($_SERVER['REMOTE_ADDR'], $ip_information)) { $row['login_ip'] = $row['login_ip']; }else{ $row['login_ip'] = $row['login_ip']."-".$_SERVER['REMOTE_ADDR']; }
  11. Oh wow thanks guys. You guys are awesome. so i just get rid of the ! and now the logic works I got this code from a tutor im doing on making a web browser game and this is his code he was using that didnt work for me since the ereg that he used no longer works in PHP5.3 i need to do more PHP tutors i guess cause i had no idea that the ! turns the if statement around. Yah sorry about the code posting i was trying to look for the code symbol. It was one of the few buttons I didnt try lol
  12. Thanks alot for the help bare with me im a huge noob Ya i couldnt figure out why the ^ was in there i just removed that. I think it is working cause when I log in it says Invalid Username. So that means its working right i just have the double negitive in there? so to fix this I would need to put the else statement on the other side of $query------------------- is the reason its a double negitive is cause im now using preg_match instead of the ereg? Thanks <?php if(isset($_POST['Login'])) { if(!preg_match('[A-Za-z0-9]',$_POST['name'])){ // before we fetch anything from the database we want to see if the user name is in the correct format. echo "Invalid Username."; }else{ $query = "SELECT password,id,login_ip FROM users WHERE name='".mysql_real_escape_string($_POST['Username'])."'"; $result = mysql_query($query) or die(mysql_error()); $row = mysql_fetch_array($result); // Search the database and get the password, id, and login ip that belongs to the name in the username field.
  13. I tried reading through several threads talking about this but still up in the air about what is going on. I"m doing a online tutor and a guy was using the ereg so i read that PHP no longer uses ereg so I replaced it with !preg_match When I do this code it says invalid username so im thinking it works fine i just need echo"invalid user name in my else statement? So its like the ereg is the oppiste of prematch? really appreciate any help with this <?php if(isset($_POST['Login'])) { if(!preg_match('[^A-Za-z0-9]',$_POST['name'])){ // before we fetch anything from the database we want to see if the user name is in the correct format. echo "Invalid Username."; }else{
  14. Thanks alot. I understand now I was thinking the cords was finding the center of a clickable area lol
  15. the part that is confusing is the size of the clickable areas What number or set of code is showing the size of that clickable area? So what is making that one area so big? I understand how they are making it clickable and all that. Just dont understand what chooses the size of the area able to be clicked. Only thing i can assume is one of the numbers of the cords equals size thanks really apprecaite the help and fast responce. really needing to understand size
  16. I was doing this tutor on a website and something occured to me that how are they making the sun a huge clickable area and the planets a small clickable area? I dont see any html showing size of this? Also how do they know what cords to use? Really appreciate the help here is the link http://www.w3schools.com/html/tryit.asp?filename=tryhtml_areamap
  17. Ahh its suppose to be mysql_select_db instead of mysql_database Now i im error free. Now i have to figure out why the next part of the tutor doesnt work for me major help Kitchen thanks again
  18. Hey Kitchen Thanks soooo much. yah i had to disable errors when I installed Joomla cause of some known bug in it. Now that I enabled error it is showing the error now on that line. This at least gives me a step in a direction of trying to solve my problem now. thanks alot. No idea why this tutor i have been following and others have no problems with using that command here is the link to the tutor i have been follow if anyone wants to try to help me figure out what is going on. would appreicate it alot thanks http://www.dreamincode.net/forums/topic/184431-text-based-mafia-game-database-with-connection-part-1/
  19. thanks I fixed my problem. Had two things going wrong at the same time. one was the 1 instead of the l and the other was apparently i cant put the script in a folder dir htdocs/spacewars I had to have the script in just htdocs I have one more issue though for kicks and grins I decided to add the command line echo "Connected to MySQL<br />"; to the script and it only works if I put it before $db. it doesnt work when i put it after the $db line. Any ideas? it still connects either way just doesnt show the echo <?php $mysql_server = "localhost"; // localhost is common on most hosts. $mysql_user = "shadowing"; // this is the name of your username of the server. $mysql_password = "eguitars8"; // the password connected to the username. MAKE IT COMPLEX. $mysql_database = "spacewars"; // the database name of where to connect to and where the information will be help. $connection = mysql_connect("$mysql_server","$mysql_user","$mysql_password") or die ("Unable to establish a DB connection"); $db = mysql_database("$mysql_database") or die ("Unable to establish a DB connection"); echo "Connected to MySQL<br />"; ?>
  20. Two things I dont understand on the script that doesnt work is the last two command lines connection and db Db is the data base im using? and not sure what connection is
  21. Thanks alot i made that change. I still get the error page though a white page is what I should be getting right?
  22. I'm using XAMPP and im a major noob. Last nite I was following this tutor and the connection script that was on it didnt work for me. So today I tried a connection script from another tutor on another site that worked just fine. here is the script that worked I saved it as test.php and went to localhost/test/php and it loaded a page connected to mysql <?php mysql_connect("localhost", "shadowing", "eguitars8") or die(mysql_error()); echo "Connected to MySQL<br />"; ?> The script that didnt work i saved it as connect.php and went to localhost/connect/php and it gave me a page saying "Object not found error "the request url was not found on this server." I understand this script doesnt have a echo on it but shouldnt it still take me to a blank white page instead of a error page. Or is there something wrong with it. Really appreciate any help with this. the script that didnt work is below <?php $mysql_server = "localhost"; // localhost is common on most hosts. $mysql_user = "shadowing"; // this is the name of your username of the server. $mysql_password = "eguitars8"; // the password connected to the username. MAKE IT COMPLEX. $mysql_database = "spacewars"; // the database name of where to connect to and where the information will be help. $connection = mysq1_connect("$mysql_server","$mysql_user","$mysql_password") or die ("Unable to establish a DB connection"); $db = mysql_database("$mysql_database") or die ("Unable to establish a DB connection"); ?>
×
×
  • 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.