Obtain data from a form in wordpress - wordpress

I'm building a wordpress website using Avada tamplate. I use the Avada login form in which the users insert their username and password. I would like to get the username of the user when he click on the form button and he's redirect to login.php page. I don't understand why I can't do that.
The code of the form (i removed "class" and "style" in order to reduce it) is:
<form name="loginform" id="loginform" method="post" action="http://www.mywebsite.com/es/wp-login.php">
<div>
<div>
<label for="user_login">Username</label>
<input type="text" name="log" placeholder="Username" value="" size="20" id="user_login" />
</div>
<div>
<label for="user_pass">Password</label>
<input type="password" name="pwd" placeholder="Password" value="" id="user_pass" />
</div>
</div>
<div>
<div>
<button type="submit" name="wp-submit">Log in</button>
<input type="hidden" name="user-cookie" value="1" />
<input type="hidden" name="redirect_to" value="login.php" />
<input type="hidden" name="fusion_login_box" value="true" />
<input type="hidden" name="_wp_http_referer" value="/es/area-privada/" /><span></span></div>
<div></div>
</div>
</form>
The login.php code is very simple:
<?php
$username = $_POST['log'];
echo $username;
?>
however the variable $username is blank and doesn't capture the username. Someone can help me please? thanks!

Related

Login from WordPress to External Site

I'm trying to do a generalized script for any WordPress theme which will display a 'Login' or 'Sign-In' link, then show login username, pwds fields, and upon Submit POST to another site with the login info and log them in.
I've done some CSS and code in some themes' header.php file like this:
<div class="sign-in-wrapper">
<div class="sign-in-dropdown">
<form name="login" id="sign-in-form"
<?php if($_SERVER['SERVER_NAME'] == "www.mysite.com") { ?>
action="https://secure.mysite.com/"
<?php } ?>
method="POST">
<input type="hidden" name="thisaction" id="thisaction" value="">
<b>User Name:</b>
<input type="Text" name="UserName" size="41" class="forminput1" value="">
<b>Password:</b>
<input type="password" name="pwd" size="41" class="forminput1">
<input type="submit" value="Sign In" name="login" border="0">
</form>
</div>
</div>
<div id="sign-in-link"><a class="sign-in" url="#top">Sign in</a> </div>
It works in some themes but not in others.
Is there a good way to do this?

Anchor tag acts as a form submit button?

