Php form submit alert if less than 1min passed [closed] - javascript

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 7 years ago.
Improve this question
I need some help with my php code
<?php
date_default_timezone_set('America/Los_Angeles');
$now = date("H:i:s");
?>
<form method="post" name="update" action="update.php" />
<input type='text' name='fname' value=''>
<input type='text' name='lname' value=''>
<input type='text' name='email' value=''>
...
<button type="submit" value="Submit"/> Submit </button>
</form>
What i need:
If someone clicks on button submit but it passed less than 1 min since start($now)
then it must appear an Alert "Check Info"(not another page or popup),
an alert like "Do you really want to leave the page?"

I should not work for free... but I won't give you the full answer!!! Make an effort and fill in the right code <<< FILL >>> to get it to work!!!
<script src="<<<FILL>>>"></script>
<script>
submitAllowed = false
$("form").submit(function(e){
e.preventDefault();
if (<<<FILL>>>||confirm("Do you really want to leave")) {
this.submit()
}
});
function submitAttempt(){
submitAllowed = true;
}
setTimeout(<<<FILL>>>, 60000);
</script>

Related

How to create 'add quantity' input box and embed it inside PHP scripts? [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 6 years ago.
Improve this question
Thanks for those who helped! I have figured it out!
How can I create a input field like the one in the image? And I want to embed it inside $_POST. Thanks for your time :)
This is an HTML5 input of type number. You use it this way:
<form method="POST" action="yourPHPfile.php">
<input type="number" name="number_input">
<input type="submit">
</form>
When this form is submitted, it will send the selected number to yourPHPfile.php and you can retrieve the number from $_POST['number_input']
You can use input for the number selecotr and post using a form like so:
<form method="post">
<input type="number" name="intNumber"/>
<input type="submit" />
</form>
Then in PHP you can do this
<?PHP
if(isset($_POST['intNumber'])){
$myNumber = $_POST['intNumber']; // intNumber is the name of of your input
}
?>
When the submit button the PHP will be fired.
Hope this helps!

Send an email from HTML / Java script [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
I have a simple html page which should take the input from text box and send that as an email.
function getData()
{ var txt=document.getElementById("result").value; }
<body>
<form>
<input type="text" id="result" size="20">
<input type="button" onclick="getData()">
</form>
</body>
Now i need to send the value of txt as email. Whats the easiest way to achieve that? I am familiar with Java/ Java script. I have no hands on PHP.
You cannot send an email using client-side JavaScript.
You will need to submit the form to a server side script which can send the mail for you.
This is not too difficult using PHP, so I urge you to read up on it. Here's a good link: http://code.tutsplus.com/tutorials/sanitize-and-validate-data-with-php-filters--net-2595
<form action="myscript.php">
<input type="text" name="message" size="20">
<input type="submit" value="Send mail"">
</form>
Then in myscript.php:
<?
$message = filter_var($_POST['message'], FILTER_SANITIZE_STRING);
mail("someone#example.com","My subject",$message);
?>

Keeping entered value on html <textarea> with pages having multiple <form> [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 8 years ago.
Improve this question
My php page consist of a number of textfileds and textareas in which the user can input their details there. these textareas and textfileds are inside a <form></form>.so when clicking on submit button all those values are posted (form method=POST ).
there are 2 <textarea> named as Permanent Address and Communication address. and also a check box "Communi. address is same as permanent". the check box code is follows
<input type="checkbox" id="checkadd" onclick="if (this.checked) copyAddress (this.form)"/>
this function calls copyaddress function that copy the Permanent address to Communication address <textarea>. " copyAddress (this.form) " will copy the value of 1st <textarea>(permanent address). so i don't get the value of Permanent address in the page in which i have to POST this value too to the Next Page.
Can you try this..
<?php
if($_POST['permaddress'])
{
echo $_POST['permaddress'];
echo $_POST['commaddress'];
}
?>
<script>
function copyAddress()
{
if(document.getElementById('checkadd').checked == true)
{
document.getElementById('commaddress').value = document.getElementById('permaddress').value;
}
}
</script>
<form method="post" action="test.php" >
<textarea rows="30"cols="30" name="permaddress" id="permaddress"></textarea>
<textarea rows="30"cols="30" name="commaddress" id="commaddress"></textarea>
<input type="checkbox" id="checkadd" onclick="copyAddress()"/>
<input type="submit" value="submit">
</form>

How to pass textbox value directly through Query String in php [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 8 years ago.
Improve this question
I want to pass textbox value directly through query string the first variable is passed but the second value will be textbox value on the same page. Please help. Thanks
<input type="text" name="txtswap" id="txtswap" size="5" />
Swap
This can't be done with PHP alone, you need some JavaScript for it:
<input type="text" name="txtswap" id="txtswap" size="5" />
Swap
JavaScript:
function doSwap(self, event)
{
var swapValue = document.getElementById('txtswap').value;
event.preventDefault();
location.href = self.href + '&value=' + encodeURIComponent(swapValue);
}
<input type="text" name="txtswap" id="txtswap" size="5" />
<a onclick="swap()" >Swap</a>
<script>
function swap() {
var swapvalue = $('#txtswap').val();
window.location.href = 'UserForm.php?operation=swap&id='+swapvalue ;
}
</script>
Try this
Not tested...
Try this .
Swap
Write JavaScript function
function redirect(){
txtswap = document.getElementById("txtswap").value;
window.location.href = "UserForm.php?operation=swap&id="+txtswap;
}
Since the text box in the same page, you can't use PHP for this. PHP won't see the data (because it won't exist at the time the PHP runs).
Stop using a link and use a form instead, converting user input into a URLs is what they are for.
<form action="UserForm.php">
<input type="hidden" name="operation" value="swap">
<input type="hidden" name="id" value="<?php echo htmlspecialchars($row['id']; ?>">
<input name="txtswap" id="txtswap" size="5">
<input type="submit" value="Swap">
</form>

How to make page submit on itself [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
I am trying to make PHP script, which will submit ID onto itself and want to make auto submit, like refresh which will send data to refreshed page :)Is it posible to use ;URL=''"> this meta refresh
You can use this;
<script>
window.onload = function() {
setInterval(function(){
document.frm.submit();
},5000);
}
</script>
HTML:
<form id="myform" method="post" name="myform">
<?php $id = $_POST['id']; $id=$id+1; ?>
<input type="hidden" name="id" value="<?php echo $id; ?>"/>
</form>
This will submit form every 5 secs after page loaded
Here is a working demo: jsfiddle

Categories