Can anyone tell me whats the problem with the code below? When I click the delete button, it gives me an error of
undefined index checkbox
even though checkbox is the name of the input tag below.
I know I haven't written the delete query, but thats not the point. I want to echo the $del_id, but I keep getting the error.
<?php
include 'connection.php';
if(isset($_POST['del'])){
$name=$_POST['checkbox'];
$del_id=implode(",", $name);
echo $del_id;
}
$sql="SELECT * FROM `student-reg`";
$result=mysqli_query($conn, $sql) or die(mysqli_error($conn));
echo "<table align='center' border='2'>
<tr>
<th>Mark</th>
<th>ID</th>
<th>First_Name</th>
<th>Last_Name</th>
<th>Roll_no</th>
<th>Degree</th>
</tr>
";
while($row=mysqli_fetch_assoc($result)){
$id=$row['Id'];
echo "
<tr>
<td><input type='checkbox' name='checkbox[]' value='".$row['Id']."'></td>
<td>{$id}</td>
<td>{$row['First_name']}</td>
<td>{$row['Last_name']}</td>
<td>{$row['Roll_no']}</td>
<td>{$row['Degree']}</td>
</tr>
";
}
?>
<html>
<body>
<form method="POST">
<input type="submit" value="Delete" name="del">
</form>
</body>
</html>
you form fields must be in <form></form> tag
<?php
include 'connection.php';
if(isset($_POST['del'])){
$name=$_POST['checkbox'];
$del_id=implode(",", $name);
echo $del_id;
}
$sql="SELECT * FROM `student-reg`";
$result=mysqli_query($conn, $sql) or die(mysqli_error($conn));
echo "<table align='center' border='2'>
<tr>
<th>Mark</th>
<th>ID</th>
<th>First_Name</th>
<th>Last_Name</th>
<th>Roll_no</th>
<th>Degree</th>
</tr>
"; ?>
<form method="post">
<?php
while($row=mysqli_fetch_assoc($result)){
$id=$row['Id'];
echo "
<tr>
<td><input type='checkbox' name='checkbox[]' value='".$row['Id']."'></td>
<td>{$id}</td>
<td>{$row['First_name']}</td>
<td>{$row['Last_name']}</td>
<td>{$row['Roll_no']}</td>
<td>{$row['Degree']}</td>
</tr>
";
}
?>
<html>
<body>
<input type="submit" value="Delete" name="del">
</form>
</body>
</html>
move this before the the closing tag of the script
if(isset($_POST['del'])){
$name=$_POST['checkbox'];
$del_id=implode(",", $name);
echo $del_id;
Related
i been trying to solve this problem for a few hours but still no progress. Want to Echo out my database result onto a table created in my html however it just pop out on the side of the window. Please advice something i can do. Thank you.
PHP
if (isset($_POST['search'])) {
include 'dbh.php';
$uid =$_POST['name1'];
$nric = $_POST['nric1'];
$number = $_POST['number1'];
$sql = "SELECT * FROM user WHERE name = '$uid' OR nric = '$nric' OR contact = '$number' ";
$result = $conn->query($sql);
if (!$row = mysqli_fetch_assoc($result))
{
echo "No result is found! ";
}
else
{
echo "result found";
$_SESSION['id'] = $row['id'];
echo "<tr>";
echo "<td>".$row['no']."</td>";
echo "<td>".$row['name']."</td>";
echo "<td>".$row['surname']."</td>";
echo "<td>".$row['nric']."</td>";
echo "<td>".$row['contact']."</td>";
echo "<td>".$row['gender']."</td>";
echo "<td>".$row['email']."</td>";
echo "<td>".$row['address']."</td>";
echo "<td>".$row['date']."</td>";
echo "</tr>";
}
}
Inside my form method.
<!-- Search function aboutus about us website -->
<form method="post" action="" >
<div class="panel" id="aboutus">
<h1>About Us</h1>
<!-- end of header -->
<input type="text" name="nric1"
placeholder="NRIC"><br> <input type="text" name="name1"
placeholder="Name"><br>
<input type="text" name="number1" placeholder="Details Number"><br>
<table width = "300" border = "1" cellpadding="1" cellspacing="1">
<tr>
<th>No</th>
<th>Name</th>
<th>Surname</th>
<th>Nric</th>
<th>Contact</th>
<th>Gender</th>
<th>Email</th>
<th>Address</th>
<th>Data</th>
<tr>
</table>
<input type="submit" name="search" value="Search">
</form>
Of course it does that,you need to echo it in the proper place,inside the HTML.Assuming the you also have the HTML inisde the same php page
<form method="post" action="" >
<div class="panel" id="aboutus">
<h1>About Us</h1>
<!-- end of header -->
<input type="text" name="nric1"
placeholder="NRIC"><br> <input type="text" name="name1"
placeholder="Name"><br>
<input type="text" name="number1" placeholder="Details Number"><br>
<table width = "300" border = "1" cellpadding="1" cellspacing="1">
<tr>
<th>No</th>
<th>Name</th>
<th>Surname</th>
<th>Nric</th>
<th>Contact</th>
<th>Gender</th>
<th>Email</th>
<th>Address</th>
<th>Data</th>
<tr>
<?php ...else{
$_SESSION['id'] = $row['id'];
echo "<tr>";
echo "<td>".$row['no']."</td>";
echo "<td>".$row['name']."</td>";
echo "<td>".$row['surname']."</td>";
echo "<td>".$row['nric']."</td>";
echo "<td>".$row['contact']."</td>";
echo "<td>".$row['gender']."</td>";
echo "<td>".$row['email']."</td>";
echo "<td>".$row['address']."</td>";
echo "<td>".$row['date']."</td>";
echo "</tr>";
?>
</table>
<input type="submit" name="search" value="Search">
</form>
I have problem with my buttons. I will try to explain.
1)I have users db from postgresql and new db in ms sql.
2)Created site with 2 columns in table ("SELECT * from users"-postgresql ): They are id/user
3)Then added new column "Operator" which contain submit buttons and functionality of submit buttons is updating "access" column from ms sql db.
PROBLEM:
It prints all buttons for all data that I have in ms sql(I have 7 rows data in ms sql, it prints 7 buttons for each row), I need to "echo" 1 button for each row which will be changable. If access==1 it should be named Active , else it should be named Diactive.
Here is my code and picture of what I got:
<?php
<table class="table table-condensed">
<thead>
<tr>
<th>ID</th>
<th>User</th>
<th>Operator</th>
<th>View</th>
</tr>
<?php
while ($row = pg_fetch_array($result)) {
?>
<tr>
<td>
<?php
$id = $row["id"];
echo $id;
?>
</td>
<td>
<?php
$username = $row["username"];
echo $username;
?>
</td>
<td>
<form method="POST" action="oper.php">
<?php
include ("db.php");
$result2 = pg_query($db_connection, "SELECT * from users ORDER by id asc");
while ($row1 = pg_fetch_array($result2))
{
$iddrain= $row1['id'];
//echo $iddrain;
//echo $iddrain;
$q7= "Select access from nezeret where id_m=$iddrain";
//var_dump($q7);
$resultid= sqlsrv_query($link, $q7, $params, $options);
while($row7= sqlsrv_fetch_array($resultid))
{
//$rs7=$row7['ID_M'];
$rs8=$row7['access'];
//echo $rs8;
//break;
if($rs8==1)
{
echo "<p><input type=\"submit\" name=\"uid\" value=Operator-ON onchange=\"this.form.submit()\"></p>
<p><input type=\"hidden\" name=\"uid\" value=$id onchange=\"this.form.submit()\"></p>";
}
else
{
echo "<p><input type=\"submit\" name=\"uid\" value=DIavtive onchange=\"this.form.submit()\"></p>
<p><input type=\"hidden\" name=\"uid\" value=$id onchange=\"this.form.submit()\"></p>";
}
}
}
?>
</form>
</td>
<?php
}
?>
</tr>
</table>
?>
You are doing typo mistake na dnot giving quote for value attributes near :
try like this :
if($rs8==1)
{
echo '<p><input type="submit" name="uid" value="Operator-ON" onchange="this.form.submit()"></p>
<p><input type="hidden" name="uid" value="'.$id.'" onchange=
"this.form.submit()"></p>';
}
else
{
echo '<p><input type="submit" name="uid" value="DIavtive" onchange="this.form.submit()"></p>
<p><input type="hidden" name="uid" value="'.$id.' onchange="this.form.submit()"></p>';
}
}
I have reditted your code to remove some errors that were making it fail to work;
<?php include ("db.php"); ?>
<table class="table table-condensed">
<thead>
<tr>
<th>ID</th>
<th>User</th>
<th>Operator</th>
<th>View</th>
</tr>
</thead>
<?php
//while ($row = pg_fetch_array($result)) {
<?php foreach( pg_fetch_array($result) as $row ) { ?>
?>
<tbody>
<tr>
<td<?php echo $row['id'] ?></td>
<td><?php echo $row['username'] ?></td>
<td>
<form method="POST" action="oper.php">
<?php
$result2 = pg_query($db_connection, 'SELECT * from users ORDER by id asc');
while ($row1 = pg_fetch_array($result2)) {
$iddrain = $row1['id'];
$q7 = "Select access from nezeret where id_m=$iddrain";
//var_dump($q7);
$resultid = sqlsrv_query($link, $q7, $params, $options);
while ($row7 = sqlsrv_fetch_array($resultid)) {
//$rs7=$row7['ID_M'];
$rs8 = $row7['access'];
if ($rs8 == 1) {
echo '<p><input type="submit" name="uid" value=Operator-ON onchange="this.form.submit()"></p>
<p><input type="hidden" name="uid" value=$id onchange="this.form.submit()"></p>';
} else {
echo '<p><input type="submit" name="uid" value=DIavtive onchange="this.form.submit()"></p>
<p><input type="hidden" name="uid" value=$id onchange="this.form.submit()"></p>';
}
}
}
?>
</form>
</td>
</tr>
</tbody>
</table>
I`ve changed code and now it is working, problem was additional useless fetch. Here is the code:
<table class="table table-condensed">
<thead>
<tr>
<th>ID</th>
<th>User</th>
<th>Operator</th>
</tr>
<?php
while ($row = pg_fetch_array($result)) {
?>
<tr>
<td>
<?php
$id = $row["id"];
echo $id;
?>
</td>
<td>
<?php
$username = $row["username"];
echo $username;
?>
</td>
<td>
<form method="POST" action="oper.php">
<?php
include ("db.php");
$iddrain= $row['id'];
$q7= "Select * from nezeret where id_m=$iddrain";
//var_dump($q7);
$resultid= sqlsrv_query($link, $q7, $params, $options);
while($row7= sqlsrv_fetch_array($resultid))
{
$rs8=$row7['access'];
//echo $rs8;
if($rs8==1)
{
echo "<p><input type=\"submit\" name=\"uid\" value=Operator onchange=\"this.form.submit()\"></p>
<p><input type=\"hidden\" name=\"uid\" value=$id onchange=\"this.form.submit()\"></p>";
}
else
{
echo "<p><input type=\"submit\" name=\"uid\" value=Nazeret onchange=\"this.form.submit()\"></p>
<p><input type=\"hidden\" name=\"uid\" value=$id onchange=\"this.form.submit()\"></p>";
}
}
?>
</form>
</td>
</tr>
<?php
}
?>
</tr>
</table>
When I use the sql UPDATE query, it only affects the first row of my members.
<?php
$query = mysqli_query($db, "SELECT * FROM `members` ORDER BY `siteRank`");
$result = mysqli_fetch_assoc($query);
?>
<?php
if($_POST['AccountUpdate'])
{
//mysqli_query($db, "UPDATE members SET username='$Username' WHERE id='$$IdentifcationNumber' ORDER BY id DESC LIMIT 1");
echo $result['id'];
echo $result['username'];
echo 'separeator';
echo $IdentifcationNumber;
}
?>
<form method="post" action="viewprofile.php">
<table border="1px">
<tr>
<th>ID</th>
<th>Username</th>
<th>Password</th>
<th>Email</th>
<th>Browser</th>
<th>IP</th>
<th>Site Rank</th>
<th>PyroCoins</th>
<th>PIN</th>
<th>Status</th>
<th>Date Joined</th>
<th>Update Account</th>
</tr>
<?php
while($result = mysqli_fetch_assoc($query)){
?>
<form method="post" action="viewprofile.php">
<tr>
<td><input readonly="readonly" value="<?php echo $result['id'];?>" /></td>
<td><?php echo $result['username'];?></td>
<td><input text="text" name="ChangePassword" value="<?php echo $result['password'];?>" /></td>
<td><?php echo $result['email'];?></td>
<td><?php echo $result['browser'];?></td>
<td><?php echo $result['ip'];?></td>
<td><?php echo $result['siteRank'];?></td>
<td><input type="text" name="ChangePyroCoins" value="<?php echo $result['PyroCoins'];?>" /></td>
<td><?php echo $result['pin'];?></td>
<td>
Current Status:
<input readonly="readonly" value="<?php echo $result['status'];?>" />
<select name="ChangeStatus">
<option value="<?php echo $result['status'];?>"><?php echo $result['status'];?></option>
<option value="[ Content Deleted ]">[ Content Deleted ]</option>
</select>
</td>
<td><?php echo $result['date'];?></td>
<td><input type="submit" name="AccountUpdate" value="Update Account"></td>
</tr>
<?php
}
?>
</table>
</form>
My $_POST data should be self explanatory, but its only affecting the first row and not the row that Im trying to affect. When I click my html update button, it only displays only the first ID and not the ID or the account credentials that i'm trying to update. For example, When I try to edit somes details with an ID of 28, it affects the first table ID which is 1
'ORDER BY id DESC LIMIT 1' in the query is unnecessary.
UPDATE members SET username='$Username' WHERE id='$IdentifcationNumber'
#Isaak Markopoulos - this is not tested but there are no nested forms so hopefully there should be less confusion when posting the form. The id field in the html has been named so at least there should be an id available in the posted vars
<html>
<head>
<title>crazy little monkey</title>
</head>
<body>
<?php
/* This only gets executed if it is a POST request */
if( $_SERVER['REQUEST_METHOD']=='POST' && isset( $_POST['AccountUpdate'] ) && isset( $_POST['IdentifcationNumber'] ) ){
/* I assume this is the correct id - there was no name for the form element previously */
$IdentifcationNumber=$_POST['IdentifcationNumber'];
$sql="UPDATE members SET username='$Username' WHERE id='$IdentifcationNumber';";
mysqli_query( $db, $sql );
echo $result['id'];
echo $result['username'];
echo 'separeator';
echo $IdentifcationNumber;
}
/* This gets executed for any request */
$query = mysqli_query( $db, "SELECT * FROM `members` ORDER BY `siteRank`;" );
$result = mysqli_fetch_assoc( $query );
?>
<!-- parent table -->
<table border="1px">
<tr>
<th>ID</th>
<th>Username</th>
<th>Password</th>
<th>Email</th>
<th>Browser</th>
<th>IP</th>
<th>Site Rank</th>
<th>PyroCoins</th>
<th>PIN</th>
<th>Status</th>
<th>Date Joined</th>
<th>Update Account</th>
</tr>
<tr>
<td colspan=12>
<!-- begin a form / table for each row in rs -->
<?php
$rc=0;
while( $result = mysqli_fetch_assoc( $query ) ){
$rc++;
echo "
<!-- unique name for each form - not essential -->
<form name='vpf_{$rc}' action='viewprofile.php' method='post'>
<!-- nested child table fully contained within it's parent form element -->
<table>
<td><input type='text' name='IdentifcationNumber' readonly='readonly' value='".$result['id']."' /></td>
<td>".$result['username']."</td>
<td><input text='text' name='ChangePassword' value='".$result['password']."' /></td>
<td>".$result['email']."</td>
<td>".$result['browser']."</td>
<td>".$result['ip']."</td>
<td>".$result['siteRank']."</td>
<td><input type='text' name='ChangePyroCoins' value='".$result['PyroCoins']."' /></td>
<td>".$result['pin']."</td>
<td>
Current Status:
<input readonly='readonly' value='".$result['status']."' />
<select name='ChangeStatus'>
<option value='".$result['status']."'>".$result['status']."
<option value='[ Content Deleted ]'>[ Content Deleted ]
</select>
</td>
<td>".$result['date']."></td>
<td><input type='submit' name='AccountUpdate' value='Update Account'></td>
</table>
</form>";
}/* Close the while loop - note that the form(s) is/are FULLY contained within the loop - NO nesting */
?>
</td>
</tr>
</table>
</body>
</html>
I have created a form that update the data in a sql column, so far all good.
The problem I have is that I would like to choose what columns are going to be updated, with checkboxes.
So I want to categorize two files as movies, I just check the checkbox and write movies in the form.
But its not only that. Every column is already connected to a checkbox, but I use this checkbox with an delete query, so I can delete multiple rows.
So my question is more like, how can I combine this two function with "one" checkbox.
This is some of my code.
This is my table with the sql outputs, and with the delete button
<?php
$files = mysql_query("SELECT * FROM files WHERE `user_name` = '{$_SESSION['username']}' ORDER BY `file_time` DESC LIMIT $start, $per_page")
or die(mysql_error());
?>
<table id="table-3">
<thead>
<tr>
<th scope="col">Upload User</th>
<th scope="col">Filename</th>
<th scope="col">Upload date</th>
<th scope="col">IP adress</th>
<th scope="col">Category</th>
<th scope="col">Delete</th>
</tr>
</thead>
<?php
while (($row = mysql_fetch_assoc( $files )) !==false)
{
echo "<tr>";
echo "<td>".$row['user_name'] . "</td> ";
?>
<td class="download"> <?php echo $row['file_name']; ?></td>
<?php echo "<td>".$row['file_time'] . "</td> "; ?>
<?php echo "<td>".$row['file_ip'] . "</td> "; ?>
<?php echo "<td>".$row['category'] . "</td> "; ?>
<td>
<form action="delete.php" method="post">
<input type="checkbox" name="done[]" id="<?php echo $row['file_id'] ?>" value="<?php echo $row['file_id'] ?>">
</td>
<?php
}
echo "</tr>";
echo "</table>";
?>
<input type ="submit" value ="Delete">
</form>
This form is the one with the update function
<form action="function.php" method="post">
category: <input type="text" name="category" />
<input type="submit" />
</form>
and
function.php
include('core/inc/init.inc.php');
if(isset($_POST['category'])){
$category = $_POST['category'];
mysql_query("UPDATE files SET category='$category'
/*WHERE category='genom' */ ");
header("Location: profile.php?uid=" . $_SESSION['uid']);
}else{
header("Location: profile.php?uid=" . $_SESSION['uid']);
};
How can I combine these two functions?
You can have multiple submit buttons in the same form. So you can do something like this:
<?php
$files = mysql_query("SELECT * FROM files WHERE `user_name` = '{$_SESSION['username']}' ORDER BY `file_time` DESC LIMIT $start, $per_page")
or die(mysql_error());
?>
<form action="updateordelete.php" method="post">
<table id="table-3">
<thead>
<tr>
<th scope="col">Upload User</th>
<th scope="col">Filename</th>
<th scope="col">Upload date</th>
<th scope="col">IP adress</th>
<th scope="col">Category</th>
<th scope="col">Delete</th>
</tr>
</thead>
<?php
while (($row = mysql_fetch_assoc( $files )) !==false)
{
?>
<tr>
<td> <?php echo $row['user_name']; ?></td>
<td class="download"> <?php echo $row['file_name']; ?></td>
<td><input type="text" name="file_time[<?php echo $row ['file_id']; ?>]" value="<?php echo $row['file_time']; ?>" /></td>
<td><input type="text" name="file_ip[<?php echo $row ['file_id']; ?>]" value="<?php echo $row['file_ip']; ?>" /></td>
<td><input type="text" name="file_category[<?php echo $row ['file_id']; ?>]" value="<?php echo $row['category']; ?>" /></td>
<td><input type="checkbox" name="done[]" id="<?php echo $row['file_id'] ?>" value="<?php echo $row['file_id'] ?>"></td>
</tr>
<?php } ?>
</table>
<input type ="submit" name="submittype" value = "Update">
<input type ="submit" name="submittype" value = "Delete">
</form>
And then, in updateordelete.php:
if($_POST['submittype']=="Delete"){
(do delete code...)
}elseif($_POST['submittype']=="Update"){
(do update code...)
}
For each of the values, you can access them using $_POST['file_category']. For example:
$file_categories=$_POST['file_category'];
foreach($_POST['done'] as $file_id){
echo $file_categories[$file_id];
}
I am new here and I have a question. I have a problem that I can't figure it out with _POST. I have been searching for hours before start writing! As far as I can see I haven't done any of the mistakes that are posted for other similar question (form action..., name attribute...,etc). Please, can you check my code below to tell me what am I doing wrong??
I use xampp 1.7.3 on windows 7.
<?php require("includes/header.php"); ?>
<?php require_once("includes/connection.php"); ?>
<?php require_once("includes/functions.php"); ?><head>
<script type="text/javascript">
function theChecker()
{
if(document.getElementById('checker').checked){
document.getElementById('submitter').disabled=false;
}
else{
document.getElementById('submitter').disabled=true;
}
}
</script>
</head>
<?php require("includes/body_no_menus.php"); ?>
<div align="center">
<form name="signup" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<?php
echo "<hr/>
<table width='600' border='0'>
<tr>
<td width='237'>Κωδικός οικοδομής</td>
<td width='351'><input name='building_id' type='text' id='building_id' size='30' maxlength='40' />*</td>
</tr>
<tr>
<td>Κωδικός διαμερίσματος</td>
<td><input name='apartment_id' type='text' id='apartment_id' size='30' maxlength='40' />*</td>
</tr>
<tr>
<td></td>
<td height='31' colspan='2' ><label>
<input name='send' type='submit' value='Αποστολή' />
</label></td>
</tr>
</table>
";
?>
</form>
</div>
<p>
<?php
if(isset($_POST['send'])) {
// Check input / Required fields
$building_id = check_input($_POST['building_id'],"Εισάγετε τον κωδικό της οικοδομής!");
$apartment_id = check_input($_POST['apartment_id'],"Εισάγετε όνομα χρήστη!");
$query = "SELECT idTENANT,FNAME,LNAME,BUILDING_ADMIN,PHONE FROM TENANT,APARTMENT, BUILDING
WHERE TENANT.APARTMENT_ID = APARTMENT.idAPARTMENT
AND APARTMENT.BUILDING_ID = BUILDING.idBUILDING
AND idAPARTMENT = '$apartment_id'
AND idBUILDING = '$building_id'";
$result=mysql_query($query) or die ("Couldn't execute query.");
$row = mysql_fetch_array( $result );
$id = $row['idTENANT'];
$fname = $row['FNAME'];
$lname = $row['LNAME'];
$apartment = $row['APARTMENT_ID'];
$phone = $row['PHONE'];
if($row['BUILDING_ADMIN'] == 0)
$admin = "ΟΧΙ";
else
$admin = "ΝΑΙ";
echo " <hr />
<table width='300' border='0'>
<tr>
<td>Όνομα</td>
<td>$fname</td>
</tr>
<tr>
<td>Επίθετο</td>
<td>$lname</td>
</tr>
<tr>
<td>Όνομα χρήστη</td>
<td><input name='username' type='text' size='30' maxlength='20' />*</td>
</tr>
<tr>
<td>Κωδικός χρήστη</td>
<td><input name='password' type='password' size='30' maxlength='20'/>*</td>
</tr>
<tr>
<td>Επαλήθευση κωδικού</td>
<td><input name='verify_password' type='password' size='30' maxlength='40'/> *</td>
</tr>
<tr>
<td>Διαχείριση οικοδομής</td>
<td>$admin</td>
</tr>
<tr>
<td>Τηλέφωνο</td>
<td>$phone</td> </tr>
<tr>
<td></td>
<td><input name='checkterms' type='checkbox' id='checker' onclick='theChecker()' value='Ναι'/>
<label>Έχω διαβάσει και αποδέχομαι τους όρους χρήσης.</label> *</td>
</tr>
<tr>
<td></td>
<td><input type='submit' name='complete' id='submitter' value='Ολοκλήρωση εγγραφής' disabled/></td>
</tr>
</table>
";
}
if(isset($_POST['complete'])) {
// Password match
if ($password != $verify_password)
{
echo '<font color="red">Οι κωδικοί δεν ταιριάζουν</font>';
}//if
else
{
// Execute MySQL commands
$query = "UPDATE TENANT SET USERNAME = '$un', PASSWD='$pw' WHERE idTENANT='$id'";
$result=mysql_query($query) or die ("Couldn't execute query.");
header("Location: main_login.php");
}//else
}//if
?>
</p>
<?php require("includes/footer.php"); ?>
The first _POST (if(isset($_POST['send']))...) works perfectly. But if(isset($_POST['complete'])) {... does nothing. I ve tried to echo some data to see if my connection doesn't work, but its the _POST...
Please help me!!!!
Thanks for your time!
what you could try:
use vardump to see what $_POST contains: var_dump($_POST);.
use firebug (or something similar for another browser) to lookup the request and see which POST-Parameters are sent.
The second set of form elements (username, password, verify_password, checkterms, complete) are not inside any html form element. Clicking the second button does not post the form to server.
header("Location: main_login.php");
Is not going to work, when $_POST["complete"] is reached. You already sent heaps of output before that. Enable more error_reporting.