After sending, an error always flies to me Undefined index: post what to do? help please
if(isset($_POST['submit'])){
$description = htmlspecialchars($_POST['post']);
}
<form action="sell.php" method="POST" name="confirmationForm">
<textarea placeholder="Post your Comment Here ..." form="confirmationForm" name="post" class="form-control custom-control" rows="3" style="resize:none"></textarea>
<input type="submit" name="submit" value="Send Request">
</form>
Remove form="confirmationForm" from textarea.
Try this
<textarea placeholder="Post your Comment Here ..." name="post" class="form-control custom-control" rows="3" style="resize:none"></textarea>
While using form attribute in form elements, the id attribute of form should be same as form attribute of form elements. Like:
<form action="sell.php" method="POST" id="confirmationForm">
<textarea placeholder="Post your Comment Here ..." form="confirmationForm" name="post" class="form-control custom-control" rows="3" style="resize:none"></textarea>
<input type="submit" name="submit" value="Send Request">
</form>
Or remove form attribute from textarea.
The textarea value does not get send with the rest of your form data, because you associated it with a non-existing form reference, form="confirmationForm" - the value of this attribute must contain the ID of a form element.
Your form only has name="confirmationForm".
Add an id, or remove the form attrribute from the textarea.
Try this code...
<form action="sell.php" method="POST" id="confirmationForm">
<textarea placeholder="Post your Comment Here ..." name="post" class="form-control
custom-control" rows="3" style="resize:none"></textarea>
<input type="submit" name="submit" value="Send Request">
</form>
Related
I'm trying to call a php file in a html form, as shown in my code, but the send button is not functioning, any ideas ?
<form id="contact-form" method="post" action="form_send.php">
<fieldset>
<label class="name">
<input type="text" value="Your Name" onFocus="if(this.value=='Your Name'){this.value=''}" onBlur="if(this.value==''){this.value='Your Name'}">
</label>
<label class="phone">
<input type="text" value="Telephone" onFocus="if(this.value=='Telephone'){this.value=''}" onBlur="if(this.value==''){this.value='Telephone'}">
</label>
<label class="email">
<input type="email" value="Email" onFocus="if(this.value=='Email'){this.value=''}" onBlur="if(this.value==''){this.value='Email'}">
</label>
<label class="message">
<textarea onFocus="if(this.value=='Message'){this.value=''}" onBlur="if(this.value==''){this.value='Message'}">Message</textarea>
</label>
<div class="btns"> <a class="button" onclick="clearFunction()" >Clear</a> <a class="button" type="submit" name="submit" value="Send Form" >Send</a> </div>
</fieldset>
</form>
you are use <a> tag to submit the form
replace <a class="button" type="submit" name="submit" value="Send Form" >Send</a> with <input class="button" type="submit" name="submit" value="Send Form" >
You are not naming any inputs in your form..
<input **name='name'** value='Your name'>
<input **name='phone'** value='Phone'>
and so on..
for proccessing:
if(isset($_POST['submit'])){
$name=$_POST['name'];
$phone=$_POST['phone'];
$xxx=$_POST['xxx'];
echo $name, $phone; //echoing data.
}
and so on.
Don't forget to sanitize your data before submitting..(ANTI-SQL INJECTION)
and instead of your OnBlur and OnFocus solution: placeholder='Your name'
I have got two different forms on the same page.
<form action="" method="post" onsubmit="ajax_send('<?print $userid;?>',this.msg.value); return false;">
<input id="msg" autocomplete="off" type="text" name="msg" stlye="width: 80px;" autofocus="autofocus" placeholder="Chat here" />
<input type="submit" />
</form>
and
<form action="?page=about&id=0#comments" method="post">
<textarea class="editbox" id="exitbox" placeholder="Write a comment ..." name="newcomment"></textarea>
<input type="submit" id="submit1" name="submit1"></div></div>
Now when I enter something in <input id="msg"..> and press enter, it submits the second form instead of the first one.
What am I missing?
Your second form isn't closed.
Your second form should by like that
<form action="?page=about&id=0#comments" method="post">
<textarea class="editbox" id="exitbox" placeholder="Write a comment ..." name="newcomment"></textarea>
<input type="submit" id="submit1" name="submit1"></div></div>
</form>
Find below my form and the action page it submits to. The _POST array is empty. Not sure how. Please help.
index.php
<form method="post" action="track-them.php">
<input type="text" width="255" id="txt" />
<textarea id="ta" type="text" cols="25" rows="4"></textarea>
<input type="submit" id="check-button" value="Ok" />
</form>
track-them.php
<?php
include_once('../simple_html_dom.php');
print_r($_POST);
?>
Both fields txt & ta have values but the output I see when I click submit is:
Array ( )
Add name attribute to your form elements:
<form method="post" action="track-them.php">
<input type="txt" width="255" id="myurl" name="myurl" />
<textarea id="ta" name="ta" type="text" cols="25" rows="4"></textarea>
<input type="submit" id="check-button" value="Ok" />
</form>
Give your inputs a name. The browser passes the name attribute not the id.
If you put the print_r($_POST) above the inclution what is the result ?
Please add name attribute for each from element
Hey guys I am not able to pass the variable "profile" through... This is done with smarty templates btw
{if $commentpossible == true}
<form name="form1" method="get" action="comment.php?profile=5">
<p>
<label for="comment"></label>
<textarea name="comment" id="comment" cols="45" rows="5" ></textarea>
<br>
<input type="submit" name="Submit" id="Submit" value="Submit">
</p>
</form>
{/if}
Basically this page is profile?profile=5 and I want to pass that profile through...I have "5 manaully inputed atm rather than a variable just too see if it would work...it still does not....when submit is hit it just goes to comment.php?comment=&Submit=Submit....(comment is blank intentionally there)...I need to be more comment.php?profile=5comment=blablabla etc etc
Any idea on what could be the problem?
Add profile as a hidden field when you're using the GET method:
{if $commentpossible}
<form name="form1" method="get" action="comment.php">
<input type="hidden" name="profile" value="5">
<p>
<label for="comment"></label>
<textarea name="comment" id="comment" cols="45" rows="5" ></textarea>
<br>
<input type="submit" name="Submit" id="Submit" value="Submit">
</p>
</form>
{/if}
I have a form and need to submit it and save the data as a JSON file.
Is it possible?
If so how please?
Here is my simple form below.
<form action="#" method="">
<div data-role="fieldcontain">
<label for="date">Date Input:</label>
<input type="date" name="date" id="date" value="" /><br /><br />
<label for="textarea">Event:</label>
<textarea cols="40" rows="8" name="textarea" id="textarea"></textarea>
<input type="submit" value="save to json" />
</div>
</form>
<?php
$file = dirname(__FILE__).'/form-data-'.time().'-'.rand(1000,9999);
file_put_contents($file, json_encode($_REQUEST));
?>
Read this post on google http://www.ryancoughlin.com/2009/05/04/how-to-use-jquery-to-serialize-ajax-forms/
I found it by googeling "jquery serialize form"
just use json_encode function like this json_encode($_POST)