Jump to content

AgentDuck

Members
  • Posts

    7
  • Joined

  • Last visited

AgentDuck's Achievements

Newbie

Newbie (1/5)

1

Reputation

  1. Fixed it myself. Found another form, and played around with the code you provided me. Thanks alot for your help.
  2. Hello your help is very appreciated in my process of learning stuff. Yes im gonna experiment putting the mysql connecter in another file. Anyways. When i press submit im getting Access forbidden! You don't have permission to access the requested object. It is either read-protected or not readable by the server. If you think this is a server error, please contact the webmaster. that error comes up. i dont really see why. I know that im making a big beginner fail, but thats how you learn huh? code look like this <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Login</title> </head> <?php mysql_connect("localhost", "root", "******") or die(mysql_error()); mysql_select_db("coinsdb") or die(mysql_error()); //Connect to database if(isset($_POST['submit'])){ $name = mysql_escape_real_string($_GET['coins']); $sql = "SELECT `coins` FROM users WHERE `name`=$name"; $query = mysql_query($sql, $connection); while ($row = mysql_fetch_array($query)) { $amount = $row['coins']; } echo $amount; } ?> <form method="post" action="<?php echo $PHP_SELF;?>"> Ingame name:<input type="text" size="12" maxlength="12" name="coins"><br /> <input type="submit" value="Check Balance" name="submit"><br /> </form><br /> </body> </html>
  3. hmmm im getting a strange problem Notice: Undefined index: submit in C:\xampp\htdocs\Login.php on line 12 im just gonna give you all the code dunno if i messed up somewhere o.O <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Login</title> </head> <?php mysql_connect("localhost", "root", "*******") or die(mysql_error()); mysql_select_db("coinsdb") or die(mysql_error()); //Connect to database if($_POST['submit']){ $name = mysql_escape_real_string($_GET['coins']); $sql = "SELECT `coins` FROM tablename WHERE `name`=$name"; $query = mysql_query($sql, $connection); while ($row = mysql_fetch_array($query)) { $amount = $row['coins']; } } ?> <form method="post" action="<?php echo $PHP_SELF;?>"> Ingame name:<input type="text" size="12" maxlength="12" name="coins"><br /> <input type="submit" value="Check Balance" name="submit"><br /> </form><br /> </body> </html>
  4. Hello this is the basic form thats basicly just a input field and a button, and yes you got it right. <form method="post" action="<?php echo $PHP_SELF;?>"> Ingame name:<input type="text" size="12" maxlength="12" name="coins"><br /> <input type="submit" value="Check Balance" name="submit"><br /> </form><br /> <?php From here i need it to take that name and then look through the database and find the amount of coins the desired user has. I this what you meant by the form? This is the mysql thingy the problem is, that this just takes the first user and shows hes coins, and i cant seem to find out how to make it like i want. <?php // Make a MySQL Connection mysql_connect("localhost", "root", "******") or die(mysql_error()); mysql_select_db("coinsdb") or die(mysql_error()); // Retrieve all the data from the "example" table $result = mysql_query("SELECT * FROM users") or die(mysql_error()); // store the record of the "example" table into $row $row = mysql_fetch_array( $result ); // Print out the contents of the entry echo "Coins: ".$row['coins']; ?>
  5. I dont think you get the point. On my php site i have an input field. In that field you should be able to type a name, then it will return how many coins he has. I have hes name and how many coins he has stored in my database. Input field: Database:
  6. Hello people, i've stumbled across a problem while learning that i can't seem to solve. In my MySQL database tables i have "name" and "coins" and on my page i have an input box, where you type a name, and the site should show how many coins he has. The problem is i can't find out how to that, and i would really appreciate if some of you in here could help me. Thanks in advance.
×
×
  • 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.