mailchimp auto pre filled url encoding - php

how to pre fill my subscription forum with email.for example if some one want to enter his "email" and click "senden" button for subscription, his "Email" should already be there in my subscription forum. down is the urls from website(for embedded subscription forum), code of this embedded widget and subscription forum.
mail chimp subscription forum url: http://boooo.us7.list-manage.com/subscribe?u=2e01f07a729f6f76a41a34ca5&id=66efb8b1bb
website url: www.boooo.com
code:
<!-- Begin MailChimp Signup Form -->
<div id="mc_embed_signup">
<form action="//eepurl.com/-xxxx" method="post" id="mc-embedded-subscribe-form" name="mc-embedded-subscribe-form" class="validate" target="_blank" novalidate="">
<div id="mc_embed_signup_scroll">
<input type="email" value="" name="EMAIL" class="email" id="mce-EMAIL" placeholder=" E-Mail Adresse" required="" />
<!-- real people should not fill this in and expect good things - do not remove this or risk form bot signups-->
<div style="position: absolute; left: -5000px;">
<input type="text" name="xxxxxxxxxxxxxxxxxxxxx_xxxxxxxxxxxx" tabindex="-1" value="" />
</div>
<div class="clear">
<input type="submit" value="senden" name="senden" id="mc-embedded-subscribe" class="button" />
</div>
</div>
</form>
</div>
<!--End mc_embed_signup-->
Thanks for the help.

Sorry for not mentioning the code it was my first question and didn't notice to put 4 spaces for the code.
I solved it by adding "&email=value" in the last of my url.
<!-- Begin MailChimp Signup Form -->
<div id="mc_embed_signup">
<form action="http://boooo.us7.list-manage.com/subscribe?u=2e01f07a729f6f76a41a34ca5&id=66efb8b1bb&email=value" method="post" id="mc-embedded-subscribe-form" name=
"mc-embedded-subscribe-form" class="validate" target="_blank" novalidate="">
<div id="mc_embed_signup_scroll">
<input type="email" value="" name="EMAIL" class="email" id="mce-EMAIL" placeholder=" E-Mail Adresse" required="#" />
<!-- real people should not fill this in and expect good things - do not remove this or risk form bot signups-->
<div style="position: absolute; left: -5000px;">
<input type="text" name="e01f07a729f76a41a34ca5_66efb8" tabindex="-1" value="" />
</div>
<div class="clear">
<input type="submit" value="senden" name="senden" id="mc-embedded-subscribe" class="button" />
</div>
</div>
</form>
</div>
<!--End mc_embed_signup mce-EMAIL mc4wp_email //eepurl.com/-Mi4r
-->

You can use the $_POST variable on your backend form for this.
The first form:
<form action="subscription.php" method="post">
<input type="text" name="first_email">
<input type="submit">
</form>
The subscription form:
<form action="mailchimp.php">
<input type="text" name="email" value="<?php echo $_POST['first_email']; ?>"
....
For more info:
http://php.net/manual/en/reserved.variables.post.php

If all you want to do is go to that mailchimp signup page and prefill the email, this link seems to work:
https://boooo.us7.list-manage.com/subscribe?u=2e01f07a729f6f76a41a34ca5&id=66efb8b1bb&MERGE0=foobar#foobar.com
If you need a form, try
<!-- Mailchimp Signup Form -->
<form
action="https://boooo.us7.list-manage.com/subscribe?u=2e01f07a729f6f76a41a34ca5&id=66efb8b1bb"
method="post" target="_blank">
<input type="email" name="MERGE0" placeholder="Your e-mail">
<input type="submit" value="Subscribe">
</form>
<!--End Mailchimp Signup Form -->

Related

Run PHP script and also submit form to URL

