Login from WordPress to External Site - wordpress

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?

Related

Obtain data from a form in 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!

Functioning of Wordpress Contact form to Laravel Method

On my website there is a contact form on footer which is working fine.
Site Blog is on wordpress have same contact form.
I don't wan't to create working again for wordpress contact form
<form action="/yocreativ/contact-us" method="post">
<?php
//Generate a random string.
$token = openssl_random_pseudo_bytes(20);
//Convert the binary data into hexadecimal representation.
$token = bin2hex($token);
//Print it out for example purposes.
// echo $token;
?>
<input type="hidden" name="_token" value="<?php echo $token; ?>">
<div class="form-group col-lg-4 wow fadeInDown animated" data-wow-delay="0.2s">
<input type="text" name="name" class="form-control" id="name" placeholder="NAME" required="required">
</div>
<div class="form-group col-lg-4 wow fadeInDown animated" data-wow-delay="0.2s">
<input type="email" name="email" class="form-control" id="email" placeholder="EMAIL" required="required">
</div>
<div class="form-group col-lg-4 wow fadeInDown animated" data-wow-delay="0.2s">
<input type="tel" name="phone" class="form-control" id="subject" placeholder="PHONE" pattern="^\d{3}\d{3}\d{4}$" required="required">
</div>
<div class="form-group col-lg-12 wow fadeInDown animated" data-wow-delay="0.2s">
<textarea name="message" id="message" cols="30" rows="5" placeholder="MESSAGE" required="required"></textarea>
</div>
<div class="row">
<div class="col-lg-12">
<button type="submit" class="btn contact-submit">SEND</button>
</div>
</div>
</form>
Form action="/yocreativ/contact-us" which is the route of my laravel app.
When i submit the form it says.
The page has expired due to inactivity.
Please refresh and try again.
For WordPress wp_nonce_field and wp_verify_nonce field to verify.
https://codex.wordpress.org/Function_Reference/wp_nonce_field
Form field like:
<form method="post">
<?php wp_nonce_field('name_of_my_action','name_of_nonce_field'); ?>
</form>
In action file
<?php
if ( empty($_POST) || !wp_verify_nonce($_POST['name_of_nonce_field'],'name_of_my_action') )
{
print 'Sorry, your nonce did not verify.';
exit;
}
else
{
// process form data
}

Form submit not working on Chrome

I'm experiencing an issue with a booking form displayed on an hotel wordpress website.
It currently works on firefox and edge, but nothing to do with chrome...
Here is my website :
http://terranostra-ariege.com/
The booking form is the big grey block on the center : when you hit "Réserver", then you are redirected to the booking solution with the options you chose.
The form is made this way :
<div id="resa">
<form id="AVP" method="post" action="http://www.secure-hotel-booking.com/Terranostra-Bellevue/2VW1/search" target="_blank">
<input type="hidden" id="language" name="language" value="fr" />
<input type="hidden" id="AVP_arrivalDate" name="arrivalDate" value="" />
<input type="hidden" id="AVP_nights" name="nights" value="" />
<input type="hidden" id="guestCountSelector" name="guestCountSelector" value="ReadOnly" />
<div class="resa_inline_block">
<label for="AVP_list_days" class="resa_block_label"><?php _e('Arrivée','qns'); ?> :</label>
<select id="AVP_list_days" onchange="updateDDay();" class="days"></select>
<select id="AVP_list_months" onchange="setDays();" class="months"></select>
</div>
<div class="resa_inline_block">
<label for="AVP_list_nights" class="resa_block_label"><?php _e('Nombre de nuits','qns'); ?> :</label>
<select id="AVP_list_nights"></select>
</div>
<div class="resa_inline_block">
<label for="selectedAdultCount" class="resa_block_label"><?php _e('Adultes','qns'); ?> :</label>
<select id="selectedAdultCount" name="selectedAdultCount"></select>
</div>
<div class="resa_inline_block">
<label for="selectedChildCount" class="resa_block_label"><?php _e('Enfants','qns'); ?> :</label>
<select id="selectedChildCount" name="selectedChildCount"></select>
</div>
<div class="resa_inline_block bb">
<label for="selectedInfantCount" class="resa_block_label"><?php _e('Bébés','qns'); ?> :</label>
<select id="selectedInfantCount" name="selectedInfantCount"></select>
</div>
<div class="resa_inline_block">
<input type="button" value="<?php _e('Réserver','qns'); ?>" class="submit" />
</div>
</form>
<p><?php _e('Contactez-nous au <span style="font-size: 14pt; font-weight: bold;">05 61 05 52 06</span> pour toute demande ou pour réserver directement','qns'); ?></p>
<script type="text/javascript">
var months = new Array("janvier","février","mars","avril","mai","juin","juillet","août","septembre","octobre","novembre","décembre");
var message='Date en dehors du planning';
</script>
<script type="text/javascript" src="http://www.secure-hotel-booking.com/Terranostra-Bellevue/2VW1/scripts/base.js"></script>
</div>
I first thought it was because I was opening the form action on a new tab, and redirecting the user to an acknowledgments page on the current tab. So i tried to make it the right way with a simple link, and the problem is still there.
Moreover the chrome console is not reporting any error.
Do you have any idea about how I could solve this ?
Thank you very much in advance,
Elliott
Change your input button to submit rather than button:
<input type="submit" value="<?php _e('Réserver','qns'); ?>" class="submit" />

WordPress search not submitting

I am using the following code for a search bar. When you click the submit, it does nothing. It is not even directing to another page. I am using the Understrap theme.
<div id="search">
<form action="/" method="get">
<input type="search" placeholder="Type your search word(s) here" value="<?php get_search_query(); ?>" />
<button type="submit" class="btn btn-primary">Search</button>
</form>
</div>
Make action attribute your site url instead of '/'. Sometime '/' want be useful.
<div id="search">
<form method="get" id="searchform" action="<?php bloginfo('url'); ?>">
<input type="search" placeholder="Type your search word(s) here" value="<?php get_search_query(); ?>" />
<button type="submit" class="btn btn-primary">Search</button>
</form>
</div>

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