Form not submitting on text click - php

This isthe form which i am submitting it through on click on text, but the values are not passing on the action page.
<form action="forget_pass.php" method="post" id="new_user" name="new_user">
<ul class="inputlist">
<li><span class="redcolor">*</span>Email Address or Phone No.</li>
<li>
<input name="" class="inputbox" type="text" name="EmailAddress" id="txtEmail" />
</li>
<li class="rightalign">
<a href="javascript:document.new_user.submit();" onclick="">
Retrieve Password</a></li>
</form>

<input name="" class="inputbox" type="text" name="EmailAddress" id="txtEmail" />
Should be
<input class="inputbox" type="text" name="EmailAddress" id="txtEmail" />
-
<a href="javascript:document.new_user.submit();" onclick="">
should be better to be
<a href="#" onclick="document.new_user.submit();return false;">

here is the working code you can use
<form action="forget_pass.php" method="post" id="new_user" name="new_user">
<ul class="inputlist">
<li><span class="redcolor">*</span>Email Address or Phone No.</li>
<li>
<input class="inputbox" type="text" name="EmailAddress" id="txtEmail" />
</li>
<li class="rightalign">
<a href="javascript:document.new_user.submit();">
Retrieve Password</a></li>
</form>
Problems in your code are
1- you have two name attributes. one is empty
2- onclick not used properly...
Hope it helps

You should try this code,
<form action="forget_pass.php" method="post" id="new_user" name="new_user">
<ul class="inputlist">
<li><span class="redcolor">*</span>Email Address or Phone No.</li>
<li>
<input class="inputbox" type="text" name="emailAddress" id="txtEmail" >
</li>
<li class="rightalign">
<a href="javascript:submitForm();">
Retrieve Password</a></li>
</ul>
</form>
And the javaScript code is,
submitForm = function(){
alert(document.forms[0].emailAddress.value);
document.forms[0].submit();
}
And the running code is this http://jsfiddle.net/4AWW6/

Related

Functioning form on a cargo site?

I'm trying to create a form on a Cargo site, but they don't allow anywhere for .php files. I want the form to send an email to me upon the "submit" button being clicked. "mailto:" doesn't work, by the way.
Here's the form right now. I've tried adding an action to the form, but obviously I can't link a .php file:
<form>
<ul class="form-style-1">
<li><label>Full Name <span class="required">*</span></label><input type="text" name="field1" class="field-divided" placeholder="First"> <input type="text" name="field2" class="field-divided" placeholder="Last"></li>
<li>
<label>Email <span class="required">*</span></label>
<input type="email" name="field3" class="field-long">
</li>
<li>
<label>Subject</label>
<select name="field4" class="field-select">
<option value="Advertise">Advertise</option>
<option value="Partnership">Partnership</option>
<option value="General Question">General</option>
</select>
</li>
<li>
<label>Your Message <span class="required">*</span></label>
<textarea name="field5" id="field5" class="field-long field-textarea"></textarea>
</li>
<li>
<input type="submit" value="Submit">
</li>
</ul>
</form>
If anyone could suggest a workaround, I'd be so grateful!

html embedded conditional if statements in php

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; ?>

how to use php to save info

I am trying to follow along here in my book when building my website, I am trying to work on PHP/ .pl form saving, but I cannot seem to get it to work like it should.
<form action="/cgi-bin/contactlist.php" method="post">
<fieldset>
<legend>Join E-mail List Test blah blah</legend>
<p>This is a test and I am curious what it does so lol </p>
<ol>
<li>
<label for="name">Name:</label>
<input type="text" name="name" id="name" />
</li>
<li>
<label for="email">Email:</label>
<input type="text`enter code here`" name="email" id="email" />
</li>
</ol>
<input type="submit" value="Submit" />
</fieldset>
</form>
</body>
</html>
The code listed above, but the form is not saving like it should, any suggestions?

Assign One Time Username in PHPMYSQL

i am working on a login Script. I have a registration and its login, what i need to give a single access/login, i have my fields in database table name is qz_userauth as ID fname lname email username password. Restrict login after one attempt. Possible ?
Here is login Form
<form action="functions.php" method="post" id="login">
<fieldset>
<legend>Login </legend>
<ul>
<li>
<label for="username"><span class="required">Username</span></label>
<input id="username" name="username" class="text required" type="text" />
<label for="username" class="error">This field cannot be empty</label>
</li>
<li>
<label for="password"><span class="required">Password</span></label>
<input name="password" type="password" class="text required" id="password" maxlength="20" />
</li>
<?php if($_SESSION['LCNT']>=4){ ?>
<li>
<p id="p-captcha">
<div id="captchaImg"><img id="captcha" src="captcha/securimage_show.php" alt="CAPTCHA Image" /></div>
<div id="captchaInput"><input type="text" name="captcha_code" size="16" maxlength="6" value="Enter Captcha" /></div>
<div id="captchaRefresh"><img src="captcha/images/refresh.gif" /></div>
</p>
</li>
<?php } ?>
<li>
<label class="centered info"><a id="forgotpassword" href="fpass.php">Forgot Your password...</a></label>
</li>
</ul>
</fieldset>
<input type="hidden" name="action" value="login" />
<fieldset class="submit">
<input type="submit" class="sbutton" value="Login" /> <input type="button" class="sbutton" value="Register" onclick="window.location='register.php'" />
</fieldset>
</form>
Just set one more field in the table as flag. and after one login attempt set the value of flag as false. and check the flag value during login.
If you mean to ask you want to allow only 1 login at a time per user then you can add another field to your table something like login_status. Set this to 1 when user is logged in and 0 on logout. Then in your login script check if this is 0, only then allow login

