I find https://formspree.io/ really good and easy to use since I can edit my form as much as I like without having to touch a single line of php to process it.
Here´s my form.
<form action="//formspree.io/my#email.here" method="POST">
<div class="row uniform">
<div class="6u 12u$(large) 6u(medium) 12u$(xsmall)">
<label for="namn">Namn</label>
<input type="text" name="namn" id="namn" required/>
</div>
<div class="6u$ 12u$(large) 6u$(medium) 12u$(xsmall)">
<label for="epost">Epost</label>
<input type="email" name="_replyto" id="epost" required/>
</div>
<div class="12u$">
<label for="meddelande">Meddelande</label>
<textarea name="meddelande" id="meddelande" rows="5" required></textarea>
</div>
<div class="6u 12u$(large) 6u(medium) 12u$(xsmall)">
<input type="checkbox" id="prenumerera" name="prenumerera">
<label for="prenumerera">Prenumerera på mitt nyhetsbrev</label>
</div>
<div class="6u 12u$(large) 6u(medium) 12u$(xsmall)">
<div class="g-recaptcha" data-sitekey="public_site_key"></div>
</div>
<input type="hidden" name="_next" value="<?php echo $ROOT; ?>./tack.php" />
<input type="hidden" name="_subject" value="Kontakt!" />
<input type="text" name="_gotcha" style="display:none" />
<div class="12u$">
<ul class="actions">
<li><input type="submit" value="Skicka" class="special" /></li>
<li><input type="reset" value="Rensa" /></li>
</ul>
</div>
</div>
</form>
So.. How can I verify the input from reCaptcha when I don't have to process the form through php?
Thank you!
Formspree now redirects all form submissions to a reCaptcha page before finishing the submission. So there's no need to use the _gotcha anymore unless you pay for Gold level and don't want the reCaptcha functionality.
For more see https://formspree.io/
Captcha is not supported by formspree.
What you can do (and what you have done) is add a _gotcha hidden input, so spammer will likely fill it.
If you want a catpcha, you may want to process the form by yourself.
Related
I have a problem.. I tried today a lot to make this working but it seems to be impossible for me.. so I decided to ask help here. So I have a form which needs to be added on database table when submit button is pressed.
This is php code I currently use.. I removed my tries btw:
<?php
$pdo = new PDO('mysql:host=;dbname=', '', '');
$sql = "SELECT * FROM games LIMIT 10";
foreach ($pdo->query($sql) as $row) {
?>
my HTML code (form):
<form class="form-group" method="POST" action="">
<div role="tabpanel" class="tab-pane active" id="home">
<div class="form-group" style="margin-top: 15px;">
<label for="exampleInputEmail1">Game Title</label>
<input type="text" class="form-control" id="exampleInputEmail1" placeholder="" name="gtitle" />
</div>
<div class="form-group">
<label for="exampleInputPassword1">YouTube Link</label>
<input type="text" class="form-control" id="exampleInputPassword1" placeholder="" name="ytlink" />
</div>
<div class="form-group">
<label for="exampleInputPassword1">Link Source</label>
<input type="text" class="form-control" id="exampleInputPassword1" placeholder="ex: GLEAM, DLH, FAILMID, HRKGAME, INDIEGALA, OTHER, STEAM" name="slink" />
</div>
<div class="form-group">
<label for="exampleInputPassword1">Link to Free Steam Keys</label>
<input type="text" class="form-control" id="exampleInputPassword1" placeholder="KEY MUST GIVE +1 TO THE STEAM LIBRARY GAME COUNT" name="keysl" />
</div>
<label for="exampleInputPassword1">Steam App ID</label>
<div class="input-group" style="padding-bottom: 10px;">
<span class="input-group-addon" id="basic-addon3">http://store.steampowered.com/app/</span>
<input type="text" class="form-control" id="basic-url" aria-describedby="basic-addon3" placeholder="App ID" name="appid" />
</div>
<div class="form-group">
<label for="exampleInputPassword1">Categories</label>
<div class="checkbox">
<label class="radio-inline">
<input type="radio" name="inlineRadioOptions" id="inlineRadio1" value="option1" /> 1
<h4><span class="label label-success">Keys Available</span></h4>
</label>
<label class="radio-inline">
<input type="radio" name="inlineRadioOptions" id="inlineRadio2" value="option2" /> 2
<h4><span class="label label-danger">No Keys left</span></h4>
</label>
</div>
<button type="submit" class="btn btn-default" name="insert">Submit</button>
</div>
</div>
</form>
Thank those who help me.
Try this and in the radio button put value as '1' and '2' instead of 'option1' and 'option2'
if(isset($_POST['insert']))
{
$game_title=$_POST['gtitle'];
$youtube_link=$_POST['ytlink'];
$link_source=$_POST['slink'];
$link_steam_keys=$_POST['keysl'];
$app_id=$_POST['appid'];
$categories=$_POST['inlineRadioOptions'];
$query_ins="INSERT INTO tbl_game(game_title,youtube_link,link_source,link_steam_keys,app_id,categories) VALUES(:game_title,:youtube_link,:link_source,:link_steam_keys,:app_id,:categories)";
$stmt_query=$dbh->prepare($query_ins);
$games_ins=$stmt_query->execute(array(":game_title"=>$game_title,":youtube_link"=>$youtube_link,":link_source"=>$link_source,":link_steam_keys"=>$link_steam_keys,":app_id"=>$app_id,":categories"=>$categories));
if(!$games_ins)
{
$error=$stmt_query->errorInfo();
echo $error['2'];
}
}
You need to check the POST variables after submitting in your PHP code. If the form is submitted, take the post values and just run an INSERT query.
See $_POST
I find https://formspree.io/ really good and easy to use since I can edit my form as much as I like without having to touch a single line of php to process it.
Here´s my form.
<form action="//formspree.io/my#email.here" method="POST">
<div class="row uniform">
<div class="6u 12u$(large) 6u(medium) 12u$(xsmall)">
<label for="namn">Namn</label>
<input type="text" name="namn" id="namn" required/>
</div>
<div class="6u$ 12u$(large) 6u$(medium) 12u$(xsmall)">
<label for="epost">Epost</label>
<input type="email" name="_replyto" id="epost" required/>
</div>
<div class="12u$">
<label for="meddelande">Meddelande</label>
<textarea name="meddelande" id="meddelande" rows="5" required></textarea>
</div>
<div class="6u 12u$(large) 6u(medium) 12u$(xsmall)">
<input type="checkbox" id="prenumerera" name="prenumerera">
<label for="prenumerera">Prenumerera på mitt nyhetsbrev</label>
</div>
<div class="6u 12u$(large) 6u(medium) 12u$(xsmall)">
<div class="g-recaptcha" data-sitekey="public_site_key"></div>
</div>
<input type="hidden" name="_next" value="<?php echo $ROOT; ?>./tack.php" />
<input type="hidden" name="_subject" value="Kontakt!" />
<input type="text" name="_gotcha" style="display:none" />
<div class="12u$">
<ul class="actions">
<li><input type="submit" value="Skicka" class="special" /></li>
<li><input type="reset" value="Rensa" /></li>
</ul>
</div>
</div>
</form>
So.. How can I verify the input from reCaptcha when I don't have to process the form through php?
Thank you!
Formspree now redirects all form submissions to a reCaptcha page before finishing the submission. So there's no need to use the _gotcha anymore unless you pay for Gold level and don't want the reCaptcha functionality.
For more see https://formspree.io/
Captcha is not supported by formspree.
What you can do (and what you have done) is add a _gotcha hidden input, so spammer will likely fill it.
If you want a catpcha, you may want to process the form by yourself.
I'm trying to submit data to a list in my mail chimp but also allow the user to upload a file.
Here is my code, the first chunk is the mailchimp autogenerated form which is submitted via:
<div class="clear"><input type="submit" value="Subscribe" name="subscribe" id="mc-embedded-subscribe" class="button"></div>
and then it's followed by the basic code to submit a file. But at the moment both functions have a submit button. I want only one. Can anyone help?
<body>
<!-- Begin MailChimp Signup Form -->
<div id="mc_embed_signup">
<form action="http://test.us7.list-manage.com/subscribe/post?u=d12b70d4bb1e08c1568d5b392&id=bfb41cbf75" method="post" id="mc-embedded-subscribe-form" name="mc-embedded-subscribe-form" class="validate" target="_blank" novalidate>
<h2>Subscribe to our test mailing list</h2>
<div class="indicates-required">
<span class="asterisk">*</span> indicates required
</div>
<div class="mc-field-group">
<label for="mce-EMAIL">
Email Address <span class="asterisk">*</span>
</label>
<input type="email" value="" name="EMAIL" class="required email" id="mce-EMAIL">
</div>
<div class="mc-field-group">
<label for="mce-FNAME">First Name </label>
<input type="text" value="" name="FNAME" class="" id="mce-FNAME">
</div>
<div class="mc-field-group">
<label for="mce-LNAME">Last Name </label>
<input type="text" value="" name="LNAME" class="" id="mce-LNAME">
</div>
<div class="mc-field-group input-group">
<strong>Interests </strong>
<ul>
<li><input type="checkbox" value="1" name="group[5597][1]" id="mce-group[5597]-5597-0"><label for="mce-group[5597]-5597-0">Interest 1</label></li>
<li><input type="checkbox" value="2" name="group[5597][2]" id="mce-group[5597]-5597-1"> <label for="mce-group[5597]-5597-1">Interest 2</label></li>
<li><input type="checkbox" value="4" name="group[5597][4]" id="mce-group[5597]-5597-2"><label for="mce-group[5597]-5597-2">Interest 3</label></li>
</ul>
</div>
<div id="mce-responses" class="clear">
<div class="response" id="mce-error-response" style="display:none"></div>
<div class="response" id="mce-success-response" style="display:none"></div>
</div>
</div>
<form action="upload_file.php" method="post" enctype="multipart/form-data">
<label for="file">Filename:</label>
<input type="file" name="file" id="file"><br>
<input type="submit" name="submit" value="Submit">
<div class="clear">
<input type="submit" value="Subscribe" name="subscribe" id="mc-embedded-subscribe" class="button">
</div>
</form>
</form>
</body>
You could accomplish this by routing the MailChimp information through your upload_file.php file.
MailChimp has a great API that you can use for more than just adding a subscriber to a list. You would specifically want the listSubscribe() function. There are some great examples on that page.
Here's more documentation on MailChimp's API: http://apidocs.mailchimp.com/api/2.0/
So in your HTML, you would want to remove the second submit button and make it one form with action="upload_file.php". The PHP file would upload the file, then use the API to submit the data to MailChimp.
You html should look like this:
<body>
<!-- Begin MailChimp Signup Form -->
<div id="mc_embed_signup">
<form action="upload_file.php" method="post" enctype="multipart/form-data">
<h2>Subscribe to our test mailing list</h2>
<div class="indicates-required">
<span class="asterisk">*</span> indicates required
</div>
<div class="mc-field-group">
<label for="mce-EMAIL">
Email Address <span class="asterisk">*</span>
</label>
<input type="email" value="" name="EMAIL" class="required email" id="mce-EMAIL">
</div>
<div class="mc-field-group">
<label for="mce-FNAME">First Name </label>
<input type="text" value="" name="FNAME" class="" id="mce-FNAME">
</div>
<div class="mc-field-group">
<label for="mce-LNAME">Last Name </label>
<input type="text" value="" name="LNAME" class="" id="mce-LNAME">
</div>
<div class="mc-field-group input-group">
<strong>Interests </strong>
<ul>
<li><input type="checkbox" value="1" name="group[5597][1]" id="mce-group[5597]-5597-0"><label for="mce-group[5597]-5597-0">Interest 1</label></li>
<li><input type="checkbox" value="2" name="group[5597][2]" id="mce-group[5597]-5597-1"> <label for="mce-group[5597]-5597-1">Interest 2</label></li>
<li><input type="checkbox" value="4" name="group[5597][4]" id="mce-group[5597]-5597-2"><label for="mce-group[5597]-5597-2">Interest 3</label></li>
</ul>
</div>
<div id="mce-responses" class="clear">
<div class="response" id="mce-error-response" style="display:none"></div>
<div class="response" id="mce-success-response" style="display:none"></div>
</div>
</div>
<label for="file">Filename:</label>
<input type="file" name="file" id="file"><br>
<div class="clear">
<input type="submit" value="Subscribe" name="subscribe" id="mc-embedded-subscribe" class="button">
</div>
</body>
I'm quite new to php and I've been struggling for a time now with uploading through a form and an iframe(To imitate ajax) while also including more data than just the file itself(In my case, a string representing a date).
I tried searching for similar examples but could only find examples where they uploaded only the file which is already working correctly.
The form is similar to this(using bootstrap):
<form id="upload_pic_form" class="form-horizontal" action="upload_picture.php"
target="upload_target" method="post" enctype="multipart/form-data">
<div id="form_content_wrapper">
<div class="control-group">
<label class="control-label">Display from</label>
<div class="controls">
<div class="input-append date" id="dpFrom" data-date-format="yyyy-mm-dd">
<input id="picFrom" class="span2" size="16" type="text" readonly>
<span class="add-on"><i class="icon-th"></i></span>
</div>
</div>
</div>
<div class="control-group">
<label class="control-label">Display until</label>
<div class="controls">
<div class="input-append date" id="dpTo" data-date-format="yyyy-mm-dd">
<input id="picTo" class="span2" size="16" type="text" readonly>
<span class="add-on"><i class="icon-th"></i></span>
</div>
</div>
</div>
<div class="control-group">
<label class="control-label">Image</label>
<div class="controls">
<input id="filename" type="text" class="input disabled" name="filename" readonly>
<label class="btn" for="pic_file_input">Choose image...</label>
<input id="pic_file_input" type="file" name="file" accept="image/*" style="display: none;"/>
</div>
</div>
<div class="form-actions">
<button type="submit" name="submit" id="submit_btn" class="btn btn-primary">Upload</button>
</div>
</div>
So now in upload_picture.php, I can get the file and all it's info by using $_FILES.
But how can I get the value of input "picFrom"?
I've tried using $_POST['picFrom'] but it gave me nothing.
Maybe I'm missing something super easy or being stupid, but please bear with me.
First be sure to close the form tag.
Then try adding name='picFrom' to the inputs(this is missing for each input element)
$_POST uses the name not the id.
I'm editing a site using Modx cms.
I'm trying to add a contact form to the contact page. I already have one in the sidebar specified in a template. The code on the contact page form points to the same div tags, but it isn't picking up any of the css.
any ideas why this is happening. Do I need some kind of plugin?
Thanks for all your help
Regards
Judi
<div class="enquiry-form-top">
<h2>Enquiry Form</h2>
</div>
<div class="enquiry-form">
<form class="enquiry" id="enquiry" action="mailer.php" method="post">
<fieldset>
<legend>Enquiry Form</legend>
<div class="form-field">
<label for="Name">Name:</label>
<input type="text" id="Name" name="Name" value="">
</div>
<input type="hidden" name="thankspage" value="thank-you.html">
<input type="hidden" name="subject" value="Enquiry Form">
<div class="form-field">
<label for="Address"> Address:</label>
<input type="text" id="Address" name="Address" value="">
<input type="text" id="Address2" name="Address2" value="">
<input type="text" id="Address3" name="Address3" value="">
</div>
<div class="form-field">
<label for="DOB">DOB:</label>
<input id="DOB" type="text" name="DOB" value="" />
</div>
<div class="form-field">
<label for="Total-Fund-Size">Total Fund Size:</label>
<input id="Total-Fund-Size" type="text" name="Total-Fund-Size" value="" />
</div>
<div class="form-field">
<label for="Number-Of-Funds">Number Of Funds:</label>
<input id="Number-Of-Funds" type="text" name="Number-Of-Funds" value="" />
</div>
<div class="form-field">
<label for="Lump-Sum-Benefit">Has Lump Sum <br/>Benefit Been Taken:</label>
<ul>
<li>Yes <input type="checkbox" name="Lump-Sum-Benefit" id="Lump-Sum-Benefit" value="Yes" /></li>
<li>No <input type="checkbox" name="Lump-Sum-Benefit" id="Lump-Sum-Benefit2" value="No" /></li>
</ul>
</div>
<div class="form-field">
<label for="Telephone-Number">Telephone Number:</label>
<input type="text" id="Telephone-Number" name="Telephone-Number" value="">
</div>
<div class="form-field">
<label for="Best-Time-To-Contact">Best Time To Contact:</label>
<input type="text" id="Best-Time-To-Contact" name="Best-Time-To-Contact" value="">
</div>
<div class="form-field">
<label for="Email">Email:</label>
<input type="text" id="Email" name="Email" value="">
</div>
<div class="form-field">
<img src="CaptchaSecurityImages.php" alt="">
<label for="security_code"> Security Code: </label>
<input type="text" id="security_code" name="security_code">
</div>
<div class="form-buttons">
<input type="image" name="Submit" value="Submit" src="images/annuity/submit_button.gif">
</div>
</fieldset>
</form>
There is no reason I can think of for this to happen, and you don't need any plug-ins.
Once the page is rendered it is of course just HTML and it doesn't matter if it was made in modx or any other system.
Can you investigate the page using Firebug and make sure the Stylesheet is loading?
Maybe the form that is working is enclosed in a div with a class and all the styles are set in the style sheet as follows (ie. Children of the containing div)
.enclosingdiv .form-field
That would explain why your form isn't picking up the styles.
Also you should check out eform (Package, wiki) it's great for simple contact forms.