I have a HTML registration form, that adds users to the content management system using PHP. I need to integrate this into my a Customer Relationship Management tool (AgileCRM).
This code here will allow a user to register, which will submit the form and create the user using PHP.
<?php
if ($input->post->submit) {
//create user
}
?>
<form action='./' accept-charset='UTF-8' autocomplete='off' method='post'>
<input type='text' name='username' placeholder='Username'>
<input type='text' name='email' placeholder='Email'>
<input type='password' name='password' placeholder='Password'>
<button type='submit' name='submit' value='register'>Register</button>
</form>
Then this code will do what I want in the CRM
<link href="https://s3.amazonaws.com/agilecrm/forms/v1/agile-form-min.css" rel="stylesheet">
<form class="form-view " id="agile-form" action="https://agiledomain.agilecrm.com/formsubmit" style="max-width:450px;" method="post">
<fieldset>
<!-- Form Name -->
<legend class="agile-hide-formname">Registration Form</legend>
<p class="agile-form-description"></p>
<div style="display: none; height: 0px; width: 0px;">
<input type="hidden" id="_agile_form_name" name="_agile_form_name" value="Registration Form">
<input type="hidden" id="_agile_domain" name="_agile_domain" value="AGILECRMDOMAIN">
<input type="hidden" id="_agile_api" name="_agile_api" value="AGILECRMAPIKEY">
<input type="hidden" id="_agile_redirect_url" name="_agile_redirect_url" value="#">
<input type="hidden" id="_agile_document_url" name="_agile_document_url" value="">
<input type="hidden" id="_agile_confirmation_msg" name="_agile_confirmation_msg" value="Thank you for signing up!">
<input type="hidden" id="_agile_form_id_tags" name="tags" value="">
<input type="hidden" id="_agile_form_id" name="_agile_form_id" value="AGILECRMID">
</div>
<!-- Text input-->
<div class="agile-group required-control">
<label class="agile-label" for="username">Username<span class="agile-span-asterisk"> *</span></label>
<div class="agile-field-xlarge agile-field">
<input maxlength="250" id="username" name="Username" type="text" placeholder="" class="agile-height-default" required="">
</div>
<div class="agile-custom-clear"></div>
</div>
<!-- Text input-->
<div class="agile-group required-control">
<label class="agile-label" for="email">Email<span class="agile-span-asterisk"> *</span></label>
<div class="agile-field-xlarge agile-field">
<input maxlength="250" id="email" name="email" type="email" placeholder="" class="agile-height-default" required="">
</div>
<div class="agile-custom-clear"></div>
</div>
<!-- Password input-->
<div class="agile-group required-control">
<label class="agile-label" for="password">Password Input<span class="agile-span-asterisk"> *</span></label>
<div class="agile-field-xlarge agile-field">
<input maxlength="250" id="password" name="password" type="password" placeholder="" class="agile-height-default" required="">
</div>
<div class="agile-custom-clear"></div>
</div>
<!--recaptcha aglignment-->
<!-- Button -->
<div class="agile-group">
<label class="agile-label"> </label>
<div class="agile-field agile-button-field">
<button type="submit" class="agile-button">Submit</button>
<br><span id="agile-error-msg"></span>
</div>
</div>
</fieldset>
</form>
<script type="text/javascript">
(function(a){var b=a.onload,p=true;isCaptcha=false;if(p){a.onload="function"!=typeof b?function(){try{_agile_load_form_fields()}catch(a){}}:function(){b();try{_agile_load_form_fields()}catch(a){}}};var formLen=document.forms.length;for(i=0;i<formLen;i++){if(document.forms.item(i).getAttribute("id")== "agile-form"){a.document.forms.item(i).onsubmit=function(a){a.preventDefault();try{_agile_synch_form_v5(this)}catch(b){this.submit()}}}}})(window);
</script>
So basically I'd like to join the functionality of these two forms together, so submit the form to AgileCRM and also run the PHP code.
You can do this with jQuery ajax
and give your first form an id then it will be submitted after agile form.
$('#agile-form').submit(function(){
// show that something is loading
$('#response').html("<b>Loading response...</b>");
/*
* 'post_receiver.php' - where you will pass the form data
* $(this).serialize() - to easily read form data
* function(data){... - data contains the response from post_receiver.php
*/
$.ajax({
type :'POST',
url : "https://agiledomain.agilecrm.com/formsubmit",
async: false,
data: $(this).serialize()
})
.done(function(data){
//give your first form an id and submit it for eg:firsForm
$('#firstForm').submit();
})
.fail(function() {
// just in case posting your form failed
alert( "Posting failed." );
});
// to prevent refreshing the whole page page
return false;
});

two javascript forms on one page

