Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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