Can't use varien - magento

In the template register.phtml I added an input type radio for some terms and condition agreements.
This one is required.
I didn't success to use the javascript Magento’s frontend validation. I add all sort of classes but nothing worked.
Is Someone knows how to do please ? thanks
Here the html
<div class="field radiobox">
<div class="input-box">
<input type="radio" name="accept" title="<?php echo $this->__('I Agree to our Terms & Conditions') ?>" id="accept" class="radio required-entry validate-one-required-by-name validation-passed validation-failed" >
<label for="accept" class=required" ><?php echo $this->__('I Agree to our Terms & Conditions') ?></label>
</div>
</div>
<script type="text/javascript">
//<![CDATA[
new Varien.FileElement('accept');
//]]>
</script>

First of all remove all class other then required-entry
<input type="radio" name="accept" title="<?php echo $this->__('I Agree to our Terms & Conditions') ?>" id="accept" class="radio required-entry" >
And put this in your form tag, you don't need to create any javascript for this just ensure that it is under form tag, in register.phtml file magento already define validation javascript so don't put your javascript again.

#Mufaddal
<div class="account-form-wrapper registerpass">
<form action="<?php echo $this->getPostActionUrl() ?>" method="post" id="form-validate" enctype="multipart/form-data" class="ctools-use-modal-processed" novalidate="novalidate">
<div class="fieldset">
<input type="hidden" name="success_url" value="<?php echo $this->getSuccessUrl() ?>" />
<input type="hidden" name="error_url" value="<?php echo $this->getErrorUrl() ?>" />
</div>
<?php echo $this->getLayout()->createBlock('customer/widget_name')->setObject($this->getFormData())->setForceUseCustomerAttributes(true)->toHtml() ?>
<div class="field">
<label for="email_address" class="required"><em>*</em>Email Address</label>
<div class="input-box">
<input type="text" name="email" id="email_address" value="<?php echo $this->escapeHtml($this->getFormData()->getEmail()) ?>" title="<?php echo $this->__('Email Address') ?>" class="input-text validate-email required-entry" placeholder="<?php echo $this->__("Email Address") ?>" />
</div>
</div>
<div class="fields">
<div class="field">
<label for="password" class="required"><em>*</em><?php echo $this->__('Password') ?></label>
<div class="input-box">
<input type="password" name="password" id="password" title="<?php echo $this->__('Password') ?>" class="input-text required-entry validate-password" placeholder="Password" />
</div>
</div>
<div class="field">
<label for="confirmation" class="required"><em>*</em><?php echo $this->__('Confirm Password') ?></label>
<div class="input-box">
<input type="password" name="confirmation" title="<?php echo $this->__('Confirm Password') ?>" id="confirmation" class="input-text required-entry validate-cpassword" placeholder="Confirm Password" />
</div>
</div>
</div>
<div class="field radiobox">
<div class="input-box">
<input type="radio" name="accept" title="<?php echo $this->__('I Agree to our Terms & Conditions') ?>" id="accept" class="radio required-entry" >
<label for="accept" class=required" ><?php echo $this->__('I Agree to our Terms & Conditions') ?></label>
</div>
</div>
__('Submit') ?>" id="form-submit">
__('maak mijn profiel aan') ?>
</form>

Related

Custom contact form gives me 404 error