Passing form data from one web page to another with PHP

i found few similar questions here but from answers i didn't get the whole picture of how should work.
I have a subscription form in a page:
<form method="post" action="index.php/register">
<fieldset>
<input type="text" id="first_name" name="first_name" />
<input type="text" id="last_name" name="last_name" />
<input type="text" id="email" name="email" />
<input type="text" id="address" name="address" />
<input id="submit" type="submit" value=">>" />
</fieldset>
</form>
when a user a user click the submit button is lead to a page with the full registering form, where i need to have few fields populated with the data sent from previous page form. this is a preview of few fields from the form of the second page:
<form id="register" name="form1" method="post" action="send_contact.php">
<fieldset>
<li><label>*First Name</label>
<input type="text" id="first_name" name="first_name" />
</li>
<li>
<label>*Last Name</label>
<input type="text" id="last_name" name="last_name" />
</li>
<li>
<label>*Email</label>
<input type="text" id="email" name="email" />
</li>
<li>
<label>*Confirm Email</label>
<input type="text" id="confirm-email" name="confirm_email" />
</li>
<li>
<label>Street Address</label>
<input type="text" id="address" name="address" />
<li class="full-width">
<input id="submit" type="submit" value="Register" />
</li>
</fieldset>
</form>
the php is not my strong point, so if you can be more detailed in answer is great for me.
thanks!
I would say for security reasons, do not use Get method "$_GET[]" as people described, keep POST as you have it.
All you need to do on register/ page is get all the values passed on using the POST method and populate them into your HTML. So the second form should look like:
<form id="register" name="form1" method="post" action="send_contact.php">
<fieldset>
<li><label>First Name</label>
<input type="text" id="first_name" name="first_name" value="<?=$_POST[first_name]?>" />
</li>
<li>
<label>*Last Name</label>
<input type="text" id="last_name" name="last_name" value="<?=$_POST[last_name]?>" />
</li>
<li>
<label>*Email</label>
<input type="text" id="email" name="email" value="<?=$_POST[email]?>" />
</li>
<li>
<label>*Confirm Email</label>
<input type="text" id="confirm-email" name="confirm_email" />
</li>
<li>
<label>Street Address</label>
<input type="text" id="address" name="address" value="<?=$_POST[address]?>" />
<li class="full-width">
<input id="submit" type="submit" value="Register" />
</li>
</fieldset>
</form>
Above, I am using shorthand version of "echo" and php tags, if you do not have that enabled under php.ini, please change "" to "; ?>. Also, script will not populate "confirm" email as I assume you would like the user to retype that.
That should do it.
There are basically two methods
Store the values of the first form in a cookie, and the process code can retrieve the values from the cookie
make the form action 'Get' so that the data is passed on to the next page.
You can use the $_POST values from the first form in the page handling the submit of the first form and print them in the new form as:
<?php
echo '<input type="text" id="email" name="email" value="' . htmlentities($_POST['email']) . '"/>
?>
<form method="post" action="register.php">
<fieldset>
<input type="text" id="first_name" name="first_name" />
<input type="text" id="last_name" name="last_name" />
<input type="text" id="email" name="email" />
<input type="text" id="address" name="address" />
<input id="submit" type="submit" value=">>" />
</fieldset>
</form>
register.php
<form id="register" name="form1" method="post" action="send_contact.php">
<fieldset>
<li><label>*First Name</label>
<input type="text" value="<?php echo $_POST['first_name'];?>" id="first_name" name="first_name" />
</li>
<li>
<label>*Last Name</label>
<input type="text" value="<?php echo $_POST['last_name'];?>" id="last_name" name="last_name" />
</li>
<li>
<label>*Email</label>
<input type="text" value="<?php echo $_POST['email'];?>" id="email" name="email" />
</li>
<li>
<label>*Confirm Email</label>
<input type="text" id="confirm-email" name="confirm_email" />
</li>
<li>
<label>Street Address</label>
<input type="text" value="<?php echo $_POST['address'];?>" id="address" name="address" />
<li class="full-width">
<input id="submit" type="submit" value="Register" />
</li>
</fieldset>
</form>
Finally service the post in send_contact.php as you wish

Categories