I have created a simple page with 3 text boxes and three check boxes in it. What I actually want to do is; Now consider that we have a student data page called "A" and the page I have created is "B".
Assume that I entered the first name and last name in "B"(which is the page we are going to create); the first name and last name should be taken to page "A"(site from where we want result. It should be auto-filled and once the result come(I actually mean when the next page opens). a screenshot of the page should be taken and saved in a particular location.
The location is like D:\REPORT\student 1
All the screenshots must be save here
The three check boxes are three different sites. I should be able to get the result from one or more of those three sites
This is the code that I have coded.
<html>
<center><font size="24" color="White"><b>
Experiment 1</center></font></b></i>
<body bgcolor="600000" bgproperties="fixed">
<br><br><b><font color="White">
First Name:<br>
<input type="text" name="fn"><br><br>
Last Name:<br>
<input type="text" name="ln"><br><br>
File Stored Location<br>
<input type="text" name="fsl"><br><br>
<form>
<input type="radio" name="site1" value="site1"> site1 <br>
<input type="radio" name="site2" value="site2"> site2<br>
<input type="radio" name="site3" value="site3"> site3<br>
<input type="submit" value="Submit">
</form>
</body>
</html>
Is this possible?
First of all, consider using CSS for your layout. It's much cleaner then what you are using now :).
Wrap everything in a form like so:
<html>
<center><font size="24" color="White"><b>
Experiment 1</center></font></b></i>
<body bgcolor="600000" bgproperties="fixed">
<br><br>
<form action="a.php" method="POST">
<b><font color="White">
First Name:<br>
<input type="text" name="fn"><br><br>
Last Name:<br>
<input type="text" name="ln"><br><br>
File Stored Location<br>
<input type="text" name="fsl"><br><br>
<input type="radio" name="site1" value="site1"> site1 <br>
<input type="radio" name="site2" value="site2"> site2<br>
<input type="radio" name="site3" value="site3"> site3<br>
<input type="submit" value="Submit">
</form>
</body>
</html>
Then you need php in your a.php to collect the post data from your form.
Related
How to keep user's input after they submit a form?
For example:
<form action="a.php" method="POST">
First name:<br>
<input type="text" name="firstname">
<br>
Last name:<br>
<input type="text" name="lastname">
<br><br>
<input type="submit" name="submit" value="Submit">
</form>
<?php
if(isset($_POST['submit']){
$firstname=$_POST['firstname'];
$lastname=$_POST['lastname'];
echo $firstname.$lastname;
?>
if user key in fname and lname, yes, it will echo out.. but i wan to keep their first name and last name at the input type, so that user dont need to refill again if the form is long.
You want to make your form sticky so that the user does not need to fill the entire form again which is a good practice.
You can add value to your form inputs for your form example like shown below:
<input type="text" name="firstname" value="<?php if(isset($_POST['firstname'])) echo $_POST['firstname'];?>" />
<input type="text" name="lastname" value="<?php if(isset($_POST['lastname'])) echo $_POST['lastname'];?>" />
In the similar way, you can make your entire form sticky (different for textarea and others but the similar idea).
I'm new to php and html, so I'm not sure that the title is easy to understand, sorry for that. The problem is simple , I have an html form like this:
<form action="action_calibration.php" method=post>
<br><br>
<input type="radio" name="type" value="fast" checked>Fast Calibration
<br><br>
<input type="radio" name="type" value="old">Old Calibration
<br><br>
<input type="checkbox" name="ScanVPlus" value="yes" checked>Scan
<br><br>
<input type="checkbox" name="Bitwise" value="yes">Bitwise Offset
<br><br>
<input type="checkbox" name="All_channel" value="yes">Calibration
<br><br>
Output Folder:<input type="textfield" name="output" value="Results/">
<br><br>
Hw Description File:<input type="textfield" name="Hw Description File " value="settings/Calibration2CBC.xml">
<br><br>
<input type="submit" value="Submit">
</form>
The action_calibration.php is a php page that execute a binary file and show the results on the php page, what I'm tring to do is print these results on the page containing the form, without open another one. I hope that you can understand what I mean. Thank you.
Try including an iframe sibling the form, with a name, and giving the form a target attribute.
Related: How do you post to an iframe?
This is hard to explain so bear with me.
I'm building a page that consists of multiple forms that are all submitted with one submit button at the bottom like so:
<form action="" method="post">
<input type="text" name="name1" value="<?$variable1;?>" placeholder="Type here...">
<form action="" method="post">
<input type="text" name="name2" value="<?$variable2;?>" placeholder="Type here...">
<form action="" method="post">
<input type="text" name="name3" value="<?$variable3;?>" placeholder="Type here...">
<form action="" method="post">
<input type="text" name="name4" value="<?$variable4;?>" placeholder="Type here...">
<input type="submit" name="submit" value="Submit">
</form>
Each of these forms asks the user for data, which then echos to a text box so that they can copy/paste the output.
Now, suppose the user fills out the data for one of these forms only and clicks on the submit button. Naturally, the data they entered would go to the text box. What I need however is that when the user then decides to fill out the rest of the forms, the data that was originally echoed is still in the text box, preferrably as well as the answer they put in the form (however not essential).
What I'm finding at the moment is that the form resets after clicking submit, so even though the user has submitted one part of the form, when they go to fill out the rest and click submit again, only the other 3 are echoed and the first one is omitted.
I hope this makes sense. Any idea on how one would go about this?
EDIT: Nearly got it with the following:
if (isset($_POST['submit'])) {
if (isset($_SESSION['test1'])) {
$_SESSION['test1']=$_SESSION['test1'];
}
else {
$_SESSION['test1'] = $_POST['test1'];
}
}
However the variable now doesn't change when we enter something new into the form field...
<form action="" method="post">
<input type="text" name="name1" value="<?$variable1;?>" placeholder="Type here...">
<input type="text" name="name2" value="<?$variable2;?>" placeholder="Type here...">
<input type="text" name="name3" value="<?$variable3;?>" placeholder="Type here...">
<input type="text" name="name4" value="<?$variable4;?>" placeholder="Type here...">
<input type="submit" name="submit" value="Submit">
</form>
Call only once. One submit button is for 1 form. Please try this. It should work
You need <?= $variable1; ?> etc. Otherwise it doesn't output anything.
I wish to use a single HTML form to send the user's input to my email, and simultaneously a web page that the user views their input. At present I can only get one of the two options; the web page re-direct which displays the users input.
Is there a back-side PHP script to accomplish sending the user input to both an email and a web page?
Form code:
<form id="form1" name="form1" method="post" action="TEST.php">
<input name="name" type="text" class="formdetail" id="name" />
<input name="color" type="text" class="formdetail" id="color" size="45"/>
<input name="animal" type="text" class="formdetail" id="animal" size="45"/>
<input name="room" type="text" class="formdetail" id="room" size="45"/>
<input name="water" type="text" class="formdetail" id="water" size="45"/>
<input name="email2" type="text" class="formdetail" id="email" size="45"/>
<input type="submit" name="submit2" id="submit" value="Submit" />
<input type="hidden" name="recipients" value="http://www.Website.net/TEST.php" />
<input type="hidden" name="good_url" value="http://www.Website.net/TEST.php" />
</form>
Results web page page code:
<p>Your results, <?php echo htmlspecialchars($_POST['name']); ?>:</p>
<p>1. Your favorite color reveals: <?php echo htmlspecialchars($_POST['color']); ?>.</p>
<p>2. Your favorite animal reveals: <?php echo htmlspecialchars($_POST['animal']); ?>.</p>
<p>3. This reveals: <?php echo htmlspecialchars($_POST['room']); ?>.</p>
<p>4. This reveals: <?php echo htmlspecialchars($_POST['water']); ?>.</p>
So if I'm understanding your question correctly you want that script to send the user on to the next page after it emails you?
It's really very simple :)
First, you need to store your data into some persistent store, such as a session using start_session() on your first page. This will allow you to store data in the $_SESSION super global. Then on your next page after using:
http_redirect($newUrl);
You can grab the session data using that same superglobal
Place that after your email code and you should be good to go. If you're asking something a little different please don't hesitate to call me out and we can figure this thing out.
For reference: http_redirect() in a nutshell
And: php sessions in a nutshell
I am done with the search page where the user enters the information and select from the drop-list. I've also added the button AddList where you can have more than one search form with tag names changed. All of the searches will eventually be executed in one Submit button and each search will go in one single query. My table caries all the information and tuples contain only numbers.
UPDATED: I tried changing the input type of the input tags but the enable and disable functions can't seem to work on integers, only on text fields. How can I fix that?
My submission is tomorrow, and here is my search code:
<script type="text/javascript">
$('#exactButton').live('click', function(){
$(this).prev().prev().prev().prev().prev().removeAttr('disabled');
$(this).prev().prev().prev().attr('disabled',true);
$(this).prev().prev().prev().prev().attr('disabled',true);
});
$('#rangeButton').live('click',function(){
$(this).prev().prev().removeAttr('disabled');
$(this).prev().prev().prev().removeAttr('disabled');
$(this).prev().prev().prev().prev().attr('disabled',true);
});
})
</script>
And this is my HTML code:
<button id="button">Add List</button><br><br>
<form id ="form" name="search" method="get" action="test.php">
<div id="div">
<select name ="select" >
...options...
</select>
Value:<input type="text" name="exact" id="exactField" />
From: <input type="text" name="from" id="fromField" />
To: <input type="text" name="to" id="toField" />
<br>
<input type="button" name="answer" value="Range" id="rangeButton" />
<input type="button" name="answer" value="Exact" id="exactButton" />
</div>
<br>
<input type="submit"name="search" value="Submit">
</form>
Thank you in advance..
as Dagon said, you will see all submitted parameters in the URL since you are submitting the form with method GET. here is very good explanation for this: http://www.w3schools.com/php/php_get.asp
One idea:
add some custom attributtes to the elements (to the clones too).
this.attr("mycustomattribute","somevalue");
after this, you can get all elements on the page with your custom attribute and your value.
divs = $('div[mycustomattribute="somevalue"]'); //should give all div container with attribute "mycustomattribute" with value "somevalue"
divs.each(function(){
console.log(this,$(this).attr('name'));//show expression (for debug)
});
then you can collect this elements, serialize it and add it to your post Not tested, but an idea.
Kind Regards
In PHP, it's already there.
print_r($_GET); will list all parameters sent by GET method
print_r($_POST); will list all parameters send by POST method.
Then, of course, you will need to iterate in the array to include each values in your query statement.
You can naming input with prefix or suffix correspond to sequence that user click to add list and add those set of inputs to only form.
<form id ="form" name="search" method="get" action="test.php">
<div>
<select name ="select[1]" >
...options...
</select>
Value:<input type="text" name="exact[1]" class="exactField" />
From: <input type="text" name="from[1]" class="fromField" />
To: <input type="text" name="to[1]" class="toField" />
<br>
<input type="button" name="answer[1]" value="Range" class="rangeButton" />
<input type="button" name="answer[1]" value="Exact" class="exactButton" />
</div>
<div>
<select name ="select[2]" >
...options...
</select>
Value:<input type="text" name="exact[2]" class="exactField" />
From: <input type="text" name="from[2]" class="fromField" />
To: <input type="text" name="to[2]" class="toField" />
<br>
<input type="button" name="answer[2]" value="Range" class="rangeButton" />
<input type="button" name="answer[2]" value="Exact" class="exactButton" />
</div>
.
.
.
<br>
<input type="submit"name="search" value="Submit">
</form>