I've created a custom contact form for each magento product, I've set up all the files and inserted this code inside a Magento static block:
{{block type="core/template" form_action="/PersonalizzazioniEmail/index/post/" template="catalog/product/view/form-personalizzazione.phtml"}}
Here's the form-personalizzazione.phtml
<?php $productId=$this->getRequest()->getParams();
$model = Mage::getModel('catalog/product');
$_product = $model->load($productId["id"]);
?>
<div id="messages_product_view"><?php echo $this->getMessagesBlock()->toHtml() ?></div>
<div class="page-title">
<h1><?php echo Mage::helper('contacts')->__('Contact Us') ?></h1>
</div>
<form action="<?php echo $this->getFormAction(); ?>" id="contactForm" method="post">
<input type="hidden" id="product" name="product" value="<?php echo $_product->getName() ?>" />
<div class="fieldset">
<h2 class="legend"><?php echo Mage::helper('contacts')->__('Contact Information') ?></h2>
<ul class="form-list">
<li class="fields">
<div class="field">
<label for="name" class="required"><em>*</em><?php echo Mage::helper('contacts')->__('Name') ?></label>
<div class="input-box">
<input name="name" id="name" title="<?php echo Mage::helper('core')->quoteEscape(Mage::helper('contacts')->__('Name')) ?>" value="<?php echo $this->escapeHtml($this->helper('contacts')->getUserName()) ?>" class="input-text required-entry" type="text" />
</div>
</div>
<div class="field">
<label for="email" class="required"><em>*</em><?php echo Mage::helper('contacts')->__('Email') ?></label>
<div class="input-box">
<input name="email" id="email" title="<?php echo Mage::helper('core')->quoteEscape(Mage::helper('contacts')->__('Email')) ?>" value="<?php echo $this->escapeHtml($this->helper('contacts')->getUserEmail()) ?>" class="input-text required-entry validate-email" type="text" />
</div>
</div>
</li>
<li>
<label for="telephone"><?php echo Mage::helper('contacts')->__('Telephone') ?></label>
<div class="input-box">
<input name="telephone" id="telephone" title="<?php echo Mage::helper('core')->quoteEscape(Mage::helper('contacts')->__('Telephone')) ?>" value="" class="input-text" type="text" />
</div>
</li>
<li class="wide">
<label for="comment" class="required"><em>*</em><?php echo Mage::helper('contacts')->__('Comment') ?></label>
<div class="input-box">
<textarea name="comment" id="comment" title="<?php echo Mage::helper('core')->quoteEscape(Mage::helper('contacts')->__('Comment')) ?>" class="required-entry input-text" cols="5" rows="3"></textarea>
</div>
</li>
</ul>
</div>
<div class="fieldset privacy">
<ul class="form-list">
<?php if (Mage::helper('privacy')->isPrivacyEnabled()): ?>
<li>
<?php echo $this->getChildHtml('privacy.include.contacts'); ?>
</li>
<?php endif;?>
</ul>
</div>
<div class="buttons-set">
<p class="required"><?php echo Mage::helper('contacts')->__('* Required Fields') ?></p>
<input type="text" name="hideit" id="hideit" value="" style="display:none !important;" />
<button type="submit" title="<?php echo Mage::helper('core')->quoteEscape(Mage::helper('contacts')->__('Submit')) ?>" class="button"><span><span><?php echo Mage::helper('contacts')->__('Submit') ?></span></span></button>
</div>
</form>
<script type="text/javascript">
//<![CDATA[
var contactForm = new VarienForm('contactForm', true);
//]]>
</script>
But I get a 404 error when I submit the form, what could be the reason?
Thanks
Create a Custom Contact Form in Magento,Kindly visit below URLs.
http://inchoo.net/magento/magento-email/magento-custom-email-contact-form-with-notification-system/
http://ignaciogondra.com/2015/08/24/how-to-create-a-custom-contact-form-in-magento/
If you don't want to use custom code,You can use this paid extension.
https://www.magentocommerce.com/magento-connect/custom-contact-forms.html
You can also use this Product Question,It's might be fulfilled your requirement. This is free extension.
https://www.magentocommerce.com/magento-connect/product-question-1.html
Hope It's helpful for you.

password set during checkout issue