I cant get the two forms to play with each other.. - meaning I have one form that sends an email - and another that is using a search function. The email form is working ok. Validates just fine, but when I click on the search button, it doesn't do anything. ( the search form is working fine if I remove the email form )
What am I missing ??.. ugh..
I've been working on this, but my brain is fried. I am sure it is something simple.
Any help from you guys would be much appreciated.
<form method="post" action="contact.php" name="contactform" id="contactform">
<div class="full-lenght">
<div class="to-left">Name<br>
<span class="small-required">Required</span> </div>
<div class="to-right">
<input name="name" type="text" id="name" value="" class="contact-field" />
</div>
</div>
<div class="clear"></div>
<div class="full-lenght">
<div class="to-left">Email<br>
<span class="small-required">Required</span> </div>
<div class="to-right">
<input name="email" type="text" id="email" value="" class="contact-field" />
</div>
</div>
<div class="clear"></div>
<div class="full-lenght">
<div class="to-left">Phone<br>
<span class="small-required">Required</span> </div>
<div class="to-right">
<input name="phone" type="text" id="phone" value="" class="contact-field" />
</div>
</div>
<div class="clear"></div>
<div class="full-lenght">
<div class="to-left">Message<br>
<span class="small-required">Required</span> </div>
<div class="to-right">
<textarea name="comments" rows="3" id="comments" class="contact-message"></textarea>
</div>
</div>
<div class="clear"></div>
<div class="clear"></div>
<div class="human">3 + 1 = ?<br>
<input name="verify" type="text" id="verify" size="4" value="" style="width: 30px;" />
<input name="e" type="submit" class="contact-button" id="submit" value="Submit" />
</div>
</form>
<div class="search">
<form class="form" action="search_results.php" method="get">
<input name="q" type="text" class="search_field" value="Search.." onfocus="if (this.value=='Search..') this.value='';">
<a onclick=" document.forms[0].submit();return false" href="#"><img class="search_button" title="Search Button" src="images/search_button.jpg" alt="" width="24" height="24"></a> <br>
<br>
</form>
</div>
This is the code. The second form starts in search div. The first one is an email form with ajax validation.
try this,
in the second form
<form class="form" id="searchform" action="search_results.php" method="get">
<input name="q" type="text" class="search_field" value="Search.." onfocus="if (this.value=='Search..') this.value='';" />
<a onclick=" document.getElementById('searchform').submit();return false" href="#"><img class="search_button" title="Search Button" src="images/search_button.jpg" alt="" width="24" height="24"/></a> <br/>
<br/>
</form>
This doesn't have anything to do with PHP, but does have everything to do with JavaScript.
Change:
<a onclick=" document.forms[0].submit();return false" href="#">
to:
<a onclick="document.forms[1].submit();" href="#">
You're using legacy DOM notation in your JavaScript, which is OK but outdated. When you have forms[0] you're referring to the first form in the DOM which isn't the search form (the contact form is), forms[1] is the search form. Clicking the icon will fail without the change, but you could type in the box and hit enter and it will work, since the JavaScript you have won't be triggered (no click). I also see no need to keep the return false statement in there.
<form class="form" action="search_results.php" method="get">
<input name="q" type="text" class="search_field" value="Search.." onfocus="if (this.value=='Search..') this.value='';">
<input type="submit" value='Search'> <br>
<br>
This problem you used anchor tag as button form and it doesn't work for submitting form so you can either replace anchor tag with input tag "submit type" as you see in code or you can use JavaScript to make anchor tag when you click on it, it fires a submitting form.
Enjoy :)

How To Make My HTML5 Form Refresh On Its Own?

I have a contact form on my website, and once you click submit button, an echo message comes up but on a new page.
I want the page to automatically refresh when someone clicks submit, but also along with the echo message.
This is the HTML5 Code:
<form method="post" id="form" action="send3.php" class="sendmail" onsubmit="return validateForm()" style="text-align:center;">
<!-- Form Name -->
<center><h2 class="">Contact Us</h2>
</div>
<center><label class="control-label">Your Email Address</label>
<center><input type="text" id="eadd" name="eadd" class="input-xlarge" required>
<center><label class="control-label">Topic of Message</label>
<center><input type="text" id="top" name="top" class="input-xlarge" required>
<center><label class="control-label">Message</label>
<center><textarea id="mess" name="mess" required></textarea>
<Br>
<!-- Button -->
<label class="control-label"></label>
<div class="controls">
<center><input class="btn btn-primary" type="submit">
</div>
</form>
Any Tips/Adivce would be very much appreciated!
Sound like this is what you are looking for...
[myContactPage.php]
if ($_SERVER['REQUEST_METHOD'] == 'POST') //Here you could check other items like referrer or some of your posted fields if you want
{
//do whatever your current send3.php does
//echo the result back out
}
<form method="post" id="myForm" action="myContactPage.php" onsubmit="return validateForm()">
[email field]
[name field]
[message field]
etc...
[submit button]
</form>

How to return php code into html body

