Pass textarea value to server php [closed] - php

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
I'm trying to capture the value of a text area and pick you up php so that it kept on the server. The functionality that is what I do is to change texts and photos so pretend that these changes I have made are saved.
Where I can move friends.
Thank you very much for your time .
That's my last try:
if(isset($_GET['submit'])){
$salida = $_GET['textarea'];
$archivo = fopen("prueba2.html", "w+");
fputs($archivo, $salida);
$contenido = file_get_contents($archivo);
fclose($abrir);
}

You are using $_GET variable, but your <form> has method POST. You have to use $_POST variable instead.

Thats it the html form really thank you
<form id="formulario" action="" method="POST" enctype="multipart/form-data">
<div>
<h3>Haga "click" encima del contenido a modificar</h3>
</div>
<iframe id="probando" src="prueba2.html" scrolling="auto" height="700" width="800" marginheight="0" marginwidth="0" name="probando"></iframe>
<textarea name="textarea" rows="4" cols="50"></textarea>
<input id="botonGuardar" type="submit" value="Confirmar cambios"/>
</form>

Give your textarea a name:
<form>
<textarea name="myTextarea"></textarea>
<!-- the rest of your form -->
</form>
And then in your php:
$salida = $_GET['myTextarea'];

Related

Editable text in Laravel [closed]

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 last month.
Improve this question
I need to make a text that can be edited by user but in some parts I need to make static text for example the date and ....,how to make it ,plz can anyone help me
I have tried the normal input but it did not work as I expected
you can define editable part in page for each section, after type in input with js concatenation all text in main input, and in submit just pass main text to back-end.
like bellow:
<input type="hidden" name="text" id="main-text-id">
<input class="text-part" type="text">
<input class="text-part" type="text">
<input class="text-part" type="hidden"> <!--static part-->
<input class="text-part" type="text">
<input class="text-part" type="hidden"> <!--static part-->
...
and your script :
<script>
const mainText = document.getElementById('main-text-id');
const inputs = document.querySelectorAll('.text-part');
inputs.forEach(input => {
input.addEventListener('input', () => {
mainText.value = Array.from(inputs).map(input => input.value).join(' ');
});
});
</script>

php if else not working in this scenario [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 5 years ago.
Improve this question
I wrote a code such that if I fill all fields of form and I submit then I should get "Ok"
and if I left the form blank then I should get "Please fill all fields".
I am not getting any errors so I am confused how to proceed .
<?php
if(isset($_POST['submit_text']) && isset($_POST['find_word']) && isset($_POST['replaced_word'])){
$sub_text = $_POST['submit_text'];
$fin_text = $_POST['find_word'];
$rep_text = $_POST['replace_word'];
if(!empty($sub_text )&& !empty($fin_text) && !empty($rep_text)){
echo "Ok.";
}else{
echo "Please fill all fields.";
}
}
?>
<html>
<head>
</head>
<body>
<form id="myForm" name="myForm" action="index.php" method="post" >
<p>
Submit Text<br/>
<textarea rows="5" cols="40" type="text" id="submit_text" name="submit_text" ></textarea>
</p>
<p>
Find<br/>
<input id="find_word" name="find_word" type="text" />
</p>
<p>
Replace<br/>
<input id="replace_word" name="replace_word" type="text" />
</p>
<input id="submit" name="submit" type="submit" value="Submit" />
</form>
</body>
</html>
For any query please comment below.
you have missed few characters here
isset($_POST['replaced_word'])
you have to use same name you use in input field.like this
isset($_POST['replace_word'])
Your first "if" needs an "else", I think it would trigger that in your scenario.
I generally try separating these, and do not put them into one large IF..
for example, I would do an if isset and else on each one separately, converting to a different variable accordingly before doing the rest of the logic.
In the first if, you wrote "replaced_word", but the name of the input tag is "replace_word" without the "d". So $_POST['replaced_word'] is never set so that's why it's not working.

Form input submit to table with this data [closed]

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 6 years ago.
Improve this question
Helou,
I have a form like this
<form id="some" data-request="checkout" class="checkoutForm">
<div class="form-group mb10">
<label for="firstName" class="col-sm-12">Name <span class="color-main">*</span></label>
<input class="form-control checkout-form-border" id="firstName" value="" type="text">
</div>
<div class="form-group mb10">
<label for="Address" class="col-sm-12">Address <span class="color-main">*</span></label>
<input class="form-control checkout-form-border" id="address" value="" type="text">
</div>
etc etc ....
</form>
Now, I want on submit button show new page with collected data from this form in a table body.
Can I do this via php and jquery or new custom component?
Thanx
PHP:
need a submit button in the form
need action=" " and method="post" attributes added to your form tag
need to add name attributes to your input boxes
Top of page,
if(isset($_POST['submit'])){
$variable = $_POST['namedOfInputBox'];
echo "<table><tr><td>$variable</td></tr></table>";
{
What that says is if the form is submitted (submit being name of your submit button, generally name it submit), the values coming through are these and in PHP we "echo", or print, out html code and place our variable here. You can either use :
echo "<table><tr><td>$variable</td></tr></table>";
or
echo "<table><tr><td>" . $variable . "</td></tr></table>";

How do I Get This HTML 5 Form To Give PHP The Input Data Then Display It On The Screen [closed]

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.

Why my upload isn't working? [closed]

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 9 years ago.
Improve this question
I'm trying already for two hours to understand what am I doing wrong and I can't figure it out:
My HTML code:
<form action="php/images.php" method="post" enctype="multipart/form-data">
<input type="file" name="image" value="on" id="file">
<input type="submit" name="submit" value="Submit">
</form>
My PHP:
if ( isset($_POST['image'])
&& $_POST['image']=="on")
{
imageUpload();
}
When I removed the if in the PHP file and immediately entered the inner function imageUpload() I've been able to upload the image, why is the variable name I pass using post isn't working?!
Your upload data will be in $_FILES array:
<?php print_r($_FILES['image']); ?>
So something like this:
<?php
if($_SERVER['REQUEST_METHOD'] === 'POST'){
if(isset($_FILES['image']) && $_FILES['image']['error'] == 0){
imageUpload();
}
}
?>
browse button lets you make an array and can be obtain via $_FILES['image'];.Similarly $_FILES also gives an array(size etc).Try var_dump($_FILES); to get the values.

Categories