LJackson
08-10-2008, 09:56 PM
hi all,
firstly i have been watching some tutorial videoswhich were a great help, so i wanted to try my new found knowledge but failed badly :(
what im trying to do is create a "sign up" form with 7 fields First Name, Last name, Age, Username, Password etc etc,
but i want it so when the user submits the form it adds the info to the database i setup, called login_test with 1 table called user_details which has the same 7 fields in it with the username being unique.
but i have absolutly no idea how to make the users input, add to the database,
so far i have:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<?php
$my_connection = mysql_connect('localhost','root', '');
if (!$my_connection) {
die('Could Not Connect: ' . mysql_error());
}
echo 'Connected Successfully to MySQL Server' . '<br><br>';
mysql_select_db('login_test');
if (!my_database){
die('could not find database: ' . mysql_error());
}
//form processing code - using 'super globals' - Killerphp.com
$first_name = $_REQUEST['name_first'];
$last_name = $_REQUEST['name_last'];
$age = $_REQUEST['age'];
$address = $_REQUEST['address'];
$postcode = $_REQUEST['postcode'];
$username = $_REQUEST['username'];
$password = $_REQUEST['password'];
mysql_query("INSERT INTo user_details (First Name ,Last Name,Age, Address , Postcode, Username , Password) VALUES ('$first_name' , '$last_name' , '$age', '$Address', '$postcode' , '$username' , '$password')");
$result = mysql_query("SELECT * FROM user_details");
echo $result;
mysql_close($my_connection);
?>
</body>
</html>
but i keep getting: Connected Successfully to MySQL Server
Resource id #3
instead of it listing all the data
any ideas???
cheers
Luke
firstly i have been watching some tutorial videoswhich were a great help, so i wanted to try my new found knowledge but failed badly :(
what im trying to do is create a "sign up" form with 7 fields First Name, Last name, Age, Username, Password etc etc,
but i want it so when the user submits the form it adds the info to the database i setup, called login_test with 1 table called user_details which has the same 7 fields in it with the username being unique.
but i have absolutly no idea how to make the users input, add to the database,
so far i have:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<?php
$my_connection = mysql_connect('localhost','root', '');
if (!$my_connection) {
die('Could Not Connect: ' . mysql_error());
}
echo 'Connected Successfully to MySQL Server' . '<br><br>';
mysql_select_db('login_test');
if (!my_database){
die('could not find database: ' . mysql_error());
}
//form processing code - using 'super globals' - Killerphp.com
$first_name = $_REQUEST['name_first'];
$last_name = $_REQUEST['name_last'];
$age = $_REQUEST['age'];
$address = $_REQUEST['address'];
$postcode = $_REQUEST['postcode'];
$username = $_REQUEST['username'];
$password = $_REQUEST['password'];
mysql_query("INSERT INTo user_details (First Name ,Last Name,Age, Address , Postcode, Username , Password) VALUES ('$first_name' , '$last_name' , '$age', '$Address', '$postcode' , '$username' , '$password')");
$result = mysql_query("SELECT * FROM user_details");
echo $result;
mysql_close($my_connection);
?>
</body>
</html>
but i keep getting: Connected Successfully to MySQL Server
Resource id #3
instead of it listing all the data
any ideas???
cheers
Luke