I am building a simple form script that collects a users email and returns a PIN.
The input sits in standard HTML below:
<p>
<form class="form-inline" role="form" method="POST">
<div class="form-group">
<label class="sr-only" for="srEmail">Email address</label>
<input type="email" name="srEmail" class="form-control input-lg" id="srEmail" placeholder="Enter email">
</div>
<button type="submit" name="srSubmit" class="btn btn-default btn-lg">Generate PIN</button>
</form>
</p>
I have the following if statement that checks the database to see if the email already exists, and if the user would like a PIN reminder.
if($num_rows != 0) {//if email found in table
?>
Email already registered, would you like a PIN reminder?
<form method="POST" action="">
<input type="submit" name="srSend" value="Click here to get pin reminder" />
<input type="hidden" name="srEmail" value="<?php echo strtolower($email);?>" />
</form>
<?php
exit;
}
At the moment, this returns the result to the user as a new page; how do I put this in the actual HTML of the body page, so it would actually appear below the original form input in a new <p> element?
This is a piece of cake with jquery.post
include the jquery library in your html head and you'll need a short script to get the php content by ajax
<head>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script>
$(function(){
$('#yourForm').submit(function(e){
e.preventDefault();
var data=$('#yourForm').serialize();
$.post('yourphp.php',data,function(html){
$(body).append(html);
});
});
});
</script>
</head>
<body>
<p>
<form id="yourForm" class="form-inline" role="form" method="POST">
<div class="form-group">
<label class="sr-only" for="srEmail">Email address</label>
<input type="email" name="srEmail" class="form-control input-lg" id="srEmail" placeholder="Enter email">
</div>
<button type="submit" name="srSubmit" class="btn btn-default btn-lg">Generate PIN</button>
</form>
</p>
</body>
You could able to achieve that without ajax too. Simply use a hidden iframe in your main page, then set the target attribute of your form to the iframe as follows:
<form method="post" action="page.php" target="myIframe">
.....
</form>
<p id="theResultP"></p>
<iframe src="#" name="myIframe" style="visibility: hidden"></iframe>
The question now, How could you make the page loaded in the iframe "page.php" to interact with the opener page to update the p. This may be done as follow:
//page.php
<script>
result = parent.document.getElementById('theResultP');
result.innerHtml = "<b>The message you want</b>"
</script>
I dont know if I get what you asking for,but this is my solution :
<p>
<form class="form-inline" role="form" method="POST">
<div class="form-group">
<label class="sr-only" for="srEmail">Email address</label>
<input type="email" name="srEmail" class="form-control input-lg" id="srEmail" placeholder="Enter email">
</div>
<button type="submit" name="srSubmit" class="btn btn-default btn-lg">Generate PIN</button>
</form>
</p>
<?php
if (isset($message)){
<p><?php print $message ?></p>
?>
<?php
}
?>
and in top of your file write something like this :
<?php
if($_post['srSend']){
$message='write your message here';
}
?>

Using "action" in Twitter Boostrap classes

I'm a newbie programmer trying to utilize Twitter Bootstrap to build out a concept. I'm using PHP and assigning actions within HTML tags to POST data and essentially take a user through the navigation. This has been pretty straightforward when using forms: i.e. here is a snippet that does work. For example, for this snippet of HTML:
<form action="?viewnotes" method="post">
<input type="hidden" name="id" value="<?php htmlout($note['id']); ?>">
</form>
It successfully triggers the following if statement in my index.php:
if (isset($_GET['viewnotes']))
However, I'm trying to do the same thing in my registration page, using a Twitter Bootstrap class for buttons. Here is the HTML:
<a class="btn btn-primary btn-large" action="?register">Sign Up Free!ยป</a></p>
The PHP code is:
if (isset($_GET['register']))
{
include 'register.html.php';
}
Clicking on the Sign Up button is not invoking the PHP code. If I hard code the URL it works, but then I have a similar issue on the register.html.php page. HTML on the register page has:
<form class="form-horizontal" action="?storeuser" method="post">
<fieldset>
<legend>It's quick and easy...</legend>
<div class="control-group">
<label class="control-label">First Name</label>
<div class="controls">
<input type="text" name="fname" class="input-xlarge" id="fname">
</div>
</div>
<div class="control-group">
<label class="control-label" name="lname">Last Name</label>
<div class="controls">
<input type="text" name="lname" class="input-xlarge" id="lname">
</div>
</div>
<div class="control-group">
<label class="control-label" name="email">Email Address</label>
<div class="controls">
<input type="text" name="email" class="input-xlarge" id="email">
</div>
</div>
<div class="control-group">
<label class="control-label" name="password">Password</label>
<div class="controls">
<input type="password" name="password" class="input-xlarge" id="password">
</div>
</div>
</fieldset>
<button type="submit" name="action" class="btn btn-primary btn-large">Complete Registration</button>
</form>
However, when clicking on the button, the index file does not trigger the following, which would store the fields into the DB.
if (isset($_GET['storeuser']))
If I hardcode the URL to register.html.php, then the resulting URL looks like localhost/register.html.php?storeuser instead of localhost/?storeuser. I'm not sure if that's affecting the behavior here.
Thank you for the help!
I think you're approaching this the wrong way, and it's not Twitter Bootstrap's fault.
Usually, you'd use POST, not GET, to handle user registrations. Your form would look like this:
<form action="register.php" method="post">
<!-- your form -->
<fieldset>
<input type="submit" name="register" value="Register" class="btn btn-primary" />
</fieldset>
</form>
You can then build register.php as follows:
<?php
if (isset($_POST['register'])) {
// handle user registration
}
// display form
?>
This will display the form when the user visits register.php, but will try and process the user registration first if the form's been POSTed.
try passing a value with your GET variable
<form action="?viewnotes=1" method="post">

Categories