PDA

View Full Version : need help with this simple registration script please


silverglade
10-12-2009, 01:08 PM
hi, i need some advice on this simple table updating registration script, it wont update the table with the new data. any help GREATLY appreciated. i tried to make it as simple as i could and i still cant find the error. thanks. derek

here is the code.

<?php
include("connections.php");


$full_name = $_POST['full_name'];
$username = $_POST['username'];
$password = $_POST['password'];
$maiden = $_POST['maiden'];
$color = $_POST['color'];




if($full_name && $username && $password && $maiden && $color){

mysql_query("INSERT INTO registration_table (full_name,username,password,maiden,color)VALUES(' $full_name','$username','$password','$maiden','$co lor')");

}


/// query db and loop through rows example
//selects everything from table and assigns to the variable $query

$query = mysql_query("SELECT * FROM registration_table");

$table = "<table width=\"40%\" border=\"1\">
<tr>
<td>Here is your new registration information</td>

</tr>";

while($row = mysql_fetch_array($query)){ ////row now stands for the array fetched.

$table .= " <tr>
<td>".$row['full_name']."</td>
<td>".$row['username']."</td>
<td>".$row['password']."</td>
<td>".$row['maiden']."</td>
<td>".$row['color']."</td>

</tr>";

}

$table .= "</table>";





?>
<!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>
Please register to our forum below
<form id="form1" name="form1" method="post" action="registration.php">

<table width="31%" border="0">

<tr>
<td>Full Name:</td>
<td><input name="full_name" type="text" id="full_name" /></td>
</tr>
<tr>
<td>User Name:</td>
<td><input name="username" type="text" id="username" /></td>
</tr>
<tr>
<td>Password:</td>
<td><input name="password" type="text" id="password" /></td>
</tr>
<tr>
<td>Mother's maiden name</td>
<td><input name="maiden" type="text" id="maiden" /></td>
</tr>
<tr>
<td>Your favorite color</td>
<td><input name="color" type="text" id="color" /></td>
</tr>

<tr>
<td>&nbsp;</td>
<td><input type="submit" name="Submit" value="Submit" /></td>
</tr>
</table>
</form>
</body>
</html>

silverglade
10-12-2009, 01:27 PM
actually i edited the code so it updates the table, i also forgot to echo my table. now it echos it but it displays everyone's registration information the way its set up now. LOL. oh well. thank you. derek

edbr
10-13-2009, 12:37 AM
displays everyone's registration information the way its set up now
sounds like it needs a where clause in the select statement on the page where you echo the details