Jump to content

[SOLVED] need help with this simple registration script please


Recommended Posts

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','$color')");

      } 


/// 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="pull Name" type="text" id="full_name" /></td>
    </tr>
    <tr>
      <td>User Name:</td>
      <td><input name="pser Name" 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> </td>
      <td><input type="submit" name="Submit" value="Submit" /></td>
    </tr>
  </table>
</form>
</body>
</html>

You might want to check if the name="...." attributes in your form are the same that your code is using in the $_POST variables.

 

Also, are you learning php, developing php code, and debugging php code on a system with error_reporting set to E_ALL and display_errors set to ON in your master php.ini so that php would help you by displaying all the errors it finds? Stop and start your web server to get any change made to the master php.ini to take effect. You will save a ton of time if you get php to display all the errors if finds.

thank you! whoa! i dont know how my text got messed up like that. here is the fixed code, but it still doesnt update the table called registration_table in my local database. any more advice greatly appreciated.

 

<?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','$color')");

      } 


/// 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="user_name" 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> </td>
      <td><input type="submit" name="Submit" value="Submit" /></td>
    </tr>
  </table>
</form>
</body>
</html>

user_name is not the same as username

 

Also, are you learning php, developing php code, and debugging php code on a system with error_reporting set to E_ALL and display_errors set to ON in your master php.ini so that php would help you by displaying all the errors it finds? Stop and start your web server to get any change made to the master php.ini to take effect. You will save a ton of time if you get php to display all the errors if finds.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.