Anchor tag acts as a form submit button?
<form method="get" action="<?php bloginfo('url'); ?>/">
<div class="field-search">
<input type="text" class="form-control input-lg" placeholder="Search for..." value="<?php the_search_query(); ?>">
<i class="fa fa-search font-16"></i>
</div>
<form action="test.aspx" type="POST">
<label>
<span>Username</span>
<input type="text" name="UserName" id="UserName" class="input-text required" />
</label>
<label>
<span>Password</span>
<input type="password" name="Password" id="Password" class="input-text required" />
</label>
<label>
<input type="checkbox" name="RememberMe" id="RememberMe" class="check-box" />
<span class="checkboxlabel">Remember Me</span>
</label>
<div class="spacer">
Login
</div>
</form>
jquery
$(document).ready(function(){
$(document).on("click",".login-button",function(){
var form = $(this).closest("form");
//console.log(form);
form.submit();
});
});
possible duplicate of
(Anchor tag as submit button?)
(This is a copied answer)
Try this approach see if it works.
Add a click event to your anchor tag as below and do a event.stopPropagation()
$('a').on('click', function(e){
e.stopPropagation();
})`
See if this works

Set a Virtual Page View with Universal GA

This is my HTML from. and i'm trying to set a Virtual Page View when submitting the form but i just can't make it work.
Pls advice
<form id="frmContact" action="post.php" method="post">
<div class="form-right-pnl">
<input type="text" class="required name" size="40" placeholder="×©× ×ž×œ×:" name="full_name">
<input type="text" class="required phone" size="40" placeholder="טלפון:" name="phone">
<input type="text" class="required email" size="40" placeholder='דו×"ל:' name="email">
<span>מ×שר קבלת ×—×•×ž×¨×™× ×¤×¨×¡×•×ž×™×™×</span>
<input type="checkbox" class="radio_btn" name="selling_a_property" checked value="Yes"/>
</div>
<div class="form-left-pnl" id='basic-modal'>
<input class="ddl_list" type="submit" value="" onClick=”_gaq.push([‘_trackEvent’, ‘Forms’, ‘Submit’]);” />
</div>
<div class="clear"></div>
</form>
Change this line
<input class="ddl_list" type="submit" value="" onClick=”_gaq.push([‘_trackEvent’, ‘Forms’, ‘Submit’]);” />
for
<input class="ddl_list" type="submit" value="" onClick=”_gaq.push(['_trackPageview', '/virtual-page-view-on-click-submit-button']);” />

WordPress Search on pluign page

I have an plugin to didsplay list of coupon code in WordPress. I would like to place search box for searching coupon code in coupon page.
<form method="get" id="searchform" action="">
<input type="text" value="Search" name="s" id="s" />
<input type="hidden" name="cat" value="5" />
<input type="submit" id="searchsubmit" value="Search" />
</form>
When I click on search button it redirect me to wordpress post page instead of plugin default page.
Suggest me working solution for implement searching in plugin page.
We have to redirect it manually using this form:
<form method="get" action="<?php echo "edit.php?";?>" id="coupon">
<label class="screen-reader-text" for="tag-search-input">Search Coupon Code:</label>
<input type="hidden" name="post_type" value="wpsc-product" /> //required to redirect it coupon page
<input type="hidden" name="page" value="wpsc-edit-coupons" />//required to redirect it coupon page
<input type="search" id="search-input" name="s" value="">
<input type="submit" name="" id="submit" class="button" value="Search Coupon Code">
</form>
After this you will have to grape the result from $_GET['s'] and apply manual search on that file.

How to send e-mail from form in wordpress

I am new in programing and WordPress. I want to send a e-mail from my form with a message, phone, ect. Can anyone tell me how can i do that?
Here is my code so far...
<div id="form">
<?php
add_filter('wp_mail_content_type','set_content_type');
function set_content_type($content_type){
return 'text/html';
}
?>
<div id="name">
<p id="username"> Name: </p>
<input type="text" name="name" class="textfield">
</div>
<div id="name">
<p id="username"> Email: </p>
<input type="text" name="name" class="textfield">
</div>
<div id="name">
<p id="username"> Phone: </p>
<input type="text" name="name" class="textfield">
</div>
<div id="name">
<p id="username"> Message: </p>
<input type="text" name="message" class="textarea">
</div>
<input type="button" value="SEND" id="btn">
</div>
To send mail from a form with following fields, open a new file and copy these lines and save (e.g. mail.php):
<?php
//sending mail
if(isset($_POST['sub']))
{
$uname=$_POST['uname'];
$mailid=$_POST['mailid'];
$phone=$_POST['phone'];
$message=$_POST['message'];
if(mail($uname,$mailid,$phone,$message))
{
echo "mail sent";
}
else
{
echo "mail failed";
}
}
?>
<form name="frm" method="post" action="#">
<label for="uname">Name:</label>
<input type="text" value="" name="uname" id="uname"><br/>
<label for="mailid">Email:</label>
<input type="text" value="" name="mailid" id="mailid"><br/>
<label for="mobile">Phone:</label>
<input type="text" value="" name="phone" id="phone"><br/>
<label for="message">Message:</label>
<input type="text" value="" name="message" id="message"><br/>
<input type="submit" value="Submit" name="sub" id="sub">
</form>
It will have to be much more complicated than what you have at the moment.
My first recommendation would be to use some, rather top-heavy, form plugins, But you will save yourself a lot of time and trouble like that.
http://www.deliciousdays.com/cforms-plugin/
http://wordpress.org/extend/plugins/contact-form-7
My 2nd recommendation would be to follow a popular tutorial for a full custom form to email script.
http://www.catswhocode.com/blog/how-to-create-a-built-in-contact-form-for-your-wordpress-theme
Note: Beware of spam bots and various other possible dangers of just putting a public form up on the web. If's very possible that you will have a hole in your custom code and a could cause some damage if exploited by the right person.

Resources