Jump to content

Mysql problem


Gruzin

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);
?>
Link to comment
https://forums.phpfreaks.com/topic/15664-mysql-problem/
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]
Link to comment
https://forums.phpfreaks.com/topic/15664-mysql-problem/#findComment-63861
Share on other sites

Archived

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

×
×
  • 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.