How do I get this Newletter Form to work? - forms

I'm not sure what to put in for href:\ Should I reference a mailhandler.php or use a mailto: command? Or is there something better?
<h3 class="margin-bot">Newsletter!</h3>
<form id="subscribe-form" name="sibscribe" method="post">
<label><input class="subscribetext" type="text" onFocus="if(this.value =='Enter E-mail:' ) this.value=''" onBlur="if(this.value=='') this.value='Enter E-mail:'" value="Enter E-mail:" name="keyword" /></label>
<a onClick="document.getElementById('subscribe-form').submit()" class="button" href="#">subscribe</a>
</form>

I think it is meant for the site to which you get after pressing the subscribe button. Preferably the page the form was implemented in (for example to return to the index.html).
You can try it by testing it here on jsfiddle (http://jsfiddle.net). Just put an URL in the field where now is the # and after pressing subscribe you will see that you'll be redirected to that page.

Related

I can't figure out how to add the <form> tag

I have a simple search box where the user is required to click the Submit button to send the address to some PHP/AJAX to query our SQL db. It does this by using the 'main-search' id of the Submit input.
<div class="address-search">
<input type='text' class='main-search-address' id="main-search-address" placeholder="Enter Street Address">in Seattle, WA
<input value="Search" type="submit" class="submit" id='main-search'>
</div>
I'd like to enable the user to be able to submit this form using the 'Enter' key, but when I wrap the inputs in a form tag, it submits, but no results show up. I've tried adding the id='main-search' to the form tag, which seems to get me closer, but instantly submits the form upon clicking in the text input.
Any help?
Thank you.
Try change:
<input value="Search" type="submit" class="submit" id='main-search'>
for:
<button type="submit" class="submit" id='main-search'> Search </button>
If nothing is displayed, you're probably wrong in your AJAX. Remember, AJAX needs a "id destiny".

Submit button for my contact form is not submitting and redirecting

I'm working on my second website and throughout creating this one and my first the people here on StackOverflow have been an amazing help.
I can just browse and find almost anything I wan't to know.
99% of problems I've had, I fixed with answers I've read on here.
So first of thank you all so much!
This is the first time I'm posting something because I'm not able to find the specific answer for my code.
There are people one here with the same problems but when I look at their code I'm just lost.
I know html a fair bit by now. It's the php that I'm clueless about.
I'm not looking for something fancy, I'm just trying to create a simple contact form.
So here is my question and code, I hope some of you are able to help me.
I used an PHP code from a youtube tutorial and it's deadeasy (as said before: first time PHP) yet I can't get it to work. Although I'm doing everything the same as the man in the clip. He shows his is working so I'm extremely curious as to way mine is not?
My form does not 'send' and after clicking the submit button I don't get the 'thank you' line.
here is the html:
<form method="post" action="contactform" name="contactform" id="contactform">
<ol>
<li>
<label for="voornaam">Voornaam</label>
<input type="text" name="voornaam" />
</li>
<li>
<label for="achternaam">Achternaam</label>
<input type="text" name="achternaam" />
</li>
<li>
<label for="telefoon">Telefoon Nummer</label>
<input type="text" name="telefoon" />
</li>
<li>
<label for="email">E-mail Adres</label>
<input type="text" name="email" />
</li>
<li>
<label for="bericht">Type hier je bericht</label>
<textarea name="bericht"></textarea>
</li>
<li>
<input name="submit" type="submit" value="submit" />
<input name="reset" type="reset" value="reset" />
</li>
</ol>
</form>
and the PHP:
<?php
$voornaam = $_POST ['voornaam'];
$achternaam = $_POST ['achternaam'];
$telefoon = $_POST ['telefoon'];
$email = $_POST ['email'];
$bericht = $_POST ['bericht'];
$to = "felicevancuyk#gmail.com";
$subject = "dkl groep bericht";
mail ($to, $subject, $bericht, "From " . $voornaam . $achternaam . $telefoon};
echo "Bedankt. We nemen zo snel mogelijk contact met u op.";
?>
It could be that your action is not set correctly:
<form method="post" action="contactform" name="contactform" id="contactform">
This action tag is the URL that the form is sent to. In the above example you gave, it doesn't appear to be a file name. You want it to be something like this:
<form method="post" action="http://mysite.com/process-form.php" name="contactform" id="contactform">
Also note that in your example PHP code you are emailing responses to the form without cleaning those responses. Someone could send malicious code to your server if you don't clean the data first.
Something like:
$cleaned_voornaam = preg_replace("/[^ 0-9a-zA-Z]/", "_", $_POST['voornaam']);
Good luck!
You have to just change your action attribute of first line of code to the page where you want to process your form. It may be the same page but it is recommend to be on another page. Here is an example to submit the form in the same page:
<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>" name="contactform" id="contactform">
Don't forget if you are submitting on the same page as like the above example then your page should be in .php extension otherwise it will not work.
Another case for submit not submitting is that html is malformed.
Just happened that my code was inserting a php error in the middle of my html form.
fixed the error, the submit is working again.
In my case, no js involved at all

Can you tell me how to find out where form info goes?

Thank you for taking a look at my post. I have this newsletter form and it appears to be working fine, but I don't know where the information goes!
<form id="subscribe-form" name="sibscribe" method="post">
<label>
<input class="subscribetext" type="text" onFocus="if(this.value =='Enter E-mail:' ) this.value=''" onBlur="if(this.value=='') this.value='Enter E-mail:'" value="Enter E-mail:" name="keyword" />
</label>
<a onClick="document.getElementById('subscribe-form').submit()" class="button" href="Thank You.html">subscribe</a>
</form>
The best way to figure out for you is to go to Firebug Net bug while the page/form submits and inspect the tabs like:
Params| Headers|Responses|XML|Cookies

Tumblr: Search returning no search results

I'm new to tumblr and am trying to implement Search in a custom theme. I have:
<form action="/search" method="get" id="search-form">
<input type="text" name="q" class="query" value="" />
<input type="submit" value="Search" class="submit" />
<div class="clear"></div>
</form>
I have about a dozen posts. Whenever I search for anything in any post, Tumblr always returns no search results. I feel like I'm missing something. Am I to implement or set any configuration anywhere else in the theme? What else is needed to implement search in a user's Tumblr theme?
Thanks!
Here's the solution I use. Put this into the <head> of your code:
<script type="text/javascript">
<!--
function handleThis(formElm)
{
window.location="/tagged/"+formElm.number.value+"";
return false;
}
-->
</script>
And place this where you want the search box to appear:
<form onsubmit="return handleThis(this)">
<div class="submit"><input type="submit" value="{lang:Search}" name="Submit"/></div>
<div class="input"><input onfocus="this.value=''" onblur="if(this.value=='') this.value='Search. Then hit enter.';" type="text" value="{lang:Search}. Then hit enter." name="number"/></div>
</form>
Use CSS to style as you wish. This will search your tags only, but unlike the regular Tumblr search it works.
I was getting no results when my blog was password protected. I removed the password protection from Tumblr Dashboard > settings > blog name > password and it started returning results again.

PHPSESSID appears in form arbitrarily

I have a login form written in PHP and each time I start the browser and go to the respective page, the first field of the form is this:
<input type="hidden" name="PHPSESSID" value="session_id_code" />
If I close the window, but I don't restart the browser, this doesn't happen. Any idea what's happening and why?
Thanks!
Form's code:
<?php
if (condition) {
?>
<form method="post" action="">
<dl>
<dt>Email:</dt>
<dd><input type="text" name="useremail" /></dd>
<dt>Password:</dt>
<dd>
<input type="password" name="userpass" /></dd>
<dt class="dt-buttons"><input type="submit" name="button_login" value="Login" class="button" /></dt>
</dl>
<input type="hidden" name="formkey" id="formkey" value="224ca00155w2fcda8906e1e40af03a71" />
</form>
<?php
}
?>
The form is simple HTML and is not dynamically generated.
EDIT2:
As I was saying, when I access the page for the first time after I started the browser, this thing happens. If I refresh the page afterwards, the hidden field doesn't show up.
Is it possible to have something to do with the SSL certificate? And if yes, why some pages/forms behave like this and some don't?
Sounds like you've got trans_sid enabled (transparent session id). Using trans_sid can be a security issue, especially if your site links to external content, or you allow link sharing - it lets a user's session ID leak out as part of the URL, meaning the session is highly vulnerable to hijacking.