I am creating a form using html and php, inside this form I have date input "from" and date input "to".
How can "to" get update with the date I select in "from"?
For example, if I select in the "from" July 1st, I want "to" to get update with the same date or the next day.
This is my form:
<?php ob_start() ?>
<?php if(isset($params['message'])) :?>
<b><span style="color: red;"><?php echo $params['message'] ?></span></b>
<?php endif; ?>
<?php
date_default_timezone_set('America/Costa_Rica');
?>
<br/>
<form name="formInsertDocument" action="index.php?ctl=insertDocument" autocomplete="off" method="POST">
<h2>Insert New Document</h2>
<fieldset>
<ul>
<li>
<label for="name">Type:</label>
<input type="number" name="id_type" required value="<?php echo $params['id_type'] ?>" />
</li>
<li>
<label for="name">Client:</label>
<input type="number" name="id_client" required value="<?php echo $params['id_client'] ?>" />
</li>
<li>
<label for="name">Date:</label>
<input type="date" name="date_document" required value="<?php echo date('Y-m-d'); ?>" value="<?php echo $params['date_document'] ?>" />
</li>
<li>
<label for="name">Arrival:</label>
<input type="date" name="date_arrival" required value="<?php echo date('Y-m-d'); ?>" value="<?php echo $params['date_arrival'] ?>" />
</li>
<li>
<label for="name">Departure:</label>
<input type="date" name="date_leaving" required value="<?php echo date('Y-m-d'); ?>" value="<?php echo $params['date_leaving'] ?>" />
</li>
<li>
<label for="name">Subtotal:</label>
<input type="number" name="subtotal" required value="<?php echo $params['subtotal'] ?>" />
</li>
<li>
<label for="name">Taxable:</label>
<input type="number" name="taxable" required value=00000000 value="<?php echo $params['taxable'] ?>" />
</li>
<li>
<label for="name">Tax:</label>
<input type="number" name="tax" value=00000000 value="<?php echo $params['tax'] ?>" />
</li>
<li>
<label for="name">Other:</label>
<input type="number" name="other" required value="<?php echo $params['other'] ?>" />
</li>
<li>
<label for="name">Total:</label>
<input type="number" name="total" required value=0 value="<?php echo $params['total'] ?>" />
</li>
</ul>
</fieldset>
<input type="submit" value="Insert" name="insert" />
</form>
<?php $contenido = ob_get_clean() ?>
<?php include '../app/templates/layout.php' ?>
With javascript you'll have to use something like this:
<script>
var date_arrival = document.getElementsByName('date_arrival')[0];
var date_leave = document.getElementsByName('date_leave')[0];
date_arrival.addEventListener('change', function() {
date_leave.value = date_arrival.value;
});
</script>
Related
In the below code i need to pass the value of firstname to hidden field (billing_name). I've tried it using jquery and php. but it didnt worked out.
Anyone help me out to pass the values of textbox without submitting the form to the hidden field
<form method="POST" name="customerData" action="<?php echo get_template_directory_uri(); ?>/payment/ccavRequestHandler.php">
<div id="personal-reservation-form-wrap">
<h5><?php echo $personalInfoHeader; ?></h5>
<div id="required-desc"><?php echo $personalInfoDescription; ?></div>
<div id="resform-firstname" class="form-field-wrap">
<div class="resform-header"><?php _e("Full Name","nation") ?> <span class="main-reservation-form-asterisk">*</span></div>
<input type="text" name="firstname" class="form-field-wrap required-field" id="firstname" required >
</div>
<div id="resform-lastname" class="form-field-wrap">
<div class="resform-header"><?php _e("Mobile Number","nation") ?> <span class="main-reservation-form-asterisk">*</span></div>
<input type="text" name="lastname" class="form-field-wrap required-field" required>
</div>
<div id="resform-email" class="form-field-wrap">
<div class="resform-header"><?php _e("Email","nation") ?> <span class="main-reservation-form-asterisk">*</span></div>
<input type="text" name="email" class="form-field-wrap required-field email-field" required>
</div>
<div id="resform-retypeyouremail" class="form-field-wrap">
<div class="resform-header"><?php _e("Address","nation") ?> <span class="main-reservation-form-asterisk">*</span></div>
<input type="text" name="resform-retypeyouremail" class="form-field-wrap required-field email-field" required>
</div>
<input type="hidden" name="order_id" value="<?php echo $tnx1 ?>"/>
<input type="hidden" name="merchant_id" value="555555"/>
<input type="hidden" name="amount" value="<?php echo $total_money; ?>"/>
<input type="hidden" name="checkin" value="<?php echo $checkin1; ?>"/>
<input type="hidden" name="checkout" value="<?php echo $checkout1; ?>"/>
<input type="hidden" name="roomid" value="<?php echo $room_id ?>"/>
<input type="hidden" name="currency" value="INR"/>
<input type="hidden" name="room_id" value="<?php echo $room_id; ?>" />
<input type="hidden" name="billing_name" value="">
<input type="hidden" name="billing_email" value="">
<input type="hidden" name="billing_tel" value="">
<input type="hidden" name="billing_address" value="">
<input type="hidden" name="redirect_url" value="http://hotels.com/wp-content/themes/wpnation/payment/ccavResponseHandler.php">
<input type="hidden" name="cancel_url" value="http://hotels.com/wp-content/themes/wpnation/payment/ccavResponseHandler.php"/>
<div id="resform-comments" class="form-field-wrap">
<div class="resform-header"><?php _e("Comments","nation") ?></div>
<textarea type="text" name="resform-comments" required></textarea>
</div>
<?php if ($enable_coupon) { ?>
<div id="resform-firstname" class="form-field-wrap">
<div class="resform-header"><?php _e("Enter Coupon Name","nation") ?></div>
<input type="text" name="resform-coupon" class="form-field-wrap">
</div>
<?php } ?>
<input name="room-id" type="hidden" value="<?php echo $_POST["room-id"]; ?>">
<input name="step3-send" type="hidden" value="true">
</div>
If after submit, you can fill it like this:
<input type="hidden" name="text_hidden" value="<?php echo htmlspecialchars($_POST['text_visible']); ?>">
If on fly, then use jQuery:
<script>
$(document).ready(function () {
$('input[name="text_visible"]').on('change', function () {
$('input[name="text_hidden"]').val($('input[name="text_visible"]').val());
});
});
</script>
put this pretty anywhere, i would recommned before or after the form
In my custom Wordpress theme, I have custom login form:
<form method="post" action="<?php bloginfo('url') ?>/wp-login.php" name="login">
<div class="login-form-container resp-hidden">
<div class="login-form-container-inner">
<h3 class="form-title"><?php echo __('Login', 'louise'); ?></h3>
<label for="user_login">
<?php echo __('User name or e-mail', 'louise'); ?>: </label>
<input class="para-content" type="text" name="log" placeholder="" value="<?php echo esc_attr(stripslashes($user_login, $user_email)); ?>" size="20" id="user_login" tabindex="11" required>
<label for="user_pass">
<?php echo __('Password', 'louise'); ?>: </label>
<input class="para-content" type="password" name="pwd" value="" size="20" id="user_pass" tabindex="12" required/>
<label for="rememberme"> </label>
<div class="buttons">
<?php do_action('login_form'); ?>
<input type="submit" name="user-submit" value="<?php echo __('Log in', 'louise'); ?>" tabindex="14" class="signupbtn" />
<input type="hidden" name="redirect_to" value="<?php echo icl_get_home_url() ; ?>" />
<input type="hidden" name="user-cookie" value="1" />
</div>
</div>
</div>
</form>
It gets the job done, but problem appears when I am trying to log in from different than default language. Login redirects to the front-page leaving with inactive URL: http://test.com/?lang=en/wp-login.php I am using WPML plugin for two languages, default one is lt_LT and en_US as additional.
I was digging threw all the weekend, but found no valid solution. To make it clear, I don't get if I have to translate core WP wp-login.php page, o is there a shortcut to bypass wp-login.php and redirect user straight to home page?
Many thanks for all possible help and suggestions.
Looking forward,
First change the form action to
<?php echo $_SERVER['REQUEST_URI']; ?>
and use this PHP after the form
if (isset($_POST['user-submit'])) {
login_auth($_POST['log'], $_POST['pwd']);
}
and add this function to functions.php
function login_auth( $username, $password ) {
global $user;
$current_cookie = esc_attr( $_COOKIE['_icl_current_language'] );
$url = '/'.$current_cookie;
$login_page = site_url($url);
$creds = array();
$creds['user_login'] = $username;
$creds['user_password'] = $password;
$creds['remember'] = true;
$user = wp_signon( $creds, false );
if ( is_wp_error($user) ) {
echo $user->get_error_message();
}
if ( !is_wp_error($user) ) {
wp_redirect($login_page);
}
}
After all, here is my solution that worked in my case. Seems, that the problem was language parameter set by WPML plugin. It is possible to check if current link has ?lang=en/ and change it with default wp-login url.
<?php
if($login = strstr($_SERVER['REQUEST_URI'], "?lang=en")) {
$login = wp_login_url();
} else {
$login = wp_login_url();
}?>
<form method="post" action="<?php echo $login?>"
<div class="login-form-container resp-hidden">
<div class="login-form-container-inner">
<h3 class="form-title"><?php echo __('Login', 'louise'); ?></h3>
<label for="user_login">
<?php echo __('User name or e-mail', 'louise'); ?>: </label>
<input class="para-content" type="text" name="log" placeholder="" value="<?php echo esc_attr(stripslashes($user_login || $user_email)); ?>" size="20" id="user_login" tabindex="11" required>
<label for="user_pass">
<?php echo __('Password', 'louise'); ?>: </label>
<input class="para-content" type="password" name="pwd" value="" size="20" id="user_pass" tabindex="12" required/>
<label for="rememberme"> </label>
<div class="buttons">
<?php do_action('login_form'); ?>
<input type="submit" name="user-submit" value="<?php echo __('Log in', 'louise'); ?>" tabindex="14" class="signupbtn" />
<input type="hidden" name="redirect_to" value="<?php echo $_SERVER['REQUEST_URI']; ?>" />
<input type="hidden" name="user-cookie" value="1" />
</div>
</div>
</div>
</form>
I feel like this should be pretty simple, but I'm not getting the results that I want. I have an email signup form that displays across all my websites. If they happen to visit my website with the store code ama_br the email signup disappears. That is fine and that works. My elseif statement is a different form than the one that is displayed across all store views and I want this new form to only appear when it's store code ama_ca. It does not work for me and I don't see anything wrong with my code. Please help. Thank you.
<?php if (Mage::app()->getStore()->getCode() != "ama_br"):?>
<ul>
<li><?php echo $this->__('Email Sign Up')?></li>
<li>
<form action="<?php echo $this->getUrl('email_preferences')?>" method="get" id="newsletter-validate-detail">
<input name="email" type="text" id="newsletter" placeholder="<?php echo $this->__('Enter Email address')?>" title="<?php echo $this->__('Enter Email address')?>' class="required-entry validate-email">
<button class="submit">+</button>
<input type="hidden" name="source" value="nt">
</form>
</li>
<li class="footer-promo"><?php echo $this->getChildHtml('footer_promo')?></li>
</ul>
<?php elseif (Mage::app()->getStore()->getCode() == "ama_ca"):?>
<ul>
<li><?php echo $this->__('Email Sign Up')?></li>
<li>
<form method="post" action="http://enews.******.com/q/9MNK4U4iV9Mutb9YzTxF2zRWDIPgKoX0F0" accept-charset="UTF-8">
<input type="hidden" name="crvs" value="6hZNXcISD79ac2Empmsr2az_B3Qc5osTNmkOdNHleqhPIYmsxEOe6PbgaUo-3WBn_Vbgorrbk4qjekx7w4tljA">
<input type="hidden" name="CheckBox.Source.ca_footer" value="on">
<input name="email" type="text" id="newsletter" placeholder="Enter Email address" title="Enter Email address' class=" required-entry="">
<input type="hidden" id="submit" value="Sign Up">
</form>
</li>
<li class="footer-promo"><?php echo $this->getChildHtml('footer_promo')?></li>
</ul>
<?php endif;?>
Description
You have done every thing right but you just miss the trick look carefully on your if statement Logic that is if your Code not equals to ama_br that is it can be equal to ama_ca so it will show the form in if statement for ama_ca as well as on any other string from ama_br so the form you are trying to show on Code equals to ama_ca is not showing. Try one of the following it will resolve your query.
Code
<?php if (Mage::app()->getStore()->getCode() == "ama_ca"): ?>
<ul>
<li><?php echo $this->__('Email Sign Up') ?></li>
<li>
<form method="post" action="http://enews.******.com/q/9MNK4U4iV9Mutb9YzTxF2zRWDIPgKoX0F0" accept-charset="UTF-8">
<input type="hidden" name="crvs" value="6hZNXcISD79ac2Empmsr2az_B3Qc5osTNmkOdNHleqhPIYmsxEOe6PbgaUo-3WBn_Vbgorrbk4qjekx7w4tljA">
<input type="hidden" name="CheckBox.Source.ca_footer" value="on">
<input name="email" type="text" id="newsletter" placeholder="Enter Email address" title="Enter Email address' class=" required-entry="">
<input type="hidden" id="submit" value="Sign Up">
</form>
</li>
<li class="footer-promo"><?php echo $this->getChildHtml('footer_promo') ?></li>
</ul>
<?php elseif (Mage::app()->getStore()->getCode() != "ama_br"): ?>
<ul>
<li><?php echo $this->__('Email Sign Up') ?></li>
<li>
<form action="<?php echo $this->getUrl('email_preferences') ?>" method="get" id="newsletter-validate-detail">
<input name="email" type="text" id="newsletter" placeholder="<?php echo $this->__('Enter Email address') ?>" title="<?php echo $this->__('Enter Email address') ?>' class="required-entry validate-email">
<button class="submit">+</button>
<input type="hidden" name="source" value="nt">
</form>
</li>
<li class="footer-promo"><?php echo $this->getChildHtml('footer_promo') ?></li>
</ul>
<?php endif; ?>
OR
<?php if (Mage::app()->getStore()->getCode() != "ama_br" && Mage::app()- >getStore()->getCode() != "ama_ca"): ?>
<ul>
<li><?php echo $this->__('Email Sign Up') ?></li>
<li>
<form action="<?php echo $this->getUrl('email_preferences') ?>" method="get" id="newsletter-validate-detail">
<input name="email" type="text" id="newsletter" placeholder="<?php echo $this->__('Enter Email address') ?>" title="<?php echo $this->__('Enter Email address') ?>' class="required-entry validate-email">
<button class="submit">+</button>
<input type="hidden" name="source" value="nt">
</form>
</li>
<li class="footer-promo"><?php echo $this->getChildHtml('footer_promo') ?></li>
</ul>
<?php elseif (Mage::app()->getStore()->getCode() == "ama_ca"): ?>
<ul>
<li><?php echo $this->__('Email Sign Up') ?></li>
<li>
<form method="post" action="http://enews.******.com/q/9MNK4U4iV9Mutb9YzTxF2zRWDIPgKoX0F0" accept-charset="UTF-8">
<input type="hidden" name="crvs" value="6hZNXcISD79ac2Empmsr2az_B3Qc5osTNmkOdNHleqhPIYmsxEOe6PbgaUo-3WBn_Vbgorrbk4qjekx7w4tljA">
<input type="hidden" name="CheckBox.Source.ca_footer" value="on">
<input name="email" type="text" id="newsletter" placeholder="Enter Email address" title="Enter Email address' class=" required-entry="">
<input type="hidden" id="submit" value="Sign Up">
</form>
</li>
<li class="footer-promo"><?php echo $this->getChildHtml('footer_promo') ?></li>
</ul>
<?php endif; ?>
I'm using the Mingle plugin for Wordpress for users to register, so they can post on a Mingle Forum.
The signup process works, but I want to redirect the user to the forum page once they have submitted their details, rather than just staying on the signup page.
I've tried adding <input type="hidden" name="redirect_to" value="<?php echo bloginfo('url'); ?>" /> to the code so that the page redirects (as it worked on the login form), but doesn't seem to work with signup form.
I've tried using the "action" function in the form details too; this redirects the page, but doesn't submit the data.
The page's code is below - would really appreciate a solution, if possible! Thanks.
<form name="registerform" id="registerform" method="post">
<input type="hidden" id="mngl-process-form" name="mngl-process-form" value="Y" />
<input type="hidden" name="redirect_to" value="http://creativespotlights.com/forum" action="http://creativespotlights.com/forum" />
<p>
<label><?php _e('Username', 'mingle'); ?>*:<br />
<input type="text" name="user_login" id="user_login" class="input mngl_signup_input" value="<?php echo $user_login; ?>" size="20" tabindex="200" /></label>
</p>
<p>
<label><?php _e('E-mail', 'mingle'); ?>*:<br />
<input type="text" name="user_email" id="user_email" class="input mngl_signup_input" value="<?php echo $user_email; ?>" size="25" tabindex="300" /></label>
</p>
<?php if(isset($mngl_options->field_visibilities['signup_page']['name'])) { ?>
<p>
<label><?php _e('First Name', 'mingle'); ?>:<br />
<input type="text" name="user_first_name" id="user_first_name" class="input mngl_signup_input" value="<?php echo $user_first_name; ?>" size="20" tabindex="400" /></label>
</p>
<p>
<label><?php _e('Last Name', 'mingle'); ?>:<br />
<input type="text" name="user_last_name" id="user_last_name" class="input mngl_signup_input" value="<?php echo $user_last_name; ?>" size="20" tabindex="500" /></label>
</p>
<?php } ?>
<?php if(isset($mngl_options->field_visibilities['signup_page']['url'])) { ?>
<p>
<label><?php _e('Website', 'mingle'); ?>:<br />
<input type="text" name="mngl_user_url" id="mngl_user_url" value="<?php echo $mngl_user_url; ?>" class="input mngl_signup_input" size="20" tabindex="600"/></label>
</p>
<?php } ?>
<?php if(isset($mngl_options->field_visibilities['signup_page']['location'])) { ?>
<p>
<label><?php _e('Location', 'mingle'); ?>:<br />
<input type="text" name="mngl_user_location" id="mngl_user_location" value="<?php echo $mngl_user_location; ?>" class="input mngl_signup_input" size="20" tabindex="700" /></label>
</p>
<?php } ?>
<?php if(isset($mngl_options->field_visibilities['signup_page']['bio'])) { ?>
<p>
<label><?php _e('Bio', 'mingle'); ?>:<br />
<textarea name="mngl_user_bio" id="mngl_user_bio" class="input mngl-growable mngl_signup_input" tabindex="800"><?php echo wptexturize($mngl_user_bio); ?></textarea></label>
</p>
<?php } ?>
<?php if(isset($mngl_options->field_visibilities['signup_page']['sex'])) { ?>
<p>
<label><?php _e('Gender', 'mingle'); ?>*: <?php echo MnglProfileHelper::sex_dropdown('mngl_user_sex', $mngl_user_sex, '', 900); ?></label>
</p>
<?php } ?>
<?php if(isset($mngl_options->field_visibilities['signup_page']['password'])) { ?>
<p>
<label><?php _e('Password', 'mingle'); ?>:<br/>
<input type="password" name="mngl_user_password" id="mngl_user_password" class="input mngl_signup_input" tabindex="1000"/></label>
</p>
<p>
<label><?php _e('Password Confirmation', 'mingle'); ?>:<br />
<input type="password" name="mngl_user_password_confirm" id="mngl_user_password_confirm" class="input mngl_signup_input" tabindex="1100"/></label>
</p>
<?php } else { ?>
<p id="reg_passmail"><?php _e('A password will be e-mailed to you.', 'mingle'); ?></p>
<?php } ?>
<?php if($mngl_options->signup_captcha) { ?>
<?php
$captcha_code = MnglUtils::str_encrypt(MnglUtils::generate_random_code(6));
?>
<p>
<label><?php _e('Enter Captcha Text', 'mingle'); ?>*:<br />
<img src="<?php echo MNGL_SCRIPT_URL; ?>&controller=captcha&action=display&width=120&height=40&code=<?php echo $captcha_code; ?>" /><br/>
<input id="security_code" name="security_code" style="width:120px" type="text" tabindex="1200" />
<input type="hidden" name="security_check" value="<?php echo $captcha_code; ?>">
</p>
<?php } ?>
<?php do_action('mngl-user-signup-fields'); ?>
<br class="clear" />
<p class="submit"><input type="submit" name="wp-submit" id="wp-submit" class="mngl-share-button" value="<?php _e('Sign Up', 'mingle'); ?>" tabindex="60" />
</p>
</form>
Try this
<?php
if (isset($_POST['wp-submit']))
{
header('Location: http://site/result.php');
}
?>
in the top of your code
OR you can try to do it by javascript with onsubmit="window.location.href='result.php';"
You can use :
header('Location: http://yoursite.com/location.php');
But you have to get a clean output (no html before the header).
Doc here.
Something like this should work:
if (isset($_POST['user_login']))
{
(your redirect code here)
}
After a form has been successfully submitted you should perform a 303 redirect to the same page. Doing this will prevent resubmitting the form if the user happens to press F5 or some other form or reloading the page.
wp_redirect("/path/to/my/script", 303);
You will need to substitute /path/to/my/script with the URL where your form lives.
Hi there. Can anyone please tell me how to arrange the list of checkboxes of cuisines label which is retrieved from the data base and when it is displaying it is not in the order coming side by side all together I want it to be displayed in a 3 by 3 format. Here is the code for that:
<div id="frmform">
<form name="frmrestaurant" id="frmrestaurant" method="post" onsubmit="" enctype="multipart/form-data">
<p class="msgsignup">Add Restaurant</p>
<div id="iderror"></div>
<div class="topinputs">
<div> <label for="restaurant_name" class="name">Restaurant Name :</label><input type="text" name="restaurant_name" size="32" id="restaurant_name" value="<?php echo $row->restaurant_name; ?>" class="validate[required,custom[onlyLetter],length[0,100]] text-input" /> </div>
</div>
<div> <label for="website" class="name">Website :</label><input size="32" type="text" name="website" id="website" value="<?php echo $row->website; ?>" class="validate[required,length[0,100]] text-input" /> </div>
<div> <label for="budget" class="name">Budget :</label>
<?php echo $this->lists['budget'];?>
</div>
<div> <label for="idcuisine" class="cuisine" >Cuisine:</label>
<?php echo $this->lists['cuisine'] ;?>
<div> <label for="idcategory" class="category">Category:</label>
<?php echo $this->lists['category'];?>
</div>
The lists of cuisine and category is not displaying properly.
Thanks.
It could be done with php right logic
<tr>
<?php
while($ofetch=$db->fetchNextObject($query))
{
$j++;
?>
<td width="33%">
<input type="checkbox" name="service[]" id="service" value="<?php echo $ofetch->service_id?>" /> some text
</td>
<?php if($j%3==0) { echo "</tr><tr>";}
}
?>
</tr>