PHP form help needed please to input data into mysql database.?

vlost1

New member
Hi I have set up a database and need the following form to connect to and insert registration details. The form seems to connect ok but when I click submit it doesn't insert the data into the db.
I also want to include a link to thanks.php page when the registration has been successful. Can someone please show me how to do this with the following form:

<?php

//Connect To Database

$hostname="hostname";
$username="username";
$password="password";
$dbname="databasename";
$usertable="tablename";

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);

$sql="INSERT INTO MEMBERS (Name, Telephone, Email, Username, Password)
VALUES('$_POST[name]','$_POST[telephone]','$_POST','$_POST[username]','$_POST[password]')))";

if($result)
{
while($row = mysql_fetch_array($result))
{
$name = $row["$yourfield"];
echo "Name: ".$name."<br>";
}
}
?>

<html>
<body>

<form action="<?php echo $editFormAction; ?>" method="post" name="form1" id="form1">
<table align="center">
<tr valign="baseline">
<td nowrap="nowrap" align="right"><div align="left" class="style2">Name:</div></td>
<td><input name="Name" type="text" value="" size="40" maxlength="40" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right"><div align="left" class="style2">Telephone:</div></td>
<td><input name="Telephone" type="text" value="" size="15" maxlength="15" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right"><div align="left" class="style2">Email:</div></td>
<td><input name="Email" type="text" value="" size="40" maxlength="40" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right"><div align="left" class="style2">Username:</div></td>
<td><input name="Username" type="text" value="" size="25" maxlength="25" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right"><div align="left" class="style2">Password:</div></td>
<td><input name="Password" type="password" value="" size="25" maxlength="25" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right"><div align="left"></div></td>
<td><input type="submit" value="Register" /></td>
</tr>
</table>
<input type="hidden" name="MM_insert" value="form1" />
</form>
</body>
</html>
 
Back
Top