Submit form in Magento only if already logged in - forms

I would like to create a form in Magento with some extension. At the bottom of the form , when the user pushes the submit button, if he is not registered and logged in yet, it should redirect him to the "Create New Account" page. But if he is already logged in, he should be able to submit the form and the form should automatically include some details of his account (e.g. username, name, etc). How could I achieve this and which extension should I use for the form?

Please check below form action
<?php $custmlogin= new Mage_Customer_Block_Form_Login();?>
<form action="<?php echo $custmlogin->getPostActionUrl() ?>" method="post" id="login-form">
Email:<input type="text" name="login[username]" value="<?php echo $this->htmlEscape($this->getUsername()) ?>" title="<?php echo $this->__('Email Address') ?>" />
Password:<input type="password" name="login[password]" id="pass" title="<?php echo $this->__('Password') ?>" />
<button type="submit" class="button" title="<?php echo $this->__('Login') ?>" name="send" id="send2"><span><span><?php echo $this->__('Login') ?></span></span></button>
</form>

Related

Combination: Open mailto and form submit

This combination of an open mailto window with a post form to test.php on one click does not work. Any suggestions?
<form id="myForm" action="test.php" method="post">
<input type="hidden" name="someName" value="helloworld" />
<a href="mailto:..."
onclick="document.getElementById('myForm').submit();">
Submit
</a>
</form>
Check below solution to ignore href attribute and focus on using onclick only to do what you need
function submit() {
window.open('mailto:mail#example.org', '_blank');
document.getElementById('myForm').submit();
return true;
}
<form id="myForm" action="test.php" method="post">
<input type="hidden" name="someName" value="helloworld" />
<a href="#" onclick="return submit();">
Submit
</a>
</form>
And if you need to use both href and onclick check below alternative solution
function submit() {
document.getElementById('myForm').submit();
return true;
}
<form id="myForm" action="test.php" method="post" onsubmit="alert('Ok')">
<input type="hidden" name="someName" value="helloworld" />
<a href="mailto:mail#example.org" target="_blank" onclick="return submit();">
Submit
</a>
</form>
#Wael: Thanks. The second solution is equivalent to this.
<form id="myForm2" action="test.php" method="post">
<input type="hidden" name="someName" value="helloworld" />
Submit 2
</form>
The missing target attribute was the issue.
In Firefox it works as required. In Chrome it leads to
1. Opens the mail client
2. Posts to test.php
3. Opens a new browser tab with url mailto:mail#example.org (and focus)
With your first solution it is the same. How to avoid 3.?

When submit I want to receive the message on my mail (duplicate)

Here's my code for my new website
<div class="single_contant_left">
<form action="#" id="formid">
<!--<div class="col-lg-8 col-md-8 col-sm-10 col-lg-offset-2 col-md-offset-2 col-sm-offset-1">-->
<div class="form-group">
<input type="text" class="form-control" name="name" placeholder="first name" required="">
</div>
<div class="form-group">
<input type="email" class="form-control" name="email" placeholder="Email" required="">
</div>
<div class="form-group">
<input type="text" class="form-control" name="subject" placeholder="Subject" required="">
</div>
<div class="form-group">
<textarea class="form-control" name="message" rows="8" placeholder="Message"></textarea>
</div>
<div class="">
<input type="submit" value="Submit" class="btn btn-primary">
and when I want someone who clikck on submit, i want to receive the message on my personal mail.
Any idea ?
Thanks
First you will need to make sure you know where you want to send the email from. Which computer should send the email? The server where you submit the form, or the client computer on which the web browser of the user is running?
If you want the server to send the email, you will need to write server-side code which will handle the form submit when the user clicks on the submit button. Inside that server-side code, you might use your own SMTP, or you can use a server-side mailer API, there are tons of possibilities and we are not aware of what server-side technology you are using, if any.
Of course you can send the emails from the browser as well, using a client-side mailer API.

how to hide fax field for guest user magento

magento, At checkout page i want to hide fax field in billing address if user checkout as guest.I tried this code
if ($('login:guest') && $('login:guest').checked) {}
but it not worked.
Please give me code for this.
And i want to hide fax field in backend(customer->address).but i could not find file. Please navigate me file.
Thanks
Add the following code in your template file of shipping .
<?php $customer = Mage::getSingleton('customer/session')->getCustomer();?>
<?if($customer):?>
<div class="field">
<label for="shipping:fax"><?php echo $this->__('Fax') ?></label>
<div class="input-box">
<input type="tel" name="shipping[fax]" value="<?php echo $this->escapeHtml($this->getAddress()->getFax()) ?>" title="<?php echo $this->__('Fax') ?>" class="input-text <?php echo $this->helper('customer/address')->getAttributeValidationClass('fax') ?>" id="shipping:fax" onchange="shipping.setSameAsBilling(false);" />
</div>
</div>
<?php endif;?>

How to submit form data with Zurb Foundation

I'm a beginner trying to set up my first form with Zurb Foundation, and I'm not able to find in the documentation the info on how to actually pass the data. It's just a basic contact form with name/email/message that I'd like sent to my email once people click the Submit button... and I don't know how to do that.
I apologize for the simple question, your help is greatly appreciated.
Zurb foundation is front end frame work for website design and development , if you want to submit the form or do server communications, please read some basics,
HTML form and input : http://www.w3schools.com/html/html_forms.asp
Submitting HTML form using Jquery AJAX :
Submitting HTML form using Jquery AJAX
AJAX - Send a Request To a Server : http://www.w3schools.com/ajax/ajax_xmlhttprequest_send.asp
The HTML part:
<form action="form_contact_process.php" method="POST" name="contact" id="contact">
<fieldset>
<legend>Contact form</legend>
<div class="row collapse">
<label for="name">Name</label>
<input type="text" name="name" id="name">
</div>
<div class="row collapse">
<label for="email">Email</label>
<input type="text" name="email" id="email">
</div>
<div class="row collapse">
<label for="phone">Phone</label>
<input type="text" name="phone" id="phone">
</div>
<div class="row collapse">
<label for="message">Message</label>
<textarea name="message" id="message" rows="5"></textarea>
</div>
<div class="row collapse">
<input class="button small large-12" type="submit" value="Submit">
</div>
</fieldset>
</form>
Then over at form_contact_process.php:
<?php
$name = $_POST['name'];
...
echo $name;

SEO Url not changing upon form submission

Am using SEO URls to load my pages ie http://www.mywebsite.com/p/page1/100 but am having a problem with my search form. When I click submit, instead of the entire url changing to the stated one in the form, it just appends the variables to the url eg http://www.mywebsite.com/p/page1/100?p=search&q=Any+Query+String+here.
My question is, how do I replace the entire URL with the form variable instead?
Here is my form code:
<form action="<?php $_SERVER['PHP_SELF'] ?>" method="get">
<input type="text" onfocus="if(this.value==this.defaultValue) this.value='';" onblur="if(this.value=='') this.value=this.defaultValue;" name="q" value="Search" />
<input type="hidden" value="search" name="p" />
<input type="submit" value="Search" class="submit" />
</form>
OK I solved it using a hack I think???
Apparently if I append a variable to the action url, this will force the browser to load the new url instead of append the form variable to the existing url.
Eg.
<form action="<?php $_SERVER['PHP_SELF'] ?>?p=search" method="get">
<input type="text" onfocus="if(this.value==this.defaultValue) this.value='';" onblur="if(this.value=='') this.value=this.defaultValue;" name="q" value="Search" />
<input type="hidden" value="search" name="p" />
<input type="submit" value="Search" class="submit" />
</form>
This worked for me but I dunno if it's the right way to achieve this or it's a hack.