PHP MySQL Insert Data
Posted
by happyCoding25
on Stack Overflow
See other posts from Stack Overflow
or by happyCoding25
Published on 2010-05-21T23:54:13Z
Indexed on
2010/05/22
0:00 UTC
Read the original article
Hit count: 160
Hello,
Im trying to insert data into a table in MySQL. I found/modified some code from w3Schools and still couldn't get it working. Heres what I have so far:
<?php
$rusername=$_POST['username'];
$rname=$_POST['name'];
$remail=$_POST['emailadr'];
$rpassword=$_POST['pass'];
$rconfirmpassword=$_POST['cpass'];
if ($rpassword==$rconfirmpassword) {
$con = mysql_connect("host","user","password");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("mydbname ", $con);
}
mysql_query("INSERT INTO members (id, username, password)
VALUES ('4', $rusername, $rpassword)");
?>
Did I mistype something? To my understanding "members" is the name of the table. If anyone knows whats wrong I appreciate the help.
Thanks
© Stack Overflow or respective owner