Re: php mysql connection help..
thank you very much Jon Stephens, I am now able to connect to my mysql table
now I'm making a regiter page where people put information, when they click regiter, the information they enter will store into the mysql database
can you please take a look if i'm doing it right, cause I can't get it to work
<html>
<head>
<title>Member Register</title>
</head>
<body>
<form action="<?php
echo $_SERVER['PHP_SELF'];
$membername = $_POST['membername'];
$password = $_POST['password'];
$safequestion = $_POST['safequestion'];
$safeanswer = $_POST['safeanswer'];
$email = $_POST['email'];
?>"
method="post">
<p>Username: <input type="text" name="membername"/></p>
<p>Password: <input type="text" name="password"/></p>
<p>This is just in case you forgot the password. <br><br>
Safety Question: <input type="text" name="safequestion"/></p>
<p>Safety Answer: <input type="text" name="safeanswer"/></p>
<p>E-mail: <input type="text" name="email"/></p>
<p><input type="Submit" value="Register"></p>
</form>
<?php
$link = mysql_connect('localhost', 'root', '12345');
if (!$link) {
die('Could not connect: ' . mysql_error());
}
$db_selected = mysql_select_db('company');
if (!$db_selected) {
die('Could not select database: ' . mysql_error());
}
if(isset($_POST['Submit']))
mysql_query("insert into memberinfo (membername, memberpassword,
safequestion, safeanswer, email)
values ('$membername', '$password', '$safequestion', '$safeanswer', '$email')");
?>
</body>
</html>
I think I ought to make global variables for $membername and $password and such, but I do not know how to do that..
and how can I redirect to a page called regitered.php after people have clicked the submit button?
any help would be greatly appreciated...thank you