PHP mysql form help needed please!!!?

vlost1

New member
I am trying to make a registration form for my db called vixtay with a table called members. I need the form to input the new registrants details into the fields in members called Name, Email, Telephone, Username and password.
The form below seems to connect to the database but will not input the details or verify the password, can someone please help me with this.
MY attempt at a form:
<style type="text/css">
<!--
.style3 {font-family: Verdana, Arial, Helvetica, sans-serif; font-weight: bold; }
-->
</style>
<title>Register</title><form method=post action=register_form.php?action=register name=s>
<table border="1" align="center">
<tr>
<td><span class="style3">
<label for="name">Name</label>
</span></td>
<td><input name="name" type="text" id="name" size="30"></td>
</tr>
<tr>
<td><span class="style3">
<label for="email">Email</label>
</span></td>
<td><input name="email" type="text" id="email" size="35"></td>
</tr>
<tr>
<td><span class="style3">
<label for="telephone">Telephone</label>
</span></td>
<td><input name="telephone" type="text" id="telephone" size="20"></td>
</tr>
<tr><td width="110"><span class="style3">Username:</span></td>
<td width="301"><input name=username type=text size="40" id="username"></td></tr>
<tr>
<td><span class="style3">Password:</span></td>
<td><input name=password type=password id="password" size="40"></td>
</tr>
<tr>
<td class="style3">Repeat Password:</td><td><label for="vpass"></label>
<input name="vpass" type="password" id="vpass" size="40"></td></tr>
<tr><td colspan=2 align=center><input type=submit value=Register></td></tr>
</table>
</form>
<?php
$hostname="hostname.com";
$username="username";
$password="password";
$dbname="vixtay";
$usertable="members";

mysql_connect($hostname,$username, $password) or die ("<html><script language='JavaScript'>alert('Unable to connect to database! Please try again later.'),history.go(-1)</script></html>");
mysql_select_db($dbname);

if ($action == register) {

if (!$name ||!$email ||!$telephone ||!$username || !$password || !$vpass) {
print "You must fill out all fields.";

exit;
}
$dupe1 = mysql_num_rows(mysql_query("select * from members where username='$username'"));

if ($dupe1 > 0) {
print "Someone already has that username.";

exit;
}
$dupe2 = mysql_num_rows(mysql_query("select * from members where email='$email'"));
if ($dupe2 > 0) {
print "Someone already has that email.";

exit;
}

if ($password != $vpass) {
print "The passwords do not match.";

exit;
}
mysql_query("insert into members (Name, Email, Telephone, Username, Password) values('$name','$email','$telephone','$username','$password')");
print "You are now registered. Login.";
}
?>
Thank you very much for the advice. Can you tell me exactly where these would go in my form please
$name = $_POST['name'];
$email = $_POST['email']; or what ever the NAMES of inputs are.
and the ["name"] am I right in assuming that has to be spelt the same as in the table such as Name instead of name?
Many thanks.
Also would it be better to link a form to a php for processing instead of having it all in the same page?
 
Ok...unless you forgot to add some code you have...your error is this:

you never assign the values of the form to php values after the submit

for each text field in the form you need to go: (in the php code)

$name = $_POST['name'];
$email = $_POST['email']; or what ever the NAMES of inputs are.

also: in your <form> tags, you need to use "" around the assignments:

<form method="post" action="<?php echo($_SERVER['PHP_SELF']); ?>" name="s">

up there I always use THAT assignment for my action="" in forms...i think its the better way to do it.


also: I dont know if it will make a difference, but try here:

Just for future debugging: try adding OR DIE("error @ query insert (or what ever query your at...for all querys)".mysql_error()); to all the queries to see where the error is occuring....this is a common way of debugging queries
 
Back
Top