I wasn't sure how to phrase the title, but here's what I'm trying to do.
I have a form to login to webmail, I don't have access to the webmail - it just posts the form input to the website and the webmail server takes it from there.
Everyone logging in to this page will be using the same email extension (e.g. "#myemail.com"), so I want to save the hassle of typing that every time, instead they can just write "mike" and the form will add "#myemail.com" on it's own.
I could post this form to a middle ground php page that sticks "mike" + "#mymail.com" together and posts this info to the webmail?
Or is there a simpler way to do this without having to create another page?
<form name="loginForm" action="http://webmail.emailsrvr.com/login.php" method="POST" target="_blank">
<input type="hidden" name="js_autodetect_results" value="SMPREF_JS_OFF">
<input type="hidden" name="just_logged_in" value="1">
<input type="hidden" name="type" value="v3">
<input type="hidden" name="useSSL" id="useSSL" value="">
<input type="email" name="user_name" placeholder="Username" required autofocus>
<input type="password" name="password" placeholder="Password" required>
<label for="remember"><input type="checkbox" name="remember">Remember my info</label>
<button type="submit">Sign In</button>
</form>
I want to take the value entered here...
<input type="email" name="user_name" placeholder="Username" required autofocus>
...and add an extension like "#myemail.com" to it, then post it.
Any idea? Thanks in advance for your help.
I could do something like this?
PAGE 1 - Enter username and password...
<input type="text" name="send_email" placeholder="Username" required autofocus>
<input type="password" name="send_password" placeholder="Password" required>
<label for="remember"><input type="checkbox" name="remember">Remember my info</label>
<button type="submit">Sign In</button>
</form>
PAGE 2 - PHP takes username and adds "#myemail.com" and sends form...
<?php
$form_email = $form_password = "";
if (!empty($_POST['send_email']) && !empty($_POST['send_password'])) {
$form_email = $test($_POST['send_email']) . '#fountaincreations.ca';
$form_password = $test($_POST['send_password']);
echo '<form name="loginForm" action="http://webmail.emailsrvr.com/login.php" method="POST" target="_blank">';
echo '<input type="hidden" name="js_autodetect_results" value="SMPREF_JS_OFF">';
echo '<input type="hidden" name="just_logged_in" value="1">';
echo '<input type="hidden" name="type" value="v3">';
echo '<input type="hidden" name="useSSL" id="useSSL" value="">';
echo '<input type="hidden" name="user_name" value="' . $form_email . '">';
echo '<input type="hidden" name="form_password" value="' . $form_password . '">';
echo '</form>';
} else {
echo '<p style="text-align:center;padding:40px 20px;">Please go back and try again.</p>';
}
function test($data) {
$data = strtolower(data);
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
return $data;
}
?>
How do I tell PHP to automatically submit the form though?
Here's what I have if I were to use jQuery:
It doesn't currently work though.
HTML:
<div class="box top">
<form name="loginForm" action="http://webmail.emailsrvr.com/login.php" method="POST" target="_blank">
<input type="hidden" name="js_autodetect_results" value="SMPREF_JS_OFF">
<input type="hidden" name="just_logged_in" value="1">
<input type="hidden" name="type" value="v3">
<input type="hidden" name="useSSL" id="useSSL" value="">
<div class="inner">
<div class="inner-row"><input type="text" name="user_name" placeholder="First Name" required autofocus></div>
<div class="inner-row"><input type="password" name="password" placeholder="Password" required></div>
<div class="inner-row">
<div class="inner-col col-2-4"><label for="remember"><input type="checkbox" name="remember">Remember my info</label></div>
<div class="inner-col col-2-4"><button type="submit">Sign In</button></div>
</div>
</div>
</form>
</div>
<div class="box bottom">
<div class="inner">
<div class="inner-row"><p>Already signed in? <b>Go to your inbox.</b></p>
</div>
</div>
JS:
<script type="text/javascript">
$(document).ready(function(){
$("button[type='submit']").on('click', function(e){
e.preventDefault();
var userEmail = $.trim($("input[name='user_name']").val());
$("input[name='user_name']").val(userEmail+"#fountaincreations.ca");
$("form[name='loginForm']").submit();
});
});
</script>
I think if you want to attach username + "#mymail.com" to useremail field, here is my suggestion:
1# create input user_email (just hide this field)
<input type="hidden" name="user_email" id="user_email" placeholder="User Email">
2# add js below
$('#user_name').on('input', function() {
username = this.value+'#myemail.com';
$('#user_email').val(username);
});
here example
I think this will go like this, hope this will help you. What i am doing in this code is, first I stop the form from being submitted through e.preventDefault(); and then i am taking the value of the required input and assigning it back value by attaching "#mymail.com".
$(document).ready(function(){
$("button[type='submit']").on('click', function(e){
e.preventDefault();
var userEmail = $.trim($("input[type='email']").val());
$("input[type='email']").val(userEmail+"#mymail.com");
$("form[name='loginForm']").submit();
});
});
Related
I have a form as follow.
<form action="action.php" method="post">
<div class="add_another">
<label for="BrotherAdmissionNumber" class="p-label-required">Admission Number</label>
<input type="text" name="BrotherAdmissionNumber[]" placeholder="Admission Number" />
<label for="varName" class="p-label-required">Name</label>
<input type="text" name="BrotherName[]" placeholder="Name" class="form-control" />
<label for="BrotherGrade" class="p-label-required">Grade</label>
<input type="text" id="varGrade" name="BrotherGrade[]" placeholder="Grade" class="form-control" />
<label for="BrotherClassTr" class="p-label-required">Class Teacher</label>
<input type="text" id="varClassTeacher" name="BrotherClassTr[]" placeholder="Class Teacher" class="form-control" />
<button class="btn add_field_button" style="float: right;">Add Another Brother</button>
</div>
<button class="submit" >Submit</button>
</form>
And I am using following jQuery to add another section to the form.
This will create the set of fields again.
<script>
var max_fields = 10;
var wrapper = jQuery(".add_another");
var add_sec_3 = '<div class="add_another" style="border-top: 1px solid #f0f0f0; border-spacing: 7px;"><label for="BrotherAdmissionNumber" class="p-label-required">Admission Number</label><input type="text" name="BrotherAdmissionNumber[]" placeholder="Admission Number" /><label for="varName" class="p-label-required">Name</label><input type="text" name="BrotherName[]" placeholder="Name" class="form-control" /><label for="BrotherGrade" class="p-label-required">Grade</label><input type="text" id="varGrade" name="BrotherGrade[]" placeholder="Grade" class="form-control" /><label for="BrotherClassTr" class="p-label-required">Class Teacher</label><input type="text" id="varClassTeacher" name="BrotherClassTr[]" placeholder="Class Teacher" class="form-control" />Remove</div>';
jQuery(add_button).click(function(e){ //on add input button click
e.preventDefault();
if(x < max_fields){ //max input box allowed
x++; //text box increment
jQuery(wrapper).append(add_sec_3); //add section
jQuery('.add_another .add_another:last').hide();
jQuery('.add_another .add_another:last').show('fast');
}
});
</script>
When clicking on add another button a section is added successfully.
So that's fine.
My issue is, I tried several methods of retrieving for arrays but nothing works.
I want to create another form with hidden fields of brother details to send it to another page.
How can I show the all generated fields values in a php page during the submission?
How do I have to update this action.php file?
action.php
<?php
$BrotherAdmissionNumber = $_POST['BrotherAdmissionNumber'];
$BrotherName = $_POST['BrotherName'];
$BrotherGrade = $_POST['BrotherGrade'];
$BrotherClassTr = $_POST['BrotherClassTr'];
foreach(){
//brothers details start here
?>
<form action="action2.php" method="post">
Admission Number :<?= $BrotherAdmissionNumber ?>
<input type="hidden" value="<?= $BrotherAdmissionNumber ?>" name="BrotherAdmissionNumber" />
Name :<?= $BrotherName ?>
<input type="hidden" value="<?= $BrotherName ?>" name="BrotherName" />
Grade :<?= $BrotherGrade ?>
<input type="hidden" value="<?= $BrotherGrade ?>" name="BrotherGrade" />
Teacher :<?= $BrotherClassTr ?>
<input type="hidden" value="<?= $BrotherClassTr ?>" name="BrotherClassTr"/>
<button name="send_to_other_page">CONFIRM</button> <!-- when this button is clicked the form shoukd send the hidden values -->
</form>
<?php } ?>
Now when send_to_other_page button is clicked the form should send the hidden values to next page action2.php
What I have to update in foreach loop above?
How I can collect these details in action2.php ?
Take a look at this link
You have to serialise form data and then you can easily retrieve and save in database.
Some thing is wrong in this code, because when i press the submit button the code inside this block of code it is not executed.
Here is the code:
if(isset($_POST["form"])) {
if (Form::isValid($_POST["form"])){
include 'config_php/insert_lead.php';
} else{
header("Location: " . $_SERVER["PHP_SELF"]);
exit();
}
}
This is a small portion of the form:
<form action="index.php?s=2468" id="multiphase" method="post" class="form-horizontal">
<fieldset>
<input type="text" class="form-control shadow" name="first_name" required="" placeholder="Voornaam:" id="multiphase-element-22">
<input type="text" class="form-control shadow" name="last_name" required="" placeholder="Achternaam: " id="multiphase-element-23">
<input type="email" class="form-control shadow" name="email1" required="" placeholder="E-mailadres:" id="multiphase-element-28">
<input type="submit" value="Submit" name="submit" class="btn btn-primary" id="multiphase-element-29">
</fieldset>
</form>
One more thing the form is generated using PFBC
There isn't a post value named 'form', so you should set one to look for on the submission.
Notice that I have also used the entire POST array in the Form::isValid() check.
PHP:
if(isset($_POST["postback"])) {
$valid = true;
if (Form::isValid($_POST)){
include 'config_php/insert_lead.php';
} else{
header("Location: " . $_SERVER["PHP_SELF"]);
exit();
}
}
HTML:
<form action="index.php?s=2468" id="multiphase" method="post" class="form-horizontal">
<fieldset>
<input type="text" class="form-control shadow" name="first_name" required="" placeholder="Voornaam:" id="multiphase-element-22">
<input type="text" class="form-control shadow" name="last_name" required="" placeholder="Achternaam: " id="multiphase-element-23">
<input type="email" class="form-control shadow" name="email1" required="" placeholder="E-mailadres:" id="multiphase-element-28">
<input type="hidden" name="postback" value="1">
<input type="submit" value="Submit" name="submit" class="btn btn-primary" id="multiphase-element-29">
</fieldset>
</form>
In your code $_POST["form"] is the fault you doing...
if you are using $_POST["form"] then it means you have named any of your input field as "form" which i dont see in your code...
so instead of $_POST["form"] you should use any of the input name you using...
I suggest to use..
$_POST["submit"] instead of $_POST["form"]
because you have already named submit input field as submit...
See if it help
Change form tor submit:
<?php
if(isset($_POST["submit"])) {
if (Form::isValid($_POST["form"])){
include 'config_php/insert_lead.php';
} else{
header("Location: " . $_SERVER["PHP_SELF"]);
exit();
}
}
The the if will be executed BUT the you will still have problems with the next if (Form::isValid($_POST["form"])) I don't know how isValid works but $_POST["form"] does not exist. You can validate all inputs one by one.
I want use my own button in form
When i'm using
<form method="post" action="check_login.php">
<input class="textbox" name="username" type="text" placeholder="Login">
<input class="textbox" name="password" type="password" placeholder="Password">
<div id="buttonPlace">
<p>Remember Me</p>
<input type="submit" value="Log in!" />
</form>
it works great. I would like to use my own button. When Im using this code :
<form method="post" action="check_login.php">
<input class="textbox" name="username" type="text" placeholder="Login">
<input class="textbox" name="password" type="password" placeholder="Password">
<div id="buttonPlace">
<p>Remember Me</p>
<div id="buttonLogin" type="submit">sing up</div>
</form>
Button doesn't work.
Why?
<form method="post" action="check_login.php">
<input class="textbox" name="username" type="text" placeholder="Login">
<input class="textbox" name="password" type="password" placeholder="Password">
<div id="buttonPlace">
<p>Remember Me</p>
<button id="buttonLogin" type="submit">Sign up</button>
</div>
</form>
Div can't have type="submit" property, only form inputs can have different input types property. If you want to style your submit button, use:
<input class="submitbutton" type="submit">Sign up</input>
and then define css style for your button class:
.submitButton {
.width: 60px;
.height: 20px;
.color: #dd5599;
}
If you want to submit form on click of your div, use need to assing its click a function to sumbit the form :-
$( document ).ready(function() {
$( "#buttonLogin" ).click(function() {
$( this ).closest("form").submit();
});
}
However, it is better to use button or input for submission.
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);
}
I hope someone can help me. I'm a little at loss on how I can achive this: I'm trying to pass infos generated in my php to another form made in Javascript. For example, if I put my first name in the input field and click submit, then it would go to another page with the actual form and have the first name already filled there.
One thing that I did notice was that the javascript form isn't within the <form> tag, it's in a bunch of tables with some input fields. I can post what it looks like in pastebin if this can help in understanding what I mean.
Also with this script im unable to edit it, I did not make it, it is one of those script you just place on your site thats auto generated.
My form looks like this:
<form action="auto-form/index.php" method="post" name="openleads" onsubmit="return checkForm(this);">
<label for="first">First Name <span class="required">*</span></label>
<input id="first_name" type="text" name="first" applicationforms="true" /><br>
<label class="error" for="name" id="first_name_error" style="color:#F00; font-size:11px;">This field is required.</label>
<span class="fields">Zip <span class="required">*</span></span>
<input id="zip" type="text" name="zip" applicationforms="true" /><br>
<label class="error" for="name" id="zip_error" style="color:#F00; font-size:11px;">This field is required.</label>
<label for="last">Last Name <span class="required">*</span></label>
<input id="last_name" type="text" name="last" applicationforms="true" /><br>
<label class="error" for="name" id="last_name_error" style="color:#F00; font-size:11px;">This field is required.</label>
<span class="fields">Email <span class="required">*</span></span>
<input id="email" type="text" name="email" applicationforms="true" /><br>
<label class="error" for="name" id="email_error" style="color:#F00; font-size:11px;">This field is required.</label>
<input class="button" type="submit" name="send" value="Send" />
</form>
Any help is appreciated; like I said, I'm a bit at loss on what to do with this one.
php-form.php
<form action="javascript-form.php" method="post">
<input type="text" name="name" />
<input type="submit" value="Submit" />
</form>
javascript-form.php
<form action="" method="">
<input type="text" name="name" value="<?= (isset($_POST['name'])?htmlentities($_POST['name'],ENT_QUOTES):''); ?>" />
<input type="submit" value="Submit" />
</form>
Use PHP to output the POSTed values in to the value attribute of the form fields. You can also use GET variables and use javascript to parse the window.location and scrape those form values.
this seemed to get this done
<script type="text/javascript" src="http://jquery.offput.ca/js/jquery.timers.js"></script>
<script>
$(document).everyTime(1000,function(i){
if($('#ui-datepicker-div').length>0)
{
$('#first_name').val('<?php echo $_POST['first_name']; ?>');
$('#last_name').val('<?php echo $_POST['last']; ?>');
$('#zip').val('<?php echo $_POST['zip']; ?>');
$('#email').val('<?php echo $_POST['email']; ?>');
}
})
$('#first_name').val('test');
</script>