Php/MYSQL

Joined
Dec 18, 2007
Messages
933
Reaction score
12
Hello, heres a query..
I want this form (mysql) to connect to database (done) then on user side, have like a box which fills in
Username - Your choice
Password - Your choice
Level - 80
Race - Human
Faction - Alliance
What it is - paladin (etc)
Items: (this box should be sent to an email with the items they had)

and on click, it will enter into the database and the user will just need me to add items to them...
So far:
PHP:
<?php
$con = mysql_connect("localhost","root","password");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("characters", $con);

mysql_query("INSERT INTO Characters (User, Password, Level, Race, Faction, Whtis)
('$_POST[User]','$_POST[Password]','$_POST[Race]','$_POST[Faction]','$_POST[Whtis]','$_POST[Level]')";

if (!mysql_query($sql,$con))
  {
  die('Error: ' . mysql_error());
  }
echo "Your User has been added to the database!";
mysql_close($con);
?>
Help! thanks :thumbup1:

Just realised, i need them to make an account on http://173.224.211.52/ then how do i make it post that user into there account?

---------- Post added at 10:44 AM ---------- Previous post was at 09:54 AM ----------

Sorry for double: Wuold it be like:
PHP:
<html>
<body>
<h1>All Players from Project EDEN, form to transfer character</h1>
<form action="old80s.php" method="post">
Username: <input type="text" name="user" />
Password: <input type="text" name="password" />
Previous Level: <input type="number" name="level" />
Faction: <input type="text" name="Faction" />
Race: <input type="text" name="Race" />
What you where (pally etc):<input type="text" name="whtis" />
<input type="submit" />
</form>

</body>
</html>
P.s any wow private owners, check if this will work... thanks!
 
Last edited:
There is no closing parenthesis for the mysql_query() line. Add or die(mysql_error()) for debugging. And dang this is ugly :
PHP:
'$_POST[User]','$_POST[Password]','$_POST[Race]','$_POST[Faction]','$_POST[Whtis]','$_POST[Level]'

You should use mysql_real_escape_string() to protect your vars, and at least MD5 your passwords or something.
 
There is no closing parenthesis for the mysql_query() line. Add or die(mysql_error()) for debugging. And dang this is ugly :
PHP:
'$_POST[User]','$_POST[Password]','$_POST[Race]','$_POST[Faction]','$_POST[Whtis]','$_POST[Level]'
You should use mysql_real_escape_string() to protect your vars, and at least MD5 your passwords or something.
Could you copy my code, then enter them things? i dont really get it. :thumbup1:
PHP:
('$_POST[User]','$_POST[Password]','$_POST[Race]','$_POST[Faction]','$_POST[Whtis]','$_POST[Level]')";
 = "3f3c3085c1699b96d1594c37c8d01603" ?
 
Last edited:
PHP:
   <?php
$con = mysql_connect("localhost","root","password");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("characters", $con);
$User = mysql_real_escape_string($_POST['User']);
$Pass = md5($_POST['Password']);
$Race = mysql_real_escape_string($_POST['Race']);
$Level = mysql_real_escape_string($_POST['Level']);
$Whtis = mysql_real_escape_string($_POST['Whtis']);
$Faction = mysql_real_escape_string($_POST['Faction']);
mysql_query("
INSERT INTO Characters
(  User,   Password,  Level,   Race,    Faction,   Whtis)
('$User',   '$Pass', '$Level','$Race', '$Faction','$Whtis')
") or exit("Error");

echo "Your User has been added to the database!";
mysql_close($con);
?>
 
PHP:
   <?php
$con = mysql_connect("localhost","root","password");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("characters", $con);
$User = mysql_real_escape_string($_POST['User']);
$Pass = md5($_POST['Password']);
$Race = mysql_real_escape_string($_POST['Race']);
$Level = mysql_real_escape_string($_POST['Level']);
$Whtis = mysql_real_escape_string($_POST['Whtis']);
$Faction = mysql_real_escape_string($_POST['Faction']);
mysql_query("
INSERT INTO Characters
(  User,   Password,  Level,   Race,    Faction,   Whtis)
('$User',   '$Pass', '$Level','$Race', '$Faction','$Whtis')
") or exit("Error");

echo "Your User has been added to the database!";
mysql_close($con);
?>
Thanks!!
Much appreciated, i will test it. :wink: :thumbup1:
 
Back