$_GET['email'] did not include the '#' character? - php

I made a custom form for forget password in WP.
below is the code that use:
<form name="lostpasswordform" id="lostpasswordform" action="'.wp_lostpassword_url().'" method="post">
<label for="user_login">Username:<br>
<input name="user_login" id="user_login" class="input" value="" size="" type="text"></label><br><br>
<label for="user_email">E-mail Address:<br>
<input name="user_email" id="user_email" class="input" value="" size="" type="text"></label>
<input type="hidden" name="" id="url_temp" value="'.str_replace( '%7E', '~', $_SERVER['REQUEST_URI']).'&axcelerate=forgotpassword">
<input name="redirect_to" value="&user_login=&user_email=" type="hidden" id="lostpasswordform_addon"><br><br>
<p class="submit">
<input name="wp-submit" id="wp-submit" class="button button-primary button-large" value="Get New Password" type="submit">
</p>
</form>
<script>
jQuery('#lostpasswordform #user_login').blur(function() {
jQuery('#lostpasswordform_addon').val( jQuery('#url_temp').val() + '&user_login=' + jQuery(this).val() + '&user_email=' + jQuery('#lostpasswordform #user_email').val());
});
jQuery('#lostpasswordform #user_email').blur(function() {
jQuery('#lostpasswordform_addon').val( jQuery('#url_temp').val() + '&user_login=' + jQuery('#lostpasswordform #user_login').val() + '&user_email=' + jQuery(this).val());
});
</script>
I have a problem in the email value when I check into redirect_to the email format is correct eg. nameof#mail.com
but when I try to set up in a function suing this code:
if($_GET['axcelerate'] == 'forgotpassword'){
echo $_GET['user_email'];
}
it returns nameofmail.com and not nameof#mail.com ?
does anyone have an idea about my case?

Related

On form submit, pass email address from first form to second form

I have two forms, the first gets submitted then the page reloads and shows the second. The problem I have is passing the email address from the first form to the second one. What's the best way to do this without interfering with my actions or changing it from POST to GET?
<?php if(!isset($_POST['crowd_email'])){ ?>
<form id="form" method="POST" action="<?php require( COMMON_PATH . '/components/crowdfunding.php' ); ?>">
<input type="text" name="crowd_email" class="crowd_email" value="" placeholder="Email address">
<input type="submit" class="register-btn" value="Register Interest" name="submit">
</form>
<?php } else { ?>
<form id="form" method="POST" action="<?php require( COMMON_PATH . '/components/crowdfunding-extra.php' ); ?>">
<input type="text" name="first_name" class="crowd_email extra-info" value="" placeholder="First name">
<input type="text" name="tel_no" class="crowd_email extra-info" value="" placeholder="Telephone number">
<input type="text" name="amount" class="crowd_email extra-info" value="" placeholder="Amount to invest">
<input type="submit" class="register-btn" value="Register Interest" name="submitextra">
</form>
<?php } ?>
1) Add a hidden field to the second form.
2) Add the value of the email address (submitted from the first form) to the hidden field when rendering the second form.
e.g.
<?php if(!isset($_POST['crowd_email'])){ ?>
<form id="form" method="POST" action="<?php require( COMMON_PATH . '/components/crowdfunding.php' ); ?>">
<input type="text" name="crowd_email" class="crowd_email" value="" placeholder="Email address">
<input type="submit" class="register-btn" value="Register Interest" name="submit">
</form>
<?php } else { ?>
<form id="form" method="POST" action="<?php require( COMMON_PATH . '/components/crowdfunding-extra.php' ); ?>">
<input type="text" name="first_name" class="crowd_email extra-info" value="" placeholder="First name">
<input type="text" name="tel_no" class="crowd_email extra-info" value="" placeholder="Telephone number">
<input type="text" name="amount" class="crowd_email extra-info" value="" placeholder="Amount to invest">
<input type="hidden" name="email" value="<?php echo $_POST["crowd_email"]; ?>" />
<input type="submit" class="register-btn" value="Register Interest" name="submitextra">
</form>
<?php } ?>
That way, when you submit the second form, the email field will be submitted along with the rest of the new data.
You can just add a hidden input in the second form containing the email value and give it the value from the first submission
<?php if(!isset($_POST['crowd_email'])){ ?>
<form id="form" method="POST" action="<?php require( COMMON_PATH . '/components/crowdfunding.php' ); ?>">
<input type="text" name="crowd_email" class="crowd_email" value="" placeholder="Email address">
<input type="submit" class="register-btn" value="Register Interest" name="submit">
</form>
<?php } else { ?>
<form id="form" method="POST" action="<?php require( COMMON_PATH . '/components/crowdfunding-extra.php' ); ?>">
<!-- New line to hold the email invisbly -->
<input type="hidden" name="crowd-email" value="<?php echo $_POST['crowd_email']; ?>"/>
<input type="text" name="first_name" class="crowd_email extra-info" value="" placeholder="First name">
<input type="text" name="tel_no" class="crowd_email extra-info" value="" placeholder="Telephone number">
<input type="text" name="amount" class="crowd_email extra-info" value="" placeholder="Amount to invest">
<input type="submit" class="register-btn" value="Register Interest" name="submitextra">
</form>
<?php } ?>

