GetDotted Domains

Viewing Thread:
"VIP PHP MYSQL"

The "Freeola Customer Forum" forum, which includes Retro Game Reviews, has been archived and is now read-only. You cannot post here or create a new thread or review on this forum.

Fri 23/01/15 at 17:59
Regular
Posts: 12
Hi, I have set up some pages that are working to collect data which I wish to add to database within VIP hosting using PHP and MYSQL already set up with Freeola.

I think or know the following syntax is wrong and wish help if possible in the correct way of entering the instructions?

Please find below a sample of the code I am using to attempt to add data already collected:





add_me







$user="l861_login"
$password="abc123"
$database="l861_login"

#get values from form
$username=$_POST['username'];
$userpass=$_POST['password'];
$level=$_POST['level'];

mysql_connect("localhost",$user);
@mysql_select_db($database) or die("Unable to select databse");

#Different type of query - an insert into...
$query = "INSERT INTO members VALUES ('$username','$userpass','$level')";

mysql_($query);
mysql_close();

#Message to indicate it has been added
echo "New user, $username, added to database";
?>



______________

Any help greatly appreciated.

Many thanks
Fri 30/01/15 at 11:38
Regular
Posts: 12
Hi, many thanks for your rely.

I think I may have to rethink my approach and to avoid the security issues use storage on the local drive of the system I wish the database to work on.

Your help greatly appreciated.
Sat 24/01/15 at 08:55
Staff Moderator
"Aargh! Broken..."
Posts: 1,408
Please don't take this the wrong way but I think you need to do a bit more reading on the subject.
As for why this won't work, you are not passing all the credentials to the mysql connect.
If you get it working the next biggest problem is that you are wide open to SQL injection attacks. This means you are not sanitising you $_POST inputs. I could modify them to get different SQL to execute via your page.
The PHP mysql_connect functions are now deprecated so I would look at using PDO or mysqli.
Have a read on php.net for the MySql connection stuff, they have good examples.
Fri 23/01/15 at 17:59
Regular
Posts: 12
Hi, I have set up some pages that are working to collect data which I wish to add to database within VIP hosting using PHP and MYSQL already set up with Freeola.

I think or know the following syntax is wrong and wish help if possible in the correct way of entering the instructions?

Please find below a sample of the code I am using to attempt to add data already collected:





add_me







$user="l861_login"
$password="abc123"
$database="l861_login"

#get values from form
$username=$_POST['username'];
$userpass=$_POST['password'];
$level=$_POST['level'];

mysql_connect("localhost",$user);
@mysql_select_db($database) or die("Unable to select databse");

#Different type of query - an insert into...
$query = "INSERT INTO members VALUES ('$username','$userpass','$level')";

mysql_($query);
mysql_close();

#Message to indicate it has been added
echo "New user, $username, added to database";
?>



______________

Any help greatly appreciated.

Many thanks

Freeola & GetDotted are rated 5 Stars

Check out some of our customer reviews below:

Brilliant service.
Love it, love it, love it!
Christopher
I've been with Freeola for 14 years...
I've been with Freeola for 14 years now, and in that time you have proven time and time again to be a top-ranking internet service provider and unbeatable hosting service. Thank you.
Anthony

View More Reviews

Need some help? Give us a call on 01376 55 60 60

Go to Support Centre
Feedback Close Feedback

It appears you are using an old browser, as such, some parts of the Freeola and Getdotted site will not work as intended. Using the latest version of your browser, or another browser such as Google Chrome, Mozilla Firefox, or Opera will provide a better, safer browsing experience for you.