html submit button not handling action .php - php

I'm trying to call a php file in a html form, as shown in my code, but the send button is not functioning, any ideas ?
<form id="contact-form" method="post" action="form_send.php">
<fieldset>
<label class="name">
<input type="text" value="Your Name" onFocus="if(this.value=='Your Name'){this.value=''}" onBlur="if(this.value==''){this.value='Your Name'}">
</label>
<label class="phone">
<input type="text" value="Telephone" onFocus="if(this.value=='Telephone'){this.value=''}" onBlur="if(this.value==''){this.value='Telephone'}">
</label>
<label class="email">
<input type="email" value="Email" onFocus="if(this.value=='Email'){this.value=''}" onBlur="if(this.value==''){this.value='Email'}">
</label>
<label class="message">
<textarea onFocus="if(this.value=='Message'){this.value=''}" onBlur="if(this.value==''){this.value='Message'}">Message</textarea>
</label>
<div class="btns"> <a class="button" onclick="clearFunction()" >Clear</a> <a class="button" type="submit" name="submit" value="Send Form" >Send</a> </div>
</fieldset>
</form>

you are use <a> tag to submit the form
replace <a class="button" type="submit" name="submit" value="Send Form" >Send</a> with <input class="button" type="submit" name="submit" value="Send Form" >

You are not naming any inputs in your form..
<input **name='name'** value='Your name'>
<input **name='phone'** value='Phone'>
and so on..
for proccessing:
if(isset($_POST['submit'])){
$name=$_POST['name'];
$phone=$_POST['phone'];
$xxx=$_POST['xxx'];
echo $name, $phone; //echoing data.
}
and so on.
Don't forget to sanitize your data before submitting..(ANTI-SQL INJECTION)
and instead of your OnBlur and OnFocus solution: placeholder='Your name'

Related

How to make a form disappear after submit in Wordpress plugin

I am building a WordPress plugin for my livechat. When someone downloads the plugin, I want them to fill out some information (name, e-mail, etc). After submitting that info, the form has to disappear/hide. For some reason I am not successful and imo I've tried everything. At the moment I'm trying to do it with an if-statement checking if the submit-button isset(). Unfortunately that didn't work.
Can someone please help me? The code for display the form and the page after submitting:
<?php
public function display_plugin_setup_page()
{
if (isset($_POST['submitForm'])) {
?>
<form action="options.php" method="post">
<?php
settings_fields('mister_chat_options');
do_settings_sections($this->plugin_name); ?>
<input name="submit" class="button button-primary" type="submit" value="<?php esc_attr_e('Save'); ?>" />
</form>
<?php
} else {
// create the form
?>
<form method="post" action="sendmail.php">
<input type="hidden" name="formSent">
<fieldset>
<input placeholder="Voornaam" type="text" id="vnaam" name="vnaam">
</fieldset>
<fieldset>
<input placeholder="Achternaam" type="text" id="anaam" name="anaam">
</fieldset>
<fieldset>
<input placeholder="Bedrijfsnaam" type="text" id="bnaam" name="bnaam">
</fieldset>
<fieldset>
<input placeholder="E-mailadres" type="email" id="email" name="email">
</fieldset>
<fieldset>
<input placeholder="Telefoonnummer" type="tel" id="telef" name="telef">
</fieldset>
<fieldset>
<input type="submit" name="submitForm" id="contact-submit" data-submit="...Verzenden">
</fieldset>
</form>
<?php
}
}
I placed the sendmail.php file inside the file above and that fixed my problem.

upload files only after submit

I'm trying to use dropzonejs in order to upload multiple files.
I want to upload them only when i submit the form (post the page)
how can i do that?
<?PHP
if ($_POST)
print_r($_FILES);
?>
here is my form:
<form method='post' action='index.php' enctype='multipart/form-data'>
<input type='text' name='title' value="" class="form-control" />
<textarea name="msgText" class="form-control" ></textarea>
<label class="control-label col-sm-1">Attached File:</label>
<div class="dropzone"></div>
<input type="submit" value="Submit" class="btn btn-success form-control">
</form>
Add name attribute to submit imput
<input type="submit" value="Submit" name="button" class="btn btn-success form-control">
Then in PHP:
if(isset($_POST['button'])){
...some code...
}

php: order of posted variables in array is backard

Somehow when I submit this form the values are stored last name then first name. How can I change the order?
<form action="..posted" method="post" id="register-form">
<div class=register-form-div>
First Name: <input class=register-form-input type="text" name="register[First name]" />
</div>
<div class=register-form-div>
Last Name: <input class=register-form-input type="text" name="register[Last Name]" />
</div>
<input type="submit" id="register-submit" name="register-submit" value="Create Account" />
</form>
try that
<form action="..posted" method="post" id="register-form">
<div class=register-form-div>
First Name: <input class=register-form-input type="text" name="register[1][First name]" />
</div>
<div class=register-form-div>
Last Name: <input class=register-form-input type="text" name="register[0][Last Name]" />
</div>
<input type="submit" id="register-submit" name="register-submit" value="Create Account" />
</form>