get addition without button click

Can anyone help me to get the addition of Basic Salary and Allowance I and insert it in Total Day Rate without clicking a button. here's my php code.
Here's a Screen Shot of my UI.
Code :
<?php
$connection = mysql_connect("localhost", "root", "");
$db = mysql_select_db("laboursalary", $connection);
if(isset($_POST['submit'])){
$ID = $_POST['ID'];
$Name = $_POST['Name'];
$Location = $_POST['Location'];
$Category = $_POST['Category'];
$LabourSupplier = $_POST['LabourSupplier'];
$Home = $_POST['Home'];
$Mobile = $_POST['Mobile'];
$BasicSalary = $_POST['BasicSalary'];
$Allowance1 = $_POST['Allowance1'];
$Allowance2 = $_POST['Allowance2'];
$DayRate = $_POST['$DayRate'];
$OTrate = $_POST['OTrate'];
if($ID !=''||$Name !=''){
$query = mysql_query("insert into attendance(ID, Name, Location, Category,LabourSupplier,Home,Mobile,BasicSalary,Allowance1,Allowance2,DayRate,OTrate) values ('$ID','$Name','$Location','$Category','$LabourSupplier','$Home','$Mobile','$BasicSalary','$Allowance1','$Allowance2','$DayRate','$OTrate')");
echo "<br/><br/><span>Data Inserted successfully...!!</span>";
}
else{
echo "<p>Insertion Failed <br/> Some Fields are Blank....!!</p>";
}
}
mysql_close($connection);
?>
After I enter the values for Basic Salary and Allowance 1, I want to get the addition of those two in Day Rate automatically.
this is my HTML code.
<form id="details" action="" method="POST">
<fieldset> ID:
<input class="input" type="text" name="ID" value="" />
</fieldset>
<fieldset> Name:
<input class="input" type="text" name="Name" value="" />
</fieldset>
<fieldset> Location:
<input class="input" type="text" name="Location" value="" />
</fieldset>
<fieldset> Category:
<input class="input" type="text" name="Category" value="" />
</fieldset>
<fieldset> Labour Supplier:
<input class="input" type="text" name="LabourSupplier" value="" />
</fieldset>
<fieldset> Telephone:
<input class="input" type="text" name="Home" value="" />
</fieldset>
<fieldset>Mobile:
<input class="input" type="text" name="Mobile" value="" />
</fieldset>
<fieldset> Basic Salary:
<input class="input" type="number" name="BasicSalary" value="" />
</fieldset>
<fieldset> Allowance I:
<input class="input" type="number" name="Allowance1" value="" />
</fieldset>
<fieldset>Allowance II:
<input class="input" type="number" name="Allowance2" value="" />
</fieldset>
<fieldset>Total Day Rate:
<input class="input" type="number" name="DayRate" value="" />
</fieldset>
<fieldset>OT Rate:
<input class="input" type="number" name="OTrate" value="" />
</fieldset>
<fieldset>
<button name="submit" type="submit" id="submit">Insert</button>
<button onclick="goBack()" name="Back" type="back" id="details-back">Back</button>
</fieldset>
</form>
As I understood your question, your HTML code should be like,
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
</head>
<body>
<form id="details" action="" method="POST">
<fieldset> ID:
<input class="input" type="text" name="ID" value="" />
</fieldset>
<fieldset> Name:
<input class="input" type="text" name="Name" value="" />
</fieldset>
<fieldset> Location:
<input class="input" type="text" name="Location" value="" />
</fieldset>
<fieldset> Category:
<input class="input" type="text" name="Category" value="" />
</fieldset>
<fieldset> Labour Supplier:
<input class="input" type="text" name="LabourSupplier" value="" />
</fieldset>
<fieldset> Telephone:
<input class="input" type="text" name="Home" value="" />
</fieldset>
<fieldset>Mobile:
<input class="input" type="text" name="Mobile" value="" />
</fieldset>
<fieldset> Basic Salary:
<input class="input" type="number" name="BasicSalary" value="0" id="bassal" />
</fieldset>
<fieldset> Allowance I:
<input class="input" type="number" name="Allowance1" value="0" id="all1" />
</fieldset>
<fieldset>Allowance II:
<input class="input" type="number" name="Allowance2" value="0" id="all2" />
</fieldset>
<fieldset>Total Day Rate:
<input class="input" type="number" name="DayRate" value="" id="DayRate" />
</fieldset>
<fieldset>OT Rate:
<input class="input" type="number" name="OTrate" value="" />
</fieldset>
<fieldset>
<button name="submit" type="submit" id="submit">Insert</button>
<button onclick="goBack()" name="Back" type="back" id="details-back">Back</button>
</fieldset>
</form>
<script >
$(document).ready(function (){
$('#bassal').on('input', function() {
$('#DayRate').val(parseInt($('#bassal').val()) + parseInt($("#all1").val()) + parseInt($("#all2").val()));
});
$('#all1').on('input', function() {
$('#DayRate').val(parseInt($('#bassal').val()) + parseInt($("#all1").val()) + parseInt($("#all2").val()));
});
$('#all2').on('input', function() {
$('#DayRate').val(parseInt($('#bassal').val()) + parseInt($("#all1").val()) + parseInt($("#all2").val()));
});
});
</script>
I've added jQuery, that does your work, and you don't need to do addition on PHP side.
This is how it would be done using a submit for post as these are all _POST values... Though to accomplish this without pressing a button would be JS/Angular/J Query/AJAX...
....
$BasicSalary = $_POST['BasicSalary'];
$Allowance1 = $_POST['Allowance1'];
$Allowance2 = $_POST['Allowance2'];
$DayRate = $_POST['$DayRate'];
$OTrate = $_POST['OTrate'];
//Set a new variable with the addition of the two `Basic Salary` and `Allowance 1`
//for the insertion into your column `dayRate`
$adustedDayRate = $BasicSalary + $Allowance1;
if($ID !=''||$Name !=''){
if($query != false){
$query = mysql_query("INSERT INTO `attendance` (ID, Name, Location, Category,LabourSupplier,Home,Mobile,BasicSalary,Allowance1,Allowance2,DayRate,OTrate) values ('$ID','$Name','$Location','$Category','$LabourSupplier','$Home','$Mobile','$BasicSalary','$Allowance1','$Allowance2','$adustedDayRate','$OTrate')");
echo "<br/><br/><span>Data Inserted successfully...!!</span>";
}esle{ $_SESSION['err'] = "ERROR: ".--- MySQL error handle here --- }
}
else{
echo "Some Fields are Blank....!!</p>";
}
}
mysql_close($connection);
Using Angular, you could place a placeholder element in your form input for `DayRate, then add the call back for the ng-model element for the two inputs you wish to add. Something like this here:
<div ng-app="">
<p>BasicSalary : <input type="number" ng-model="BasicSalary" placeholder="Basic Salary"></p>
<p>AllowanceI : <input type="number" ng-model="AllowanceI" placeholder="Allowance I"></p>
<p>DayRate : <input type="number" ng-model="DayRate" placeholder="{{BasicSalary -- AllowanceI}}"></p>
Your code would look like:
<fieldset> Basic Salary:
<input class="input" type="number" ng-model="BasicSalary" name="BasicSalary" value="" />
</fieldset>
<fieldset> Allowance I:
<input class="input" type="number" ng-model="Allowance1" name="Allowance1" value="" />
</fieldset>
<fieldset>Allowance II:
<input class="input" type="number" name="Allowance2" value="" />
</fieldset>
<fieldset>Total Day Rate:
<input class="input" type="number" name="DayRate" placeholder="{{ BasicSalary -- Allowance1 }}" value="" />
</fieldset>
Here is a working fiddle of the angular method, simply add the angular library to your server using composer or hosted links, no additional JS is required with the Angular library elements. You can change the value of DayRate as the two other combining inputs are being input.
https://jsfiddle.net/qkpfb90o/1/
Hope this helps!
You can also try with this.
<form id="details" action="" method="POST">
<fieldset> ID:
<input class="input" type="text" name="ID" value="" />
</fieldset>
<fieldset> Name:
<input class="input" type="text" name="Name" value="" />
</fieldset>
<fieldset> Location:
<input class="input" type="text" name="Location" value="" />
</fieldset>
<fieldset> Category:
<input class="input" type="text" name="Category" value="" />
</fieldset>
<fieldset> Labour Supplier:
<input class="input" type="text" name="LabourSupplier" value="" />
</fieldset>
<fieldset> Telephone:
<input class="input" type="text" name="Home" value="" />
</fieldset>
<fieldset>Mobile:
<input class="input" type="text" name="Mobile" value="" />
</fieldset>
<fieldset> Basic Salary:
<input class="input" type="number" name="BasicSalary" value="" id="BasicSalary" onkeyup="doSum()"/>
</fieldset>
<fieldset> Allowance I:
<input class="input" type="number" name="Allowance1" value="" id="Allowance1" onkeyup="doSum()"/>
</fieldset>
<fieldset>Allowance II:
<input class="input" type="number" name="Allowance2" />
</fieldset>
<fieldset>Total Day Rate:
<input class="input" type="number" name="DayRate" value="" id="DayRate" />
</fieldset>
<fieldset>OT Rate:
<input class="input" type="number" name="OTrate" value="" />
</fieldset>
<fieldset>
<button name="submit" type="submit" id="submit">Insert</button>
<button onclick="goBack()" name="Back" type="back" id="details-back">Back</button>
</fieldset>
<script>
function doSum() {
var Allowance1 = isNaN(document.getElementById('Allowance1').value) ? document.getElementById('Allowance1').value : 0;
var BasicSalary = isNaN(document.getElementById('BasicSalary').value) ? document.getElementById('BasicSalary').value : 0;
var tot = parseInt(Allowance1) + parseInt(BasicSalary);
document.getElementById('DayRate').value = tot;
}
</script>

Input string separated by underscore in form

I haven't come to much luck finding anything on this, since I couldn't think how to word it originally.
Basically I have a form, in HTML, the end user will submit a value such as "12345_54321" into 1 input field, then process.
I would like to be able to allow there to be 2 input fields instead, so one of them they would enter "12345" and in the second one, they'd enter "54321".
Which seems easy enough, but my real need is that the "_" must be used as a separator, such as, when the value is submitted, it will process "12345_54321" instead of "12345" and "54321"
My form so far:
<form role="form" method="post" action="process.php">
<fieldset>
<div class="form-group">
<input size="18" type="visible" name="postid" id="postid" class="form-control" placeholder="Enter Story ID Here:" class="input-medium" ><input size="18" type="visible" name="postid" id="postid" class="form-control" placeholder="Enter Comment ID Here:" class="input-medium" >
</div>
<input type="submit" name="submit" class="btn btn-primary btn-large" id="submit_btn" value="Process"/>
</fieldset>
If you want to display 2 inputs for the story id, you have to modify your page to be like so (no need for the underscore (_):
<form role="form" method="post" action="process.php">
<fieldset>
<div class="form-group">
<input size="18" type="visible" name="story_id_1" id="story_id_1" class="form-control" placeholder="Enter Story ID Here:" class="input-medium" >
<input size="18" type="visible" name="story_id_2" id="story_id_2" class="form-control" placeholder="Enter Story ID Here:" class="input-medium" >
<input size="18" type="visible" name="comment_id" id="comment_1" class="form-control" placeholder="Enter Comment ID Here:" class="input-medium" >
</div>
<input type="submit" name="submit" class="btn btn-primary btn-large" id="submit_btn" value="Process"/>
</fieldset>
</form>
In your process.php you can get these variables by looking in your POST.
<?php
$story_id_1 = '';
$story_id_2 = '';
$comment_id = '';
// Check for empty fields
if(isset($_POST['story_id_1']))
$story_id_1 = $_POST['story_id_1']; // From HTML Page
if(isset($_POST['story_id_2']))
$story_id_2 = $_POST['story_id_2']; // From HTML Page
if(isset($_POST['comment_id']))
$comment_id = $_POST['comment_id']; // From HTML Page
print 'Story Id 1: '. $story_id_1 . '</br>';
print 'Story Id 2: '. $story_id_1 . '</br>';
print 'Comment Id: '. $comment_id . '</br>';
Add a hidden field, whose value will be the concatenation of the two input fields:
and on submit, set its value by concatenating the values of the two input fields:
<form role="form" method="post" action="process.php">
<fieldset>
<input type="hidden" id="theValue" />
<div class="form-group">
<input size="18" type="visible" name="postid" id="postid1" class="form-control" placeholder="Enter Story ID Here:" class="input-medium" onchange="concat();">
<input size="18" type="visible" name="postid" id="postid2" class="form-control" placeholder="Enter Comment ID Here:" class="input-medium" onchange="concat();">
</div>
<input type="submit" name="submit" class="btn btn-primary btn-large" id="submit_btn" value="Process" />
</fieldset>
<script>
// if no jQuery.....standard ECMAScript
function concat() {
var val = document.getElementById('postid1').value + '_' + document.getElementById('postid2').value;
document.getElementById('theValue').value = val;
console.log(val);
}

jquery to update dropdown menu from textbox

I am new to jquery. I have a textbox, and I want to take value from a textbox and show it in dropdown menu. I have searched for the solution in many websites,but can't get an appropriate answer. Kindly please help me how to do it in jquery.
The code for textbox are shown below. Thanks in advance, and sorry for my english.
<form method="post" action="inq.php">
<p><br>
<b>Question no:</b><br>
<input class="inp-form" type="Text" name="qno" size="30" required>
<br>
<br>
<b>Question:</b><br>
<textarea name="question" rows="4" cols="50" required></textarea>
<!--<input class="inp-form"type="Text" name="question" size="50">-->
<br>
<b>Option 1:</b><br>
<input class="inp-form" type="Text" name="opt1" size="30" required>
<br>
<b>Option 2:</b><br>
<input class="inp-form"type="Text" name="opt2" size="30" required>
<br>
<b>Option 3:</b><br>
<input class="inp-form"type="Text" name="opt3" size="30" required>
<br>
<b>Option 4:</b><br>
<input class="inp-form" type="Text" name="opt4" size="30" required>
<br>
<b>Answer</b> (must be identical to correct option):<br>
<input class="inp-form" type="Text" name="answer" size="30" required>
<br>
<br>
<input class="form-submit" type="Submit" name="submit" value="Add" required>
</p>
</form>
Try this. Add another class to options text box (i.e) option like below.
Add onclick="AddQS()" to submit button.
Add one dropdown box.
function AddQS() {
$('#sltOptions').empty();
$('.option').each(function() {
$('#sltOptions').append('<option value = ' + $(this).attr('name') + '>' + $(this).val() + '</option>');
});
}
<------------------>
<input class="inp-form option" type="Text" name="opt1" size="30" required>
<------------------>
<input class="form-submit" type="Submit" name="submit" value="Add" onclick="AddQS()" required>
<------------------>
<select id="sltOptions">
</select>
Please have a look at http://jsfiddle.net/2dJAN/47/
$('.options').change(function(){
var val = $(this).val().trim();
$("#answer").append("<option value='"+val+"'>"+val+"</option>");
});
Let me know is this example full fill your requirement or not.

print values in a specific <p>

hello guys? can you help me with this? i want to get the id of the first input and the text value of the second input in a specific p tag
<p class="receiveitem">
<label for="mat_id">Material</label>
<input type="text" id="4"value="GI Coulping" disabled/>
<label for="rec_qty">Quantity</label>
<input type="text" class="rec_qty" />
<input type="button" class="receive" value=Receive />
</p>
<p class="receiveitem">
<label for="mat_id">Material</label>
<input type="text" id="5"value="Vulca Seal" disabled/>
<label for="rec_qty">Quantity</label>
<input type="text" class="rec_qty" />
<input type="button" class="receive" value=Receive />
</p>
<p class="receiveitem">
<label for="mat_id">Material</label>
<input type="text" id="6"value="teflon tape" disabled/>
<label for="rec_qty">Quantity</label>
<input type="text" class="rec_qty" />
<input type="button" class="receive" value=Receive />
</p>
so when i click the receive button that's in the p tag.
it will output someting like
ID: 4 and Value: 10
already have a js.but i can't get it done.
$(document).ready(function(){
$('input#receive').click(function(){
var mat = $('input[type=text]:first').attr('id');
var qty = $('input[type=text]:last').val;
alert(mat + qty);
});
});
and i dont know where to put the this in my variables mat and qty.please help?
Here is a modified approach using the more semantically correct data attributes (which are broadly supported) (building on #Chase's answer) (and a demo)
<p class="receiveitem">
<label for="mat_id">Material</label>
<input name="mat_id" type="text" data-id="4" value="GI Coulping" disabled="disabled"/>
<label for="rec_qty">Quantity</label>
<input type="text" name="rec_qty" />
<input name="rec_qty" type="button" class="receive" value="Receive" />
</p>
<p class="receiveitem">
<label for="mat_id">Material</label>
<input name="mat_id" type="text" data-id="5" value="Vulca Seal" disabled="disabled"/>
<label for="rec_qty">Quantity</label>
<input type="text" name="rec_qty" />
<input type="button" class="receive" value="Receive" />
</p>
<p class="receiveitem">
<label for="mat_id">Material</label>
<input name="mat_id" type="text" data-id="6" value="teflon tape" disabled="disabled"/>
<label for="rec_qty">Quantity</label>
<input type="text" name="rec_qty" />
<input type="button" class="receive" value="Receive" />
</p>
With this JavaScript
$(document).on("click", "input.receive", function () {
var mat = $(this).siblings("[name='mat_id']").data("id");
var qty = $(this).siblings("[name='rec_qty']").val();
alert("mat id: " + mat + " qty val: " + qty);
});
This approach won't abuse the id attribute which is designed for node identification and not data storage.
$(document).on('click', 'input#receive', function(e){
e.preventDefault();
var qty = $(this).prev().prev('input');
alert(qty);
});
You really need to change your markup to use data or unique IDs though.

Categories