Keep text value after submit - php

I'm trying to find how to retain my text value after submit, so the text that i submit is still keep in the textbox, there's so many reference in internet but too hard for me to understand (newbie here), so i'd like to ask here, if anyone have some solution.
Here's my form code:
echo
"<form method='post' action='process.php'>
<tr>
<td>Nama Jurusan</td>
<td>:</td>
<td><input type='text' name='jurusan' size='50%'></td>
</tr>
<tr>
<td>Nama Laboratorium</td>
<td>:</td>
<td><input type='text' name='lab' size='50%></td>
</tr>
<input name='submit' type='submit' id='ajukan' value='Ajukan'>
</form>";
As you can see, i was placing the form inside echo.
Here's my process.php code:
<?php
if(isset($_REQUEST['submit'])) {
include "../conf/koneksi.php";
$jurusan = $_POST['jurusan'];
$lab = $_POST['lab'];
$urutkan= "ALTER TABLE tb_pengusul AUTO_INCREMENT = 1";
mysql_query($urutkan);
$input = mysql_query("INSERT INTO tb_pengusul (nama_jurusan,nama_laboratorium)
VALUES ('$jurusan','$lab')") or die (mysql_error());
echo "<script language=\"Javascript\">\n";
echo "window.alert('Input sukses !')";
echo "</script>";
echo "<META HTTP-EQUIV=\"REFRESH\" CONTENT=\"0;URL='../koordinator.php?url='\">";
}
?>

Use Post value as,
This will works only if you form page and submit code are in same page ( process.php )
<?php echo"<form method='post' action='process.php'>
<tr><td>Nama Jurusan</td>
<td>:</td>
<td><input type='text' name='jurusan' value='".$_POST['jurusan']."' size='50%'></td>
</tr>
<tr>
<td>Nama Laboratorium</td>
<td>:</td>
<td><input type='text' name='lab' value='".$_POST['lab']."' size='50%'></td>
</tr>
<input name='submit' type='submit' id='ajukan' value='Ajukan'>
</form>";?>
Also you have error in your code in line
<td><input type='text' name='lab' size='50%></td>
it should be <td><input type='text' name='lab' size='50%'></td>

If your form is still available in the process.php file, change it like this:
echo "<form method='post' action='process.php'>
<tr><td>Nama Jurusan</td>
<td>:</td>
<td><input type='text' name='jurusan' size='50%'";
if (isset($_POST['jurusan']))
{
echo " value=\'$_POST['jurusan']\'";
}
echo "></td>
</tr>
<tr>
<td>Nama Laboratorium</td>
<td>:</td>
<td><input type='text' name='lab' size='50%'";
if (isset($_POST['lab']))
{
echo " value=\'$_POST['lab']\'";
}
echo "></td>
</tr>
<input name='submit' type='submit' id='ajukan' value='Ajukan'>
</form>";

you need to use PHP sessions.
add the following string to your process.php page
session_start();
$_SESSION['prev_values'] = $_POST;
and the following to your form page
$lab = "";
$jur = "";
session_start();
if(isset($_SESSION['prev_values'])){
$jur = $_SESSION['prev_values']['jurusan'];
$lab = $_SESSION['prev_values']['lab'];
}
echo
"<form method='post' action='process.php'>
<tr>
<td>Nama Jurusan</td>
<td>:</td>
<td><input type='text' name='jurusan' size='50%' value='$jur'></td>
</tr>
<tr>
<td>Nama Laboratorium</td>
<td>:</td>
<td><input type='text' name='lab' size='50%' value='$lab'></td>
</tr>
<input name='submit' type='submit' id='ajukan' value='Ajukan'>
</form>";
SECURITY NOTICE:
Please note: this script is basic and it is vulnerable to XSS (just to name one). As a rule of thumb, you should NEVER display directly user inputs without some form of sanitation

Related

PHP post of td content inside a for

I just need to send a line of a table in my PHP page after click on button.
This is my code :
$login = $_POST['login'];
$requete = Connexion::query("SELECT id
FROM session
WHERE login='$login'");
$requete = $requete[0][0];
$application = Connexion::query("SELECT titre,cleAk,cleAs,cleCk
FROM cles
WHERE sessionId='$requete'");
echo "<form class='login-form' method='POST'><table class='table'><th>Titre</th><th>Cle ak</th><th>Cle as</th><th>Cle ck</th><tr>";
for($i=0;$i<sizeof($application);$i++)
{
for($j=0;$j<4;$j++)
{
echo "<td><input type='hidden' name='titre' value='".$application[$i][$j]."'>".$application[$i][$j]."</td>";
}
echo "<td><button type='submit' name='api'>Submit</button></td></tr></form>";
}
And this var_dump($_POST['titre']); return the last cell of the last line.
Can you help me ?
As was briefly mentioned in the comments of a previous answer, if you only want to submit the contents of one line, then you will need a separate <form> on every line (table row). You were trying this with a closing </form> inside the loop, but you opened it outside the loop resulting in invalid HTML with lots of closing </form> tags but only one opening <form> tag.
Another problem with your form inputs is that they were all named the same after the first column name='titre' but you had specified each column separately in the table header. To fix this, others offered an imprecise option by creating an array name='titre[]', but I think it's better to dynamically name the inputs to match the column key.
I don't know what database API you're using, but it appears to only produce a numeric multidimensional array without associative keys. There's probably a class method to get the column names, or you can manually assign it based on your SQL query as I have done with the array $cols
<?php
// debugging to show you everything posted
print_r($_POST);
// generate some random data for example
$application[0][0] = "first titre";
$application[0][1] = "first cleAk";
$application[0][2] = "first cleAs";
$application[0][3] = "first cleCk";
$application[1][0] = "second titre";
$application[1][1] = "second cleAk";
$application[1][2] = "second cleAs";
$application[1][3] = "second cleCk";
$application[2][0] = "third titre";
$application[2][1] = "third cleAk";
$application[2][2] = "third cleAs";
$application[2][3] = "third cleCk";
// get the columns for input names
$cols = array('titre','cleAk','cleAs','cleCk');
// semantically complete HTML table
echo "
<table class='table'>
<thead>
<tr><th>Titre</th><th>Cle ak</th><th>Cle as</th><th>Cle ck</th><th>Submit</th></tr>
</thead>
<tbody>
";
for($i=0;$i<sizeof($application);$i++)
{
echo "
<tr>
<form class='login-form' method='POST'>";
for($j=0;$j<sizeof($cols);$j++)
{
echo "
<td><input type='hidden' name='".$cols[$j]."' value='".$application[$i][$j]."'>".$application[$i][$j]."</td>";
}
echo "
<td><button type='submit' name='api'>Submit</button></td>
</form>
</tr>\n";
}
echo "
</tbody>
</table>
";
Results in this rendered output when I click on the first row's submit button. Note that you can't post data in the snippet below, this is purely for static HTML demonstration purposes.
Array
(
[titre] => first titre
[cleAk] => first cleAk
[cleAs] => first cleAs
[cleCk] => first cleCk
[api] =>
)
<table class='table'>
<thead>
<tr><th>Titre</th><th>Cle ak</th><th>Cle as</th><th>Cle ck</th><th>Submit</th></tr>
</thead>
<tbody>
<tr>
<form class='login-form' method='POST'>
<td><input type='hidden' name='titre' value='first titre'>first titre</td>
<td><input type='hidden' name='cleAk' value='first cleAk'>first cleAk</td>
<td><input type='hidden' name='cleAs' value='first cleAs'>first cleAs</td>
<td><input type='hidden' name='cleCk' value='first cleCk'>first cleCk</td>
<td><button type='submit' name='api'>Submit</button></td>
</form>
</tr>
<tr>
<form class='login-form' method='POST'>
<td><input type='hidden' name='titre' value='second titre'>second titre</td>
<td><input type='hidden' name='cleAk' value='second cleAk'>second cleAk</td>
<td><input type='hidden' name='cleAs' value='second cleAs'>second cleAs</td>
<td><input type='hidden' name='cleCk' value='second cleCk'>second cleCk</td>
<td><button type='submit' name='api'>Submit</button></td>
</form>
</tr>
<tr>
<form class='login-form' method='POST'>
<td><input type='hidden' name='titre' value='third titre'>third titre</td>
<td><input type='hidden' name='cleAk' value='third cleAk'>third cleAk</td>
<td><input type='hidden' name='cleAs' value='third cleAs'>third cleAs</td>
<td><input type='hidden' name='cleCk' value='third cleCk'>third cleCk</td>
<td><button type='submit' name='api'>Submit</button></td>
</form>
</tr>
</tbody>
</table>
You should pass an array to handle the multiple elements with the inputs. In Your code it should be look like this:
for($j=0;$j<4;$j++)
{
echo "<td><input type='hidden' name='titre[$j]' value='".$application[$i][$j]."'>".$application[$i][$j]."</td>";
echo "<td><button type='submit' name='api'>Submit</button></td></tr></form>";
}
The modification is name='titre[]'. Hope this will help you

Fetching multiple looped textboxes' values

So I have this program where the user sets up a database table. First, I ask them how many fields they want.
first.php
<html>
<form name="formCreateFields" method="post" align="center" action="second.php">
<p>Number of fields: <input type ="text" name="fieldsNum"/>
<input type="submit" name="submitFieldsNum" value=" Submit "/></p><br>
</form>
</html>
Then I loop the fields, depending on their input above.
second.php
<?php
echo "<form name='formSetupFields' method='post' align='center' action='third.php'>";
for ($z=1; $z<=$_POST['fieldsNum']; $z++) {
echo "<table align='center'>
<tr>
<th rowspan=2> <big> $z </big> </th> <th>Name</th> <th>Type</th> <th>Length</th>
</tr>
<tr>
<td><input type='text' name='fieldName$z'></td>
<td><input type='text' name='fieldType$z'></td>
<td><input type='text' name='fieldLength$z'></td>
</tr>
</table><br><br>";
}
<input type='submit' name='submitFieldSetup'>
</form>";
?>
I'm having problems after this. I've been trying to test fetching them by putting them in an array and using foreach to view them but can't seem to get anywhere. I thought it was okay to use something like $_POST['fieldName$z'] but I guess I was wrong.
I just need to find out how I could fetch all the inputs in the second file. Any ideas? Thanks in advance! :)
If fieldsNum is a number, the for should be fine in this case, just properly concatenate the values:
echo "<form name='formSetupFields' method='post' align='center' action='third.php'>";
echo "<table align='center'>";
echo '
<tr>
<th rowspan=2></th> <th>Name</th> <th>Type</th> <th>Length</th>
</tr>';
for ($z = 1; $z <= $_POST['fieldsNum']; $z++) {
echo "
<tr>
<td><input type='text' name='inputs[$z][name]'></td>
<td><input type='text' name='inputs[$z][type]'></td>
<td><input type='text' name='inputs[$z][length]'></td>
</tr>
";
}
echo '</table><br><br>';
echo "<input type='submit' name='submitFieldSetup'>";
echo '</form>';
Then in third.php;
if(isset($_POST['inputs'])) {
$inputs = $_POST['inputs'];
foreach($inputs as $input) {
echo $input['name'];
echo $input['type'];
echo $input['length'];
}
}

Php doesn't insert/post empty value, but still insert/post filled value

Before asking, here's my form picture:
As you can see, I have 1 form with 2 tables, in each table, there are six inputs.
The input code in "Table Alat" and "Table Bahan" is like this:
<form method='post' action='p_input.php'>
<table>
<tr>
<td>1.</td>
<td><input type='text' name='nama[]' style='width:100%;' autocomplete='off'></td>
<td><input type='text' name='merk[]' style='width:100%;' autocomplete='off'></td>
<td><input type='text' name='kemasan[]' style='width:100%;' autocomplete='off'></td>
<td><input type='text' name='mhs[]' style='width:100%;' autocomplete='off'></td>
<td><input type='text' name='jml[]' style='width:100%;' autocomplete='off'></td>
<td><input type='text' name='hps[]' style='width:100%;' autocomplete='off'>
<input type='hidden' name='jenis[]' value='alat' autocomplete='off'></td>
</tr>
</table>
<table>
<tr>
<td>1.</td>
<td><input type='text' name='nama[]' style='width:100%;' autocomplete='off'></td>
<td><input type='text' name='merk[]' style='width:100%;' autocomplete='off'></td>
<td><input type='text' name='kemasan[]' style='width:100%;' autocomplete='off'></td>
<td><input type='text' name='mhs[]' style='width:100%;' autocomplete='off'></td>
<td><input type='text' name='jml[]' style='width:100%;' autocomplete='off'></td>
<td><input type='text' name='hps[]' style='width:100%;' autocomplete='off'>
<input type='hidden' name='jenis[]' value='bahan' autocomplete='off'></td>
</tr>
<table width='100%' align='center' style='margin-top:0;'>
<tr>
<td><input name='reset' type='reset' id='bersihkan' value='Reset'>
<input name='submit' type='submit' id='ajukan' value='Send'></td>
</tr>
</table>
</table>
</form>
The difference in here is <input type='hidden' name='jenis[]' value='alat' autocomplete='off'>, for "Table Alat" the value is 'alat' for "Table Bahan" the value is 'bahan'(I have no trouble in here, just telling you).
This is my p_input.php script:
<?php
error_reporting(0);
session_start();
if(isset($_REQUEST['submit'])) {
include "../conf/koneksi.php";
$count = count($_POST['nama']);
$jurusan = $_POST['jurusan'];
$lab = $_POST['lab'];
$materi = $_POST['materi'];
$mahasiswa= $_POST['mahasiswa'];
for($i = 0; $i < $count; $i++){
$nama = mysql_real_escape_string($_POST['nama'][$i]);
$merk = mysql_real_escape_string($_POST['merk'][$i]);
$kemasan = mysql_real_escape_string($_POST['kemasan'][$i]);
$mhs = mysql_real_escape_string($_POST['mhs'][$i]);
$jml = mysql_real_escape_string($_POST['jml'][$i]);
$hps = mysql_real_escape_string($_POST['hps'][$i]);
$jenis = mysql_real_escape_string($_POST['jenis'][$i]);
$sql2= "ALTER TABLE tb_usulan AUTO_INCREMENT = 1";
mysql_query($sql2);
$sql=mysql_query("INSERT INTO tb_usulan (nama,merk,kemasan,kebutuhan,jml_kebutuhan,hps,jenis,materi_praktikum)
VALUES
('$nama', '$merk', '$kemasan', '$mhs', '$jml', '$hps','$jenis','$materi')") or die(mysql_error());
}
}
?>
And my question is: If I only fill input in "TABLE ALAT" and keep input in "TABLE BAHAN" empty, then when I click submit, I want only input in table alat to insert/post to database, and vice versa, if I only fill input in "TABLE BAHAN" and keep input in "TABLE ALAT" empty, then only input in "TABLE BAHAN" will insert/post to database.
UPDATE QUESTION: This is only one form and one submit button, and insert it to the same table at same time.
just do a checking inside your for loop.
for($i = 0; $i < $count; $i++)
{
//skip if nama is empty
if($_POST["nama"][$i] == ""){continue;}
$nama = mysql_real_escape_string($_POST['nama'][$i]);
$merk = mysql_real_escape_string($_POST['merk'][$i]);
$kemasan = mysql_real_escape_string($_POST['kemasan'][$i]);
$mhs = mysql_real_escape_string($_POST['mhs'][$i]);
$jml = mysql_real_escape_string($_POST['jml'][$i]);
$hps = mysql_real_escape_string($_POST['hps'][$i]);
$jenis = mysql_real_escape_string($_POST['jenis'][$i]);
$sql2= "ALTER TABLE tb_usulan AUTO_INCREMENT = 1";
mysql_query($sql2);
$sql=mysql_query("INSERT INTO tb_usulan (nama,merk,kemasan,kebutuhan,jml_kebutuhan,hps,jenis,materi_praktikum)
VALUES ('$nama', '$merk', '$kemasan', '$mhs', '$jml', '$hps','$jenis','$materi')") or die(mysql_error());
}
Remember i added input field. so delete it before you apply the solution. as you already have input feild in your original form.
<table>
<tr>
<td>1.</td>
<td><input type='text' name='nama1' style='width:100%;' autocomplete='off'></td>
<td><input type='text' name='merk1' style='width:100%;' autocomplete='off'></td>
<td><input type='text' name='kemasan1' style='width:100%;' autocomplete='off'></td>
<td><input type='text' name='mhs1' style='width:100%;' autocomplete='off'></td>
<td><input type='text' name='jml1' style='width:100%;' autocomplete='off'></td>
<td><input type='text' name='hps1' style='width:100%;' autocomplete='off'>
<input type='hidden' name='jenis1' value='alat' autocomplete='off'></td>
</tr>
</table>
<table>
<tr>
<td>1.</td>
<td><input type='text' name='nama2' style='width:100%;' autocomplete='off'></td>
<td><input type='text' name='merk2' style='width:100%;' autocomplete='off'></td>
<td><input type='text' name='kemasan2' style='width:100%;' autocomplete='off'></td>
<td><input type='text' name='mhs2' style='width:100%;' autocomplete='off'></td>
<td><input type='text' name='jml2' style='width:100%;' autocomplete='off'></td>
<td><input type='text' name='hps2' style='width:100%;' autocomplete='off'>
<input type='hidden' name='jenis2' value='bahan' autocomplete='off'></td>
</tr>
</table>
<input type='submit' name="submit">
</form>
</body>
Than where you are running the query only change that part.
if(!empty($_POST['name1']))
{
//Run First query
}
if(!empty($_POST['name2']))
{
//run your second query
}
What this code will do it will check for the value. If the values are not empty than it will execute the query other wise it will not execute the query
and second is when you use the code you wont have any array so you need to remove the $count variable. and your foreach loop from the code.
And Third thing. you need to set the value after
if(isset($_REQUEST['submit'])) {
include "../conf/koneksi.php";
For each and every feild like below as i am setting few
$name1=$_Post['name1'];
$merk1=$_post['merk1'];
Do this for each and every value for both table.
And forth thing you need to change the value part in your query like your values going to be $name1, and so on for first query and for second query $name2 and so on.
Hope i explain this follow the step. and before following the steps. If you dont understand it ask me before you start applying them.
Thanks
An easy solution would be to separate the tables to separate forms like this:
<form name=formOne>
<table><!-- Alat etc. -->
</table>
<input type=submit>
</form>
<form name=formTwo>
<table><!-- Behan etc. -->
</table>
<input type=submit>
</form>
then only the table for wich submit is pushed will get submited!
Edit
To make it work with only one submit button (client side).
Add the following jquery:
var lastForm;
$("form").click(function(){
lastForm = this;
});
$("input[type=submit]").click(function(){
$(lastForm).submit();
});
You then add the submit button outside of the form elements.
But the nicest solution would be to check the fields serverside. (whitch should be done anyway since you can't really trust the end user).
But that has already been proposed in other answers!

HTML Form POST is null

so I'm trying to simply send one field of data from a form to a php file. Below is my form in a table. I also posted my php code. It keeps returning that $username is null. Ive tried post/get and it doesn't seem to matter.
HTML:
<form action='http://k9minecraft.tk/scripts/adduser.php' method='POST'>
<table>
<tr>
<td>First Name:</td>
<td><input type='text' id='first'></td>
</tr>
<tr>
<td>Last Name:</td>
<td><input type='text' id='last'></td>
</tr>
<tr>
<td>Email:</td>
<td><input type='text' id='email'></td>
</tr>
<tr>
<td>Minecraft Name:</td>
<td><input type='text' name='user'></td>
</tr>
<tr>
<td><input type='submit' value='Send'></td>
<td><input type='reset' value='Reset'></td>
</tr>
</table>
</form>
PHP:
<?php
print_r($_POST);
if (isset($_POST['user'])) {
$username = $_POST['user'];
echo $username;
echo 'username is not null';
}
?>
The issue is that all of your inputs have id but not name. The id are used by JavaScript. The name are used for sending form data.
Change it to be like this:
<form action='http://k9minecraft.tk/scripts/adduser.php' method='POST'>
<table>
<tr>
<td>First Name:</td>
<td><input type='text' name='first' id='first'></td>
</tr>
<tr>
<td>Last Name:</td>
<td><input type='text' name='last' id='last'></td>
</tr>
<tr>
<td>Email:</td>
<td><input type='text' name='email' id='email'></td>
</tr>
<tr>
<td>Minecraft Name:</td>
<td><input type='text' name='user'></td>
</tr>
<tr>
<td><input type='submit' name='Send' value='Send'></td>
<td><input type='reset' name='Rest' value='Reset'></td>
</tr>
</table>
</form>
This code is working. You need to add some condition, that checks, if $username is posted or not.
Something like that:
if(count($_POST)){
$username ='';
if(isset($_POST['user'])){
$username = $_POST['user'];
if ($username==null || !$username)
echo 'username is null';
echo strlen($username);
echo $username;
}
}
Try this to find out if the field is posted by the formular:
isset($_POST['user'])
I think $username==null will be true even if $username really is equal to an empty string.
This is how people usually do it:
if(isset($_POST['user']) && !empty($_POST['user'])) {
$user = $_POST['user'];
}
Note: == null will not work with empty string. see here.
You also need to add a name attribute for other input fields of yours.
try using this
<?php
if(isset($_POST['submit'])){
$msg = "";
/* Validate post */
if(isset($_POST['user'])==""){
$msg .= "username is null";
}
/*End Validate*/
if($msg==""){
$user = $_POST['user'];
}else{
echo $msg;
}
}
?>

$_POST not working in php

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.

Categories