protected function pro_show_sendRequestForm(){
echo("<SECTION id='page_content-small'>");
echo("<ARTICLE>");
echo("<table width='100%' cellspacing='5'>");
echo("<tr><td><form method='post' action='main.php'></td></tr>");
echo("<tr><td colspan ='2' align='center'><B><H2>Send a event form.</H2></B></td></tr>");
echo("<tr><td align='left'><B>Name event:</B></td>");
echo("<td align='left'><input name='sEventTitle' type='text' size='30' maxlength='50' required></td></tr>");
echo("<tr><td align='left'><B>Name organisation:</B></td>");
echo("<td align='left'><B>New: </B><input name='sNewOrganisationName' type='text' size='30' maxlength='50'></td></tr>");
echo("<tr><td> </td><td align='left'><B>Or choose: </B>");
$this->pro_OrganisationDropdown('sExcistingOrganisationRecordNumber');
echo("</td><tr>");
echo("<tr><td align='left'><B>E-mail address:</B></td><td align='left'>");
echo("<input name='sEmailadress' type='text' size='30' maxlength='50' required></td></tr>");
echo("<input type='hidden' name='sSubmitForm' value='SendIntakeForm'>");
echo("<tr><td colspan='3' align='center'><input type='submit' value=' Sending '></td></tr>");
echo("</form></table></ARTICLE></SECTION>");
}
Hi you all,
Today I created this form and it worked fine. Until I started with testing and then i discovered that a certain value in the input field 'sEventTitle' was the reason that the form wasn't processed. I checked and rechecked but the value for example 'Apple' was excepted and the value 'pineapple' wasn't.
So to discover why, I commented all other input fields out like this:
protected function pro_show_sendRequestForm(){
echo("<SECTION id='page_content-small'>");
echo("<ARTICLE>");
echo("<table width='100%' cellspacing='5'>");
echo("<tr><td><form method='post' action='main.php'></td></tr>");
echo("<tr><td colspan ='2' align='center'><B><H2>Send a event form.</H2></B></td></tr>");
echo("<tr><td align='left'><B>Name event:</B></td>");
echo("<td align='left'><input name='sEventTitle' type='text' size='30' maxlength='50' required></td></tr>");
//echo("<tr><td align='left'><B>Name organisation:</B></td>");
//echo("<td align='left'><B>New: </B><input name='sNewOrganisationName' type='text' size='30' maxlength='50'></td></tr>");
//echo("<tr><td> </td><td align='left'><B>Or choose: </B>");
//$this->pro_OrganisationDropdown('sExcistingOrganisationRecordNumber');
//echo("</td><tr>");
//echo("<tr><td align='left'><B>E-mail address:</B></td><td align='left'>");
//echo("<input name='sEmailadress' type='text' size='30' maxlength='50' required></td></tr>");
echo("<input type='hidden' name='sSubmitForm' value='SendIntakeForm'>");
echo("<tr><td colspan='3' align='center'><input type='submit' value=' Sending '></td></tr>");
echo("</form></table></ARTICLE></SECTION>");
}
Now the entire form wont submit itself. This can not be true.
The basics are there: form and /form. A input name ='foo' type='text' and a submit button. Why is this form not submitted when the larger one is working? What is my mistake? Is there something I don't see? Any help is appriciated.
The first lines from main.php to see if the form is submitted are:
$oMainPage = new main();
echo($_POST['sEventTitle']);
echo($_POST['sSubmitForm']);
The code generated from the browser:
<SECTION id='page_content-small'><ARTICLE><form method='post' action='main.php'>
<table width='100%' cellspacing='5'><tr><td colspan ='2' align='center'><B>
<H2>Een aanmeldformulier versturen.</H2></B></td></tr><tr><td align='left'>
<B>Naam evenement:</B></td><td align='left'>
<input name='sEventTitle' type='text' size='30' maxlength='50' required></td></tr>
<input type='hidden' name='sSubmitForm' value='SendIntakeForm'><tr>
<td colspan='3' align='center'><input type='submit' value=' Versturen '></td></tr>
</table></form></ARTICLE></SECTION>
take the form out of the <td>, wrap the <form> around that <table>
Related
I have checkbox inside looping like this.
<?php
for($i=0;$i<$jumlah;$i++) {
echo "<tr>
<td align='center'><input type='text' name='PROSES[]' placeholder='Input Proses $i'/></td>
<td align='center'><input type='checkbox' name='NOTIF[]' value='Yes'/></td>
<td align='center'> <input type='checkbox' name='REMINDER[]' value='Yes'/></td>
<td align='center'> <input type='checkbox' name='DECISION[]' value='Yes'/></td>
<td align='center'> <input type='checkbox' name='AUTHOR[]' value='Yes'/></td>
<td align='center'><input type='text' name='SIAPA[]' size='40' placeholder='dari siap ke siapa' /></td>
</tr>";
}//end for
echo "</table>";
?>
and the query to input like this
if(isset($_POST['SUBMIT'])) {
$proses = $_POST[PROSES];//value from selectbox
$jumlah = count($proses);
$max_id = $data_max_id[ID];
for($i=0;$i<$jumlah;$i++) {
$query_input = "INSERT INTO data_proses SET ID_input = '$max_id',
proses = '$proses[$i]',
notifikasi = '$notif[$i]',
reminder = '$reminder[$i]',
decision = '$decision[$i]',
authorization = '$author[$i]',
dari_siapa = '$siapa[$i]'";
$hasil_input = mysqli_query($mysqli, $query_input);
}//end for
}
it will Produce table like this
In Short,
After I have submit to mysql is successfull But stil wrong. IF I have Check like that image the database have wrong result like this
input :
[x][x][ ][ ]
[ ][x][x][ ]
[ ][ ][x][x]
On database :
[x][x][x][x]
[ ][x][x][ ]
[ ][ ][ ][ ]
Can anyone help to fix my problem?
Thanks in advance
Include the row number in the names of all the checkboxes. Only the checked boxes get submitted, and PHP will index them all from 0 if they don't have an explicit index -- you won't see empty values for the checkboxes that are skipped.
for($i=0;$i<$jumlah;$i++) {
echo "<tr>
<td align='center'><input type='text' name='PROSES[]' placeholder='Input Proses $i'/></td>
<td align='center'><input type='checkbox' name='NOTIF[$i]' value='Yes'/></td>
<td align='center'> <input type='checkbox' name='REMINDER[$i]' value='Yes'/></td>
<td align='center'> <input type='checkbox' name='DECISION[$i]' value='Yes'/></td>
<td align='center'> <input type='checkbox' name='AUTHOR[$i]' value='Yes'/></td>
<td align='center'><input type='text' name='SIAPA[]' size='40' placeholder='dari siap ke siapa' /></td>
</tr>";
}//end for
I have a form in PHP with two submit buttons of type 'image'.
How do I know which button is clicked?
Code:
<?php
echo ("
<form action='WijzigSession.php' method='POST'>
<td><input class= 'nummers' type='number' name='aantal' value=".$_SESSION['producten'][$i]['aantal']." min='1' max='20'>
<input name='refresh' class='buttons' type='image' src='img/refresh.png'</a>
<input name='delete' class='buttons' type='image' src='img/delete.png'</a>
<input type='hidden' name='id' value='$i'>
</form></td>
<td>€ ".$_SESSION['producten'][$i]['prijs']."</td>
");
?>
Just try:
if(isset($_POST['refresh_x'])) { //you can potentially even check for '$_POST['refresh_y']'
// refresh is clicked
}
if(isset($_POST['delete_x'])) {
// delete is clicked
}
I'm trying to figure out how to make this code snippet display the value or the button but not both. As you'll see there is a button for "Call_Attempt_One". I'm trying to have it only display when there is no value in the field but have the field value displayed when there is a value and have the button disappear.
Suggestions?? Thanks!
<td style='font-size:12px;width:500px;'><div style=\"overflow-x:auto; max-height:100px\">{$row['Project_Description']}</div></td>
<td style='font-size:12px;'><center>{$row['Restoration_Decision_Matrix']}</center></td>
<td style='font-size:12px;'><center>
<form action='".$_SERVER['PHP_SELF']."' method='post'>
<input type='hidden' id='ID' name='ID' value='{$row['ID']}' />
<input type='submit' name='formCalledOne' id='formCalledOne' value='Called' />
</form>
{$row['Call_Attempt_One']}
</center></td>
<td style='font-size:12px;'><center><button type=\"submit\" form=\"form1\" value=\"Submit\">Called</button></center></td>
<td style='font-size:12px;'><center><button type=\"submit\" form=\"form1\" value=\"Submit\">Called</button></center></td>
<td style='font-size:12px;'><center><button type=\"submit\" form=\"form1\" value=\"Submit\">Emailed</button></center></td>
<td style='font-size:12px;'><center>Text Area</center></td>
<td style='font-size:12px;'><center>{$row['Received_Date']}</center></td>
<td style='font-size:12px;'><center>
<form action='".$_SERVER['PHP_SELF']."' method='post'>
<input type='hidden' id='ID' name='ID' value='{$row['ID']}' />
<input type='submit' name='formDelete' id='formDelete' value='Delete' />
</form>
</center></td>
</tr>";
}
//Check to see if delete button is pressed
if(isset($_POST['formDelete']))
{
if(isset($_POST['ID']) && !empty($_POST['ID']))
{
$ID = $_POST['ID'];
$result = mysql_query("DELETE FROM Project_Submissions WHERE ID ='".$ID."'");
}
}
here is the code that I found to work in my question above. I fixed it myself and replaced these lines
if(isset($_POST['formDelete']))
{
if(isset($_POST['ID']) && !empty($_POST['ID']))
{
$deleteID = $_POST['ID'];
$result = mysql_query("DELETE FROM Project_Submissions WHERE ID ='".$deleteID."'");
}
}
I am fetching data from database , each rowof data creates a form , each row has a "book" button, which submits phase and site data, but this "book" button does not work in Firefox and IE , it works in chrome
<?php
echo"<div style='overflow-y:scroll;height:200px;float:left;' ><table border=1 >
<tr>
<td>phase</td> <td>site no.</td> <td>plot-size</td> <td>face</td> <td>sply</td> <td>status</td><td>select </td>
</tr>" ;
while($row = mysql_fetch_array($ret, MYSQL_ASSOC))
{
echo "<tr>".
"<form action='restricted.php' method='get'>".
"<td><input type='text' value=\"{$row['phase']}\" name='phase' size='3' readonly /> </td>".
"<td><input type='text' value=\"{$row['id']}\" name='site' size='4' readonly /></td>".
"<td> {$row['size']} </td>".
"<td> {$row['facing']} </td>".
"<td>{$row['sply']} </td> ".
"<td>{$row['status']} </td> ".
"<td><input type='submit' name='book' value='book' \" /></td>".
"</form>".
"</tr>";
}
echo "</table></div>";
?>
you cannot have a form within a <tr> element. You must either put the form outside the table, or inside a <td> element. Firefox is probably complaining about that.
Im am trying to add a check box that will enable/disable the edit button. Im retrieving a price list and displaying it inside a table. When i add the javascript into the php code it doesn't work. Below is my code
<table border="1">
<tr>
<td width="100">Fee % </td>
<td width="100">Price</td>
<td width="100">Total</td>
<td width="102"> </td>
</tr>
<tr>
<?php
$sql1="select * from pricelist";
$result1=mysql_query($sql1) or die(mysql_error());
while ($row=mysql_fetch_array($result1)) {
$id=$row['id'];
$price=$row['h_price'];
$a=0;
print "<form id='form1' name='$a+' method='post' action=''>";
print "<td><input name='fees' value ='$fees' type='text' size='4' /></td>";
print "<td><input name='price' value ='$price' type='text' size='15' /></td>";
echo "<td><input type='checkbox' onclick='this.$a+.disabled = !this.checked;'><td>";
print"<td><input type='submit' name='$a+' value='Submit' disabled='disabled' /></td>";
print "</tr>";
print "</form>";
}
?>
</table>
Can someone please tell me what am i doing wrong?
Thanks
take out the following code out of loop... it creates multiple form tag...
print "<form id='form1' name='$a+' method='post' action=''>";
Place "<tr></tr>" inside the loop...
final code looks like:
<form id='form1' name='fm1' method='post' action=''> <tr>
<?php
$sql1="select * from pricelist";
$result1=mysql_query($sql1) or die(mysql_error());
while ($row=mysql_fetch_array($result1)) {
$id=$row['id'];
$price=$row['h_price'];
$a=0;
print "<tr>";
print "<td><input name='fees' value ='$fees' type='text' size='4' /></td>";
print "<td><input name='price' value ='$price' type='text' size='15' /></td>";
echo "<td><input type='checkbox' onclick='this.$a+.disabled = !this.checked;'><td>";
print"<td><input type='submit' name='$a+' value='Submit' disabled='disabled' /></td>";
print "</tr>";
}
print "</form>";
?>
Next if u want to control the button only then
<input type='checkbox' onclick='document.$a.submit.disabled = !this.checked;' />
and make sure of the following things:
1.) form name should be $a
i.e <form name='$a' ...>
2.) submit buttons name should be submit
i.e <input type='submit' name='submit'...>
3.) increase the $a variable only at the end of loop
i.e
$a++;
}
i think $a+ will cause syntax error. you need to increment $a at the end of loop like $a++. Also see page source and see what is coming from server.
I would recommend using following format for html + php output
<form id='form1' name='<?=$a++?>' method='post' action=''>
<tr>
<td><input name='fees' value ='<?=$fees?>' type='text' size='4' /></td>
<td><input name='price' value ='<?=$price?>' type='text' size='15' /></td>
<td><input type='checkbox' onclick='this.disabled = !this.checked;'><td>
<td><input type='submit' name='<?=$a++?>' value='Submit' disabled='disabled' /></td>
</tr>
</form>
<?
you also need to have < tr > to be in the while loop.
In your html part where you set up the formular you have to use " " to escape the php code. example:
print "<form id='form1' name='".$a+."' method='post' action=''>";
But as Adeel said already, what is $a+ ?
And you have to edit all prints and echoes in the way, that php expressions are excaped from the HTML source.