I have an issue with customer registered through checkout.
After the checkout process, the customer lands in “My Account” but once logged off, he can’t acces "My Account" anymore, the message "Invalid login or password" is displayed.
Setting a new password through “Forgotten Password” button seems to solve the problem for the customer. (But it would be great if the password could work directly without passing through this step.)
I think (but am not sure at all) that the password set through billing.phtml is not stored correctly.
The customers registered through "Register" button are saved correctly and don't encounter any issue.
I have in template/persistent/Customer/form/register.phtml:
<li class="fields">
<div class="field">
<label for="password" class="required"><em>*</em><?php echo $this->__('Password') ?></label>
<div class="input-box">
<input type="password" name="password" id="password" title="<?php echo $this->quoteEscape($this->__('Password')) ?>" class="input-text required-entry validate-password" />
</div>
</div>
<div class="field">
<label for="confirmation" class="required"><em>*</em><?php echo $this->__('Confirm Password') ?></label>
<div class="input-box">
<input type="password" name="confirmation" title="<?php echo $this->quoteEscape($this->__('Confirm Password')) ?>" id="confirmation" class="input-text required-entry validate-cpassword" />
</div>
</div>
</li>
In template/Customer/form/resetforgottenpassword.phtml:
<li class="fields">
<div class="field">
<label for="password" class="required"><em>*</em><?php echo $this->__('New Password'); ?></label>
<div class="input-box">
<input type="password" class="input-text required-entry validate-password" name="password" id="password" />
</div>
</div>
<div class="field">
<label for="confirmation" class="required"><em>*</em><?php echo $this->__('Confirm New Password'); ?></label>
<div class="input-box">
<input type="password" class="input-text required-entry validate-cpassword" name="confirmation" id="confirmation" />
</div>
</div>
</li>
And in template/persistent/checkout/onepage/billing.phtml, which I think is the culprit:
<li class="fields" id="register-customer-password">
<div class="field">
<label for="billing:customer_password" class="required"><em>*</em><?php echo $this->__('Password') ?></label>
<div class="input-box">
<input type="password" name="billing[customer_password]" id="billing:customer_password" title="<?php echo $this->quoteEscape($this->__('Password')) ?>" class="input-text required-entry validate-password" />
</div>
</div>
<div class="field">
<label for="billing:confirm_password" class="required"><em>*</em><?php echo $this->__('Confirm Password') ?></label>
<div class="input-box">
<input type="password" name="billing[confirm_password]" title="<?php echo $this->quoteEscape($this->__('Confirm Password')) ?>" id="billing:confirm_password" class="input-text required-entry validate-cpassword" />
</div>
</div>
</li>
I tried several modifications to billing.phtml, such as:
<label for="password" class="required"><em>*</em><?php echo $this->__('Password') ?></label>
<input type="password" name="password" id="password" title="<?php echo $this->quoteEscape($this->__('Password')) ?>" class="input-text required-entry validate-password" />
<input type="password" name="password" title="<?php echo $this->quoteEscape($this->__('Confirm Password')) ?>" id="confirmation" class="input-text required-entry validate-cpassword" />
But I’m still leading to the same result.
I’m on a CE 1.9.3.1 patched with SUPEE 9652.
How to make Customer registered during checkout being saved correctly?
I have 4 errors concerning lib/Varien/Crypt/Mcrypt.php
Warning: mcrypt_generic_init(): Key size is 0 in /lib/Varien/Crypt/Mcrypt.php on line 94
Warning: mcrypt_generic_init(): Key length incorrect in /lib/Varien/Crypt/Mcrypt.php on line 94
Warning: mcrypt_generic_deinit(): 495 is not a valid MCrypt resource in /lib/Varien/Crypt/Mcrypt.php on line 135
Warning: mcrypt_module_close(): 495 is not a valid MCrypt resource in /lib/Varien/Crypt/Mcrypt.php on line 136
I thought it was relative to a module is missing in PHP Mcrypt on my server (https://magento.stackexchange.com/a/35888). But it's not the case as by installing a fresh CE 1.9.3.1 in a folder in the root of the same Magento installation is doing its job properly with the same server configuration and Mcrypt.php. Moreover, the password set during registration with form (?and using the same encryption?), is set properly.
I'll open a new post with more precisions.
#urfusion, thank you for advice, I was looking at the wrong end of system.log (thought it was writing on the top...)
Edit
I got it, the solution's here:
https://stackoverflow.com/a/42474835/7553582

Codeigniter Validation errors work on localhost not on server

I have problem same code running on local and on server, but i dont get validation errors when i upload code online. I pass validatio errors via flashdata
Controller
function send_mail($lang)
{
$this->load->library(array('email','form_validation'));
$this->form_validation->set_rules('fullname', 'Full Name','trim|required|xss_clean');
$this->form_validation->set_rules('address', 'Permanent Home Address', 'trim|required|xss_clean');
$this->form_validation->set_rules('posta', 'Email Address', 'required|valid_email|xss_clean');
$this->form_validation->set_rules('country', 'Country of Citizenship', 'trim|required|xss_clean');
$this->form_validation->set_rules('date', 'Date of Birth','trim|required|xss_clean');
$this->form_validation->set_rules('tel', 'Telephone Number','trim|required|xss_clean');
$this->form_validation->set_rules('inst', 'Name of Institution','trim|required|xss_clean');
$this->form_validation->set_rules('study', 'Field of Study', 'trim|required|xss_clean');
$this->form_validation->set_rules('degree', 'Degree awarded/expected','trim|required|xss_clean');
$this->form_validation->set_rules('dates1', 'Dates attended', 'trim|required|xss_clean');
$this->form_validation->set_rules('dates2', 'Dates attended', 'trim|required|xss_clean');
$this->form_validation->set_rules('employment', 'Employment', 'trim|required|xss_clean');
$this->form_validation->set_rules('language', 'Language Skills', 'trim|required|xss_clean');
$this->form_validation->set_rules('statement', 'Statement', 'trim|required|xss_clean');
if($this->form_validation->run()==FALSE)
{
$this->session->set_flashdata('errors', validation_errors());
$this->set_fleshdata();
header('Location: '.$_SERVER['HTTP_REFERER']);
}
else
in view
<?php
$this->load->helper(array('form', 'url'));
$this->load->library('form_validation');
$attributes = array('id' => 'intership_application_form',
'name' => 'intership',
);
echo $this->session->flashdata('success');
echo form_open_multipart('pages/send_mail/'.$lang, $attributes);
?>
<section>
<div > All fields required, only files in doc, docx or pdf format are allowed.</div><br/>
<div class="form_item">
<label class="form_item_name">Full Name:</label>
<input type="text" name="fullname" placeholder="Full Name" value="<?php echo $this->session->flashdata('name'); ?>" >
</div><!--end .form_item-->
<div class="form_item">
<label class="form_item_name">Permanent Home Address:</label>
<input type="text" name="address" placeholder="Permanent Home Address" value="<?php echo $this->session->flashdata('address'); ?>"/>
</div><!--end .form_item-->
<div class="form_item">
<label class="form_item_name">Email Address:</label>
<input type="email" name="posta" placeholder="Email Address" value="<?php echo $this->session->flashdata('posta'); ?>"/>
</div><!--end .form_item-->
<div class="form_item">
<label class="form_item_name">Country of Citizenship:</label>
<input type="text" name="country" placeholder="Country of Citizenship" value="<?php echo $this->session->flashdata('country'); ?>" />
</div><!--end .form_item-->
<div class="form_item">
<label class="form_item_name">Date of Birth:</label>
<input type="text" name="date" placeholder="Date of Birth" value="<?php echo $this->session->flashdata('date'); ?>" />
</div><!--end .form_item-->
<div class="form_item">
<label class="form_item_name">Telephone Number:</label>
<input type="text" name="tel" placeholder="Telephone Number" value="<?php echo $this->session->flashdata('tel'); ?>"/>
</div><!--end .form_item-->
</section>
<section>
<p><strong>University Level Education</strong> <span>[ Please give details of your final school leaving qualification ]</span></p>
<div class="form_item">
<label class="form_item_name">Name of Institution:</label>
<input type="text" name="inst" placeholder="Name of Institution" value="<?php echo $this->session->flashdata('inst') ?>"/>
</div><!--end .form_item-->
<div class="form_item">
<label class="form_item_name">Field of Study:</label>
<input type="text" name="study" placeholder="Field of Study" value="<?php echo $this->session->flashdata('study'); ?>"/>
</div><!--end .form_item-->
<div class="form_item">
<label class="form_item_name">Degree awarded/expected:</label>
<input type="text" name="degree" placeholder="Degree awarded/expected" value="<?php echo $this->session->flashdata('degree'); ?>"/>
</div><!--end .form_item-->
<div class="form_item">
<label class="form_item_name">Dates attended:</label>
<input type="text" name="dates1" placeholder="Dates attended" value="<?php echo $this->session->flashdata('dates1'); ?>" />
<input class="below" type="text" name="dates2" placeholder="Dates attended" value="<?php echo $this->session->flashdata('dates2'); ?>"/>
</div><!--end .form_item-->
</section>
<section class="third">
<div class="form_item">
<label class="form_item_name" />Employment<span>[ Please outline details of employment history or relevant professional experience ]</span></label>
<textarea cols="" rows="" name="employment" placeholder="Your text here" ><?php echo $this->session->flashdata('employment'); ?></textarea>
</div>
<div class="form_item">
<label class="form_item_name" />Language SKills:<span>[ Proficiency in English is required for all CIRSD internship applicants, who are encouraged to indicate knowledge of any additional languages ]</span></label>
<textarea cols="" rows="" name="language" placeholder="Your text here" ><?php echo $this->session->flashdata('language'); ?></textarea>
</div>
</section>
<section class="third">
<div class="form_item">
<label class="form_item_name">References:<span>[Please include three academic/professional references or letters of recommendation ]</span></label>
<div class="right">
<p>Please attach your reference here:</p>
<div class="upload_buttons">
<p class="form">
<input type="text" id="path" class="path" />
<label class="add-photo-btn">BROWSE<span><input type="file" id="myfile" name='file1' /></span>
</label>
</p>
<p class="form">
<input type="text" id="path1" class="path" />
<label class="add-photo-btn">BROWSE<span><input type="file" id="myfile1" name='file2' /></span>
</label>
</p>
<p class="form">
<input type="text" id="path2" class="path" />
<label class="add-photo-btn">BROWSE<span><input type="file" id="myfile2" name='file3' /></span>
</label>
</p>
</div><!--end .upload_buttons-->
</div><!--end .form_item-->
</section><!--end .third-->
<section class="third">
<div class="form_item">
<label class="form_item_name" />Personal Statement:<span>[ Compose a brief personal statement in English outlining your interests, why you are applying for the CIRSD internship program, and what you hope to gain from it. Include an explanation of what makes you a suitable candidate for an internship at CIRSD. All statements should not exceed the limit of 750 words ]</span></label>
<textarea name="statement" cols="" rows="" class="personal_statement" placeholder="Your text here"><?php echo $this->session->flashdata('statement'); ?></textarea>
</div>
<div class="form_item cv">
<label class="form_item_name" />Cirriculum Vitae:</label>
<div class="right cv">
<p class="form">
<input type="text" id="path3" class="path cv" value="Please attach your CV here:" />
<label class="add-photo-btn">BROWSE<span><input type="file" id="myfile3" name='file4' multiple /></span>
</label>
</p>
</div>
</div>
</section><!--end .third-->
<section class="third">
<div class="form_item spam">
<label>Spam Check:</label>
<div class="spam_form">
<img src="<?php echo site_url(); ?>captcha_code_file.php?rand=<?php echo rand(); ?>" name="6_letters_code" id='captchaimg' >
<input type="text" class="spam_input" name="6_letters_code"/>
<input type="submit" class="send_btn" value="SEND" id="button"/>
</div>
</div><!--end .form_item-->
</section><!--end .third-->
<?php form_close(); ?>
<div><?php var_dump($this->session->flashdata('errors'));?></div>
Last line is important. Strange why my code works on xampp not on live server?
Please check your code you are setting 'errors' variable for setting errors messages and on view part you are accessing 'success' variable. Please use same variable at both places.
Controller:
$this->session->set_flashdata('errors', validation_errors());
View:
echo $this->session->flashdata('success');
And what is use of this function in controller $this->set_fleshdata(); the above method (set_flashdata) is enough to set your flashdata.
Also in the last line you forgot to write 'echo' before the form
<?php form_close(); ?> should be <?php echo form_close(); ?>

how to add new fieds and use existing address fields in magento custom regstration form

hi i am new to magento.. i need some help..
i am able to add address fields in form in my view(phtml file) but that fields data is not being
saved . how could i be able to save those fields?
code for address field in phtml file
<div class="form-group margin_top">
<label for="street_1" class="required col-md-4 control-label"><?php echo $this->__('Adresse') ?><em>* :</em></label>
<div class="col-md-6">
<div class="row">
<div class="col-md-3 nopaddingright">
<?php $_streetValidationClass = $this->helper('customer/address')->getAttributeValidationClass('street'); ?>
<input type="text" name="street[]" value="<?php echo $this->escapeHtml($this->getFormData()->getStreet(1)) ?>" title="<?php echo $this->__('Street Address') ?>" id="street_1" class="input-text form-control <?php echo $_streetValidationClass ?>" />
</div>
<div class="col-md-9 address_block">
<?php $_streetValidationClass = trim(str_replace('required-entry', '', $_streetValidationClass)); ?>
<?php for ($_i = 2, $_n = $this->helper('customer/address')->getStreetLines(); $_i <= $_n; $_i++): ?>
<input type="text" name="street[]" value="<?php echo $this->escapeHtml($this->getFormData()->getStreet($_i)) ?>" title="<?php echo $this->__('Street Address %s', $_i) ?>" id="street_<?php echo $_i ?>" class="form-control input-text <?php echo $_streetValidationClass ?>" />
<?php endfor; ?>
</div>
<div class="col-md-9 nopaddingright">
<input type="text" name="city" value="<?php echo $this->escapeHtml($this->getFormData()->getCity()) ?>" title="<?php echo $this->__('City') ?>" class="form-control input-text <?php echo $this->helper('customer/address')->getAttributeValidationClass('city') ?>" id="city" />
</div>
<div class="col-md-3 address_block">
<input type="text" name="postcode" value="<?php echo $this->escapeHtml($this->getFormData()->getPostcode()) ?>" title="<?php echo $this->__('Zip/Postal Code') ?>" id="zip" class="input-text form-control validate-zip-international <?php echo $this->helper('customer/address')->getAttributeValidationClass('postcode') ?>" />
</div>
<div class="col-md-12">
<input type="text" id="region" name="region" value="<?php echo $this->escapeHtml($this->getRegion()) ?>" title="<?php echo $this->__('State/Province') ?>" class="input-text form-control <?php echo $this->helper('customer/address')->getAttributeValidationClass('region') ?>" />
</div>
</div>
</div>
2 . i also need mobile(cell) field to be added into my form how can i add that and save into my
database.
do i need to create Custom module ? please suggest me and help me
Thank you

How to remove ‘password cannot be empty’ msg on the registration form

In my app(Magento v1.7), I don’t want user to input their password when registration. So I comment out the following code on page app\design\frontend\base\default\template\persistent\customer\form\register.phtml
<ul class="form-list">
<li class="fields">
<div class="field">
<label for="password" class="required"><em>*</em><?php echo $this->__('Password') ?></label>
<div class="input-box">
<input type="password" name="password" id="password" title="<?php echo $this->__('Password') ?>" class="input-text required-entry validate-password" />
</div>
</div>
<div class="field">
<label for="confirmation" class="required"><em>*</em><?php echo $this->__('Confirm Password') ?></label>
<div class="input-box">
<input type="password" name="confirmation" title="<?php echo $this->__('Confirm Password') ?>" id="confirmation" class="input-text required-entry validate-cpassword" />
</div>
</div>
</li>
<?php echo $this->getChildHtml('persistent.remember.me'); ?>
</ul>
But the warning message ‘The password cannot be empty.’ is still displayed when registration. How to remove this warning msg?
Many thanks
The password is validated at Mage_Customer_Model_Customer::validate() so you either override this function or make a hidden field name="password" and input some dummy info there you can later override with your generated passwords whatsoever. However this might be a security hole if you don't overwrite the password right away.
Remove the class "required-entry" from the password field.

Resources