Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
<?php /* for loop starts */ ?>
<div>
<input name="cat[]" type="text" />
</div>
<?php /* for loop ends */ ?>
I want to display each value inside the input box if their POST variable is set.
try this bro :
i have a similar query like this.
<?php
$j = 0;
for($i = 1; $i<=8; $i++) {
?>
<tr>
<td style="width:50% !important;">
<input type="text" class="form-control" name="cat[]" value="<?php echo isset( $_POST['cat'][$j] ) ? $_POST['cat'][$j] : ''; ?>" />
</td>
</tr>
<?php $j++; } ?>
Related
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 1 year ago.
Improve this question
I try to get the value from the select area using form and $_Post. I looked through plenty of older questions and am sure, I followed the instructions. still i get the error: Undefined array key "platz".
<form action="" method="POST">
<select name="platz">
<?php
for ($i=0; $i < $saalinfo[2]; $i++) {
echo "<option value='$i'> Reihe $i </option>";
}
?>
</select>
<select class="" name="reihe">
<?php
for ($i=0; $i < $saalinfo[3]; $i++) {
echo "<option value='$i'> Spalte $i </option>";
}
?>
</select>
<?php echo "($_POST[platz])" ?>
</form>
For clarification Saalinfo 2 and 3 contain integer so that there are different options to choose from based on the given values. Many Thanks in advance.
I also tried
<?php echo "($_POST['platz'])" ?>
When the page loads initially there will be no POST data so you get that error. Instead check that POST array is available first - like so perhaps:
<?php echo !empty( $_POST['platz'] ) ? $_POST['platz'] : ''; ?>
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
Hello i want to check if the textarea isnt empty and i still can´t get the echo that i want even when the textarea isnt empty and input is set
here is my code:
<form method="post" action="">
<input type="text" name="jmeno"/>
<textarea name="textarea" id="textarea" rows="5" cols="40"></textarea>
<input type="submit" name="submit"/>
</form>
<?php
if(isset($_POST['jmeno']) AND !empty($_POST['textarea'])){
echo "dokončeno";
}
?>
How about this:
if (!is_null($_POST['jmeno']) && strlen(trim($_POST['jmeno'])) > 0) {
echo "dokončeno";
}
As far as I understand you want your code to check if the submit button is pressed and the textarea isn't empty. I would say the code is:
if(isset($_POST['jmeno'])){
if(strlen($_POST['textarea']) > 0){
echo "dokončeno";
}
}
OR simply:
if(isset($_POST['jmeno']) && strlen($_POST['textarea']) > 0){
echo "dokončeno";
}
if (isset($_POST['jmeno']) && strlen(trim($_POST['textarea']))>0)
{
echo "dokončeno";
}
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
How do I Get This HTML 5 Form To Give PHP The Input Data Then Display It On The Screen. I want to collect data in a form. Convert it into a php variable and then echo it out in a way that I can read it.
<form>
First name:<br>
<input type="text" name="name">
</form>
<body>
<pre>
<?php
$taco = htmlspecialchars($_POST["name"]) . '!';
$taco = $_POST;
echo $taco;
?>
</pre>
</body
</html>
How about the following:
<?php
if($_POST) { // check if the page is posted not with a $_GET
foreach($_POST as $field => $value) { // Foreach field
$value = strip_tags($value); // Strip html tags (you can add more)
echo 'Field: '.$field.' has value: '.$value.'<br>'; // output
}
}
?>
<form action="" method="post">
First name: <input type="text" name="first_name">
<input type="submit" value="Display">
</form>
Just put it all in one php file. You can add as many fields as you want.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I need help with this one. My checkbox value doesnt submit.
<input name="helicopter" type="checkbox" value="<?php echo $aircraft->helicopter; ?>" checked="<?php
if ($aircraft->helicopter==1) {
echo "checked";
}
?>"/>
Try this:
<input name="helicopter" type="checkbox" value="<?php echo $aircraft->helicopter; ?>"
<?php
if ($aircraft->helicopter==1) {
echo "checked";
}
?>>
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
i have an if statement as follows
if($_POST['remember']=="on")
i want to know if this is the correct syntax for checking if the checkbox is checked or unchecked?
This code will help you
<input type="checkbox" name="checkbx" <?php if(isset($_POST['remember'])=="on") echo "checked";?> />
OR
<?php if(isset($_POST['remember'])=="on") {?>
<input type="checkbox" name="checkbx" checked="checked" />
<?php }else {?>
<input type="checkbox" name="checkbx" />
<?php }?>
simple check of isset
if(isset($_POST['remember']) && $_POST['remember']=="on")
{
// checkbox remember is checked
}
else
{
// checkbox remember is not checked
}
Use
if (isset($_POST['remember'])) {
// checked
} else {
not checked
}
<input type="checkbox" name="remember" value="YES" />
$remember= ($_POST['remember'] == 'YES')?'YES':'NO';