This is my code for texarea that i have.
<textarea class="text" id="post_content_auto" name="post_content_auto"><?php echo (!empty($car_info['post_content_auto']) ? $car_info['post_content_auto'] : ''); ?></textarea>
I want to echo that on some other page and for that i use this code :
<?php echo strip_tags($car_info['post_content_auto']); ?>
But it won't echo text. I tried to change id and name but still no result.
You need to wrap that form element in a form, give it the post method, and an action that points to your PHP file. In your PHP file, access that variable as $_POST['post_content_auto']
Related
I have div element with dynamic id for input type text.
this is my html code.
<?php
for($j=0;$j<=3;$j++){
?>
<input type="text" id="money<?php echo $j; ?>"/>
<?php
}
?>
And this is my script. I try with this code but its not work, and the value is still empty.
$("#money1").val("200");
I try with this code and its working, but it affect all of the input type text with 'money' id.
$('input[id^="money"]').val("200");
please help me, I'm already stuck.
Thank you for your attention.
Is it possible to echo php value into form label? Currently I can only echo into textbox which is editable for the user but I want it to be unable to edit like label, any way I can do so?
Below is for textbox which is able to work
<input style="color:#000000" type="text" value="<?php echo $account['Username']; ?>" name="name" required/>
I tried to echo in label but nothing shown in my web
<label for="fullname"><?php echo $account['Fullname']; ?></label>
Use the echo statement. Like this:
<label><?php echo ("this is a label");?></label>
Of course it is possible.
You can use the echo function like you used it before.
Make sure:
you are using PHP file (*.php)
index in array is not empty
you are using < ? php tags
Try this:
// index.php
<?php
$text = "privet";
?>
<label for="fullname"><?php echo $text; ?></label>
// output is <label for="fullname">privet</label>
read this http://php.net/manual/en/function.echo.php
be careful and read also this http://php.net/manual/en/function.htmlspecialchars.php
BTW: if it still does not working... just use dump to get the variable info
<label><?php echo $var; ?></label> // does not working
// ok -> then dump the var!
<?php var_dump($var); ?> // hmm.. lets see (maybe null or string(0)?) :-)
Explanation
I have a plain HTML form with a few fields
I post it to my controller function
In the function I var_dump the POST data
public function actionReceive()
{
echo "<pre>";
var_dump($_POST);
echo "</pre>";
exit();
}
On screen php shows the POST data is empty
In Firebug I can see the POST data
Question
Why is the POST data not displayed in the var_dump?
When I post it directly to a view file in site/page the POST is displayed with var_dump.
why are you using var_dump($_POST) ??
If you want to pass data from one page to another in PHP just create 2 files. Let's sets first file name as send.html, and another one as receive.php.
Now put these codes into send.html file:
<form method="post" action="catching-var.php">
1. <input type="text" name="name1"/><br/>
2. <input type="text" name="name2"/><br/>
3. <input type="text" name="name3"/><br/>
4. <input type="text" name="name4"/><br/>
<input type="submit" name="submit"/>
</form>
Also put these lines into receive.php file:
<?php
$name0 = $_POST['name0'];
$name1 = $_POST['name1'];
$name2 = $_POST['name2'];
$name3 = $_POST['name3'];
$name4 = $_POST['name4'];
echo $name0.'<br/><br/>';
echo $name1.'<br/><br/>';
echo $name2.'<br/><br/>';
echo $name3.'<br/><br/>';
echo $name3.'<br/><br/>';
?>
Put some values into the HTML textbox fields and click the Submit button.
EDIT: If you do this in Yii Framework all of these operations and codes are same. But you must paste the PHP codes in action. That's all.
Please tell me; in which step you have problem?
Thanks. Best regards.
I have the following link on index page
<td align="center">update</td>
and this is the page it goes to ... Update.php
and here is the code
$id=$_GET['keyword'];
<tr><td> Keyword: </td><td> <input type="text" name="keyword" id="keyword" value="<? echo $id['keyword']; ?>">
I want the keyword to be automatically inserted into the form so that the rest of info can be updated. How can i accomplish this? For some reason this is not working. It is putting the keywork in the URL ?id=KEYWORD on the update page but not displaying in the form. Prob something stupid im sure
You need to either use $_GET['id'] or change the link href to ../athena/admin/update.php?keyword=. Currently, you are not looking for the id parameter, which contains the keyword.
You need to change:
<? echo $id['keyword']; ?>
to:
<?php echo htmlspecialchars($id); ?>
Note:
I used normal php tags instead of short tags, just in case;
I used htmlspecialchars to avoid errors and javascript nastiness; always prepare your data for the medium you are outputting to.
Please check your variable name again.
Here, you pass .php?id= as your GET parameter:
<td align="center">update</td>
In the Update.php, I think you were just misnamed it, it was supposed to be:
$id = $_GET["id"]; //not $_GET["keyword"]
The code below will output all the GET parameter, usually useful to debug in a simple PHP app:
<?php
echo '<pre>';
print_r($_GET);
echo '</pre>';
?>
Hope it helped.
Edit: there is no println in php. Use print_r() or var_dump()
$id=$_GET['keyword'];
<tr><td> Keyword: </td><td> <input type="text" name="keyword" id="keyword" value="<? echo $id; ?>">
May be like this?
I have textarea in the UI which i display text inside it from db and the user edits it and clicks on update button.
while($row=$stmt->fetch(PDO::FETCH_NUM,PDO::FETCH_ORI_NEXT)){
<textarea id= <?php echo $row5[0]; ?> name='upAncText[]' rows=1 cols=40> <?php echo $row5[1]; ?> </textarea><br/>
}
Now when i click on update i have to read the id and texarea value inorder to insert into DB. could anyone let me know how to do this in php?
Change your textarea to something like this:
// Are you sure you want $row5 and not $row ?
<textarea name="upAncText[<?= $row5[0]; ?>]"></textarea>
Now, when you grab $_POST['upAncText'], it will be an array with keys that are the textarea ID and values that are the user input.
FYI, <?= ?> is shorthand for <?php echo ?>