HTML PHP Contact Form - Submit Button Not Working? Or PHP Issue?

Hope you can help, I am trying to knock up a contact form for my website which is HTML, styled with CSS and the email sent with PHP.
<form class="form" action="webform.php" method="post">
<h1>Contact Form:</h1>
<label>
<span>Your Name:</span><input id="name" type="text" name="name" />
</label>
<label>
<span>Email Address:</span><input id="email" type="text" name="email" />
</label>
<label>
<span>Subject:</span><input id="subject" type="text" name="subject" />
</label>
<label>
<span>Message</span><textarea id="feedback" name="feedback"></textarea>
<input id="button" type="button" value="Submit Form" />
</label>
</form>
Anyone help me out, can provide the link to my site if necessary.
Appreciate any help :)
You should use submit as the button type
<input id="button" type="submit" value="Submit Form" />
Fiddle DEMO
See updated FIDDLE
Have you tried changing:
<input id="button" type="button" value="Submit Form" />
to:
<input id="button" type="submit" value="Submit Form" />
Alternatively, you can use:
<button id="button" >Submit Form</button>
As you have it now, input type='button' is not a valid element for form submission. For valid form elements, MDN have a great article- see the sections input and buttons
Change type="button" to type="submit"
<form class="form" action="webform.php" method="post">
<h1>Contact Form:</h1>
<label>
<span>Your Name:</span><input id="name" type="text" name="name" />
</label>
<label>
<span>Email Address:</span><input id="email" type="text" name="email" />
</label>
<label>
<span>Subject:</span><input id="subject" type="text" name="subject" />
</label>
<label>
<span>Message</span><textarea id="feedback" name="feedback"></textarea>
<input id="button" type="submit" value="Submit Form" />
</label>
</form>
In this particular case, I agree with the suggested solutions re: type="submit.
But I arrived here due to having my buttons stop working all of a sudden, though a Select submit was still working. And it was due to a tiny bug in some Javascript that was killing the submission.
Just something else to check.
try this html form
<form class="form" action="webform.php" method="post">
<h1>Contact Form:</h1>
<label>
<span>Your Name:</span><input id="name" type="text" name="name" />
</label>
<label>
<span>Email Address:</span><input id="email" type="text" name="email" />
</label>
<label>
<span>Subject:</span><input id="subject" type="text" name="subject" />
</label>
<label>
<span>Message</span><textarea id="feedback" name="feedback"></textarea>
<input id="button" type="submit" value="Submit Form" />
</label> </form>

Two forms interfere with each other on submit

I have two forms on a page-'indexpage plus a included page'. Their actions point as so action=''. The problem is when I hit submit on the search bar, it shows a header error. The submit for the login works fine. I narrowed the problem all the way down to
tabindex="6" type="submit"
in the submit button of the login form.
They both have different names.
Login Form:
echo'<div id="container">
<div id="topnav" class="topnav"> <font color="white">Have an account? &nbsp</font> <span>Sign in</span><span>Sign Up</span> </div>
<fieldset id="signin_menu">';
output_errors($errors);
echo'
<form id="signin" action="" method="POST" >
<br>
<label for="username"><font color="black">Username or email</font></label>
<input id="username" name="username" value="" title="username" tabindex="4" type="text">
</p>
<p>
<label for="password"><font color="black">Password</font></label>
<input id="password" name="password" value="" title="password" tabindex="5" type="password">
</p>
<p class="remember">
<input id="signin_submit" name="submit" value="Sign in" tabindex="6" type="submit">
<input id="remember" name="remember_me" value="1" tabindex="7" type="checkbox">
<label for="remember"><font color="black">Remember me</font></label>
</p>
<p class="forgot"> Forgot your password? </p>
<p class="forgot-username"> <A id=forgot_username_link
title="If you remember your password, try logging in with your email"
href="/recovery/username">Forgot your username?</A> </p>
</form>
</fieldset>
</div>';
Search Form:
<form action='' method='POST'>
<input type='text' value='". $clean ."' name='keywords'/>
<input type='submit' name='submit2' Value='Search'/>
</form>
Header Error:
Warning: Cannot modify header information - headers already sent by (output started at C:\Program Files
(x86)\xampp\htdocs***\index.php:298) in C:\Program Files
(x86)\xampp\htdocs***\pages\search.inc.php on line 35
I'm petty sure that error is due to you trying to output (echo/print) something before trying to redirect in the headers. Redirects header('Location: /anotherpage.php'); after an echo or some printed HTML are probably the cause.
I found the problem in my input for the login submit. Here is what I did.
I change this
<input id="signin_submit" name="submit" value="Sign in" tabindex="6" type="submit">
Too this
<input name="submit" value="Sign in" type="submit">
Apparently the tabindex and id had some kind of issue, not sure why.

Categories