Jump to content

Archived

This topic is now archived and is closed to further replies.

Gruzin

Mysql problem

Recommended Posts

Hi,
I want the username and passowrd to be inputed in the database, but I've got a little problem:
The username is not saved in the database, I don't undestand why. But Password is saved correctly. any ideas how can I fix that? Thank you.

here is the code:

<?php
$con = mysql_connect("localhost","3d","password"); //connect to the sql database
if(!$con)
{
  die('Couldn"t connect'.mysql_error());
}

mysql_select_db("3d",$con);
$insert = "INSERT INTO password
(user, pass)
VALUES
('$_POST[$user]','$_POST[pass]')";
if(!mysql_query($insert,$con))
{
  die('Error'.mysql_error());
}
echo "Welcome George, your username and password is saved in Database";
mysql_close($con);
?>

Share this post


Link to post
Share on other sites
Thanks man, I'am dead.....time to sleep now :P

Share this post


Link to post
Share on other sites
There you go mate

good luck.

[code]
<?php

//connect database.

$con = mysql_connect("localhost","3d","password"); //connect to the sql database

//post varables.

$user=($_POST['user']);
$pass=($_POST['pass']);

//addslasshes to insert to database for database hekth lol....

$user=addslashes($user);
$pass=addslashes($pass);


if(!$con)
{
 die('Couldn"t connect'.mysql_error());
}

mysql_select_db("3d",$con);

if($_POST['submit']) {

$insert = "INSERT INTO password(user, pass)VALUES('$user','$pass')";

if(!mysql_query($insert,$con))
{
 die('Error'.mysql_error());
}
echo "Welcome $user, your username and $pass is saved in Database";

//send user to the index page in stead of the above message ok.

//header("location: index.php");

}
mysql_close($con);
?>
[/code]

Share this post


Link to post
Share on other sites
Your more then welcome becouse you was nice,

ill help you next time your on ok

good luck mate.

Share this post


Link to post
Share on other sites
thank u very much redarrow! I've already added u to my buddy list ;)

Share this post


Link to post
Share on other sites
[quote author=redarrow link=topic=101891.msg403687#msg403687 date=1153904664]
ok mate pm me anytime ok.
[/quote]
Kinda hard that when the PM system is disabled.

Share this post


Link to post
Share on other sites

×

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.