I am currently trying to make a form validation which checks wether some inputs / a textfield are empty or not. I want the text in a textfield to be saved and entered in the next php file in the textfield again. It works with all inputs but not with the textfield. The site loads but the textfield is just empty.
THank you in anticipation!
HTML PART:
<form id="formularheader" name="form" method="post" action="php/contact.php">
<fieldset id="personenInfo">
<p><label for="message" >Nachricht *</label></p>
<p><textarea name="nachricht" id="message" cols="40" rows="10" required=""></textarea></p>
<div class="terms">
<input type="checkbox" name="terms">
</div>
<p style="font-size: 80%; color: #292929; font-style: italic;">* notwendige Angaben</p>
</fieldset>
<input type="submit" id="submitButton" value="Abschicken">
</form>
PHP PART:
<?php
$message = $_POST['message'];
?>
<form id="formularheader" name="form" method="post" action="<?php echo $_SERVER['PHP_SELF']?>">
<fieldset id="personenInfo">
<p><label for="message">Nachricht *</label></p>
<p><textarea name="nachricht" id="message" value="<? echo $message; ?>" cols="50" rows="10" required=""></textarea></p>
<div class="terms">
<input type="checkbox" name="terms">
</div>
<p style="font-size: 80%; color: #292929; font-style: italic;">* notwendige Angaben</p>
</fieldset>
<input type="submit" id="submitButton" value="Abschicken">
</form>
should be $_POST["nachricht"] (name attribute is taken in account when in a POST)
You need to use the field name as opposed to the ID e.g. $_POST['NAME'] whereas you have $_POST['id']
More than one level of validation can be used:
use the HTML5 tool : add required to each input to deny the user from sending empty input
use if(isset())
Related
I am just wondering if I can access to my input from different php page in another folder.
I just want to pass search (input name) from index/index.php to artucles/index.php.
<div style="width: 500px; margin-right: 300px;">
<div class="single_input">
<input style="font-weight: bold;" class="font1" name="search" type="text"
placeholder="Search what you want">
</div>
</div>
Well, you should just use a form.
<form method="post" action="articles/index.php">
<input name="search" type="text" placeholder="Search what you want">
</form>
i want to get value of input of my form via $_post in my insert page but my problem is that i get error massage:undefined index:track_code and i cant get value of it.the names is same what is problem?
this is my problem why stackoverflow want more detail. this is all detail
<form action="insert.php" method="post">
<input name="track_code" type="text" class="tiny-size" value="<?php echo $track_code_rnd ; ?>" style="width: auto;height: auto" disabled />
</form>
<form action="insert.php" method="post" class="form-horizontal form-checkout">
<div class="control-group">
<label class="control-label" for="firstName">نام<span class="red-clr bold">*</span></label>
<div class="controls">
<input name="first_name" type="text" id="firstName" class="span4" >
</div>
</div>
<div class="control-group">
<label class="control-label" for="lastName">نام خانوادگی<span class="red-clr bold">*</span></label>
<div class="controls">
<input name="last_name" type="text" id="lastName" class="span4">
</div>
</div>
<input name="submit" type="submit" class="btn btn-success" value="خرید" style="width: 66px"/>
</form>
<form action="insert.php" method="post">
<input name="track_code" type="text" class="tiny-size" value="<?php echo $track_code_rnd ; ?>" style="width: auto;height: auto" disabled />
</form>
<?php
$track_code = $_POST['track_code'];
?>
Set this one code in your form
<form action="insert.php" method="post">
<input name="track_code" type="text" class="tiny-size" value="<?php echo ($track_code_rnd)?$track_code_rnd:'';?>" style="width: auto;height: auto" disabled />
</form>
Remove disable tag from your input code. Disable controls wont be posted on server. for that you can make it readonly or make it hide
Try Putting the PHP code on the form. as given below.
<?php
if (isset($_POST['submit'])) {
$track_code = $_POST['track_code'];
}
?>
<form action="your_page.php" method="post">
<input name="track_code" type="text" class="tiny-size" value="<?php echo $track_code_rnd; ?>" style="width: auto;height: auto" readonly />
<input name="submit" type="submit" />
</form>
It will execute the whole file as PHP. The first time you open it, $_POST['submit'] won't be set because the form has not been sent. Once you click on the submit button, it will print the information.
Disabled controls never post on server. So make it readonly or hidden.
I want to pass a input value with a url.
<div class="modal-body">
<div id="myDiv" class="answer_list">
<form action="" id="usrform" method="get">
<textarea name="comment" style="width: 450px; height: 80px; form="usrform"></textarea>
<?php echo '<a href="reject_request.php?leave_id='.$id1.'&emp_id='.$emp_id.'">'?>
<button style="float: right" type="button" class="btn btn-primary" name="submit">
Proceed
</button></a></form></div>
</div>
Here I want to pass the textarea input value to 'reject_request.php' page with other variables. I couldn't able to find a way, Can any one help me !
Use method="POST" and action="reject_request.php"
<form action="reject_request.php" id="usrform" method="POST">
<textarea name="comment" id="comment"></textarea>
<input type="hidden" name="leave_id" id="leave_id" value="<?php echo $id1; ?>">
<input type="hidden" name="emp_id" id="emp_id" value="<?php echo $emp_id; ?>">
</form>
In reject_request.php you can access the form datas via $_POST['comment'],$_POST['leave_id'],$_POST['emp_id']
First of all, it is not advisable to pass long content in URL, as commented by #Dhara Parmar.
But if you want to do it,
<form action = "yourpage.php" .... as, again, commented by splash 58
As far as accessing those variables are concerned, you can access them via ASSOCIATIVE GLOBAL ARRAY $GET[KEY]
Hello i want to make one form That Submits data to XXXXXXX and opens a new tab alongside with mydomain.com
Please Help Me To Get This..
<form action="XXXXXXXXXX" method="get" style="margin-top: 12px;">
<label>
<input type="text" name="user" value="" style="width: 100%" placeholder="Your Code Here" autocomplete="off" autofocus="" required>
</label>
<input type="submit" style="width: 84px;margin-top: 10px;" value="Submit" class="submit">
</form>
Please Send me Some Details To Do This.. i Firstly Saw This on official-liker.net submit button..
Try this
<form action="XXXXXXXXXX" method="get" style="margin-top: 12px;" target=_blank>
<label>
<input type="text" name="user" value="" style="width: 100%" placeholder="Your Code
Here" autocomplete="off" autofocus="" required>
</label>
<input type="submit" style="width: 84px;margin-top: 10px;" value="Submit"
class="submit">
</form>
The target attribute specifies a name or a keyword that indicates where to display the response that is received after submitting the form.
For that you would need to use jQuery to submit the form using AJAX and in it's success callback via
window.open(url,'_blank');
Try something like below
<form action="XXXXXXXXXX.php" method="get" target="_blank" style="margin-top: 12px;">
If you want to get Redirected after the Post header("Location: http://www.example.com/") php function.
If you want to open alongside you can use JQuery.
<form>
<input name="text2" type="text" id="text" />
<a class="className" href="#" name="save" id="saveButton">Save</A>
</form>
After that some JavaScript stuff:
$(document).ready(function() {
$("#save").click(function(e) {
e.preventDefault();
$.post("sendPhp.php", { textPost : $("#text").val()},
function(html) {
//open a new window here
window.open("mydomain.com");
}
});
});
No need for Javascript, you just have to add a target="_blank" attribute in your form tag.
<form action="XXXXXXXXXX" method="get" style="margin-top: 12px;" target=_blank>
<label>
<input type="text" name="user" value="" style="width: 100%" placeholder="Your Code Here" autocomplete="off" autofocus="" required>
</label>
<input type="submit" style="width: 84px;margin-top: 10px;" value="Submit" class="submit">
</form>
Following link will help:HTML form target
I hope someone can help me. I'm a little at loss on how I can achive this: I'm trying to pass infos generated in my php to another form made in Javascript. For example, if I put my first name in the input field and click submit, then it would go to another page with the actual form and have the first name already filled there.
One thing that I did notice was that the javascript form isn't within the <form> tag, it's in a bunch of tables with some input fields. I can post what it looks like in pastebin if this can help in understanding what I mean.
Also with this script im unable to edit it, I did not make it, it is one of those script you just place on your site thats auto generated.
My form looks like this:
<form action="auto-form/index.php" method="post" name="openleads" onsubmit="return checkForm(this);">
<label for="first">First Name <span class="required">*</span></label>
<input id="first_name" type="text" name="first" applicationforms="true" /><br>
<label class="error" for="name" id="first_name_error" style="color:#F00; font-size:11px;">This field is required.</label>
<span class="fields">Zip <span class="required">*</span></span>
<input id="zip" type="text" name="zip" applicationforms="true" /><br>
<label class="error" for="name" id="zip_error" style="color:#F00; font-size:11px;">This field is required.</label>
<label for="last">Last Name <span class="required">*</span></label>
<input id="last_name" type="text" name="last" applicationforms="true" /><br>
<label class="error" for="name" id="last_name_error" style="color:#F00; font-size:11px;">This field is required.</label>
<span class="fields">Email <span class="required">*</span></span>
<input id="email" type="text" name="email" applicationforms="true" /><br>
<label class="error" for="name" id="email_error" style="color:#F00; font-size:11px;">This field is required.</label>
<input class="button" type="submit" name="send" value="Send" />
</form>
Any help is appreciated; like I said, I'm a bit at loss on what to do with this one.
php-form.php
<form action="javascript-form.php" method="post">
<input type="text" name="name" />
<input type="submit" value="Submit" />
</form>
javascript-form.php
<form action="" method="">
<input type="text" name="name" value="<?= (isset($_POST['name'])?htmlentities($_POST['name'],ENT_QUOTES):''); ?>" />
<input type="submit" value="Submit" />
</form>
Use PHP to output the POSTed values in to the value attribute of the form fields. You can also use GET variables and use javascript to parse the window.location and scrape those form values.
this seemed to get this done
<script type="text/javascript" src="http://jquery.offput.ca/js/jquery.timers.js"></script>
<script>
$(document).everyTime(1000,function(i){
if($('#ui-datepicker-div').length>0)
{
$('#first_name').val('<?php echo $_POST['first_name']; ?>');
$('#last_name').val('<?php echo $_POST['last']; ?>');
$('#zip').val('<?php echo $_POST['zip']; ?>');
$('#email').val('<?php echo $_POST['email']; ?>');
}
})
$('#first_name').val('test');
</script>