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?  </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.
Related
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.
I am having issues with a piece of code in Joomla. It may be something to do with the plugin that enables the PHP but in case it isn't.
Page 1 has a form
<form action="/index.php/bridge" method="POST" name="postcode">
<div><input style="height: 50px;" type="text" placeholder="Enter Your Postcode..." /> <input type="submit" value="Get Started today!" /></div></form>
The text you input becomes the variable I want to pass over
On Page 2
<?php echo "test";
$postcode=1;
$poster=$_POST['postcode'];
echo $poster;
// You can place PHP like this
?>
Unfortunately, the postcode isn't echoed
Assuming nothing else is the cause of this error, try naming the input you are sending over to postcode:
<form action="/index.php/bridge" method="POST">
<div>
<input style="height: 50px;" name="postcode" type="text" "placeholder="Enter Your Postcode..." />
<input type="submit" value="Get Started today!" />
</div>
</form>
In your PHP code you are echoing $_POST['postcode'] but you are not sending the same variable at the time of form submission from input attribute.
<form action="/index.php/bridge" method="POST" name="demoForm">
<div>
<input style="height: 50px;" name="postcode" type="text" "placeholder="Enter Your Postcode..." />
<input type="submit" value="Get Started today!" />
</div>
</form>
Try this
<form action="/index.php/bridge" method="POST">
<div>
<input name="postcode" style="height: 50px;" type="text" placeholder="Enter Your Postcode..." />
<input type="submit" name="submit" value="Get Started today!" />
</div>
<?php
if (isset($_POST['submit'])){
echo $poster = $_POST['postcode'];
}else{
echo $poster = 1;
}
?>
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'
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>
I wonder whether someone could help me please.
I'm put together the following form contained within a PHP file.
<form name="savemyfindstolocation" id="savemyfindstolocation" method="post">
<p><label></label>
</p>
<p align="left">
<input name="userid" type="text" id="userid"/>
<input name="locationid" type="text" id="locationid"/>
<br />
</p>
<div>
<label>
<div align="left">Click on the map to place the marker for the find that has been made and drag until the precise location has been found. </div>
</div>
<p align="left"><label>Find OSGB36 Latitude Co-ordinate<br />
</label>
</p>
<div>
<div align="left">
<input name="findosgb36lat" type="text" id="findosgb36lat" size="20" />
</div>
</div>
<p align="left"><label>Find OSGB36 Longitude Co-ordinate<br />
</label>
</p>
<div>
<div align="left">
<input name="findosgb36lon" type="text" id="findosgb36lon" size="20" />
</div>
</div>
<p align="left"><label>Date of Trip<br />
</label>
</p>
<div>
<div align="left">
<input name="dateoftrip" type="text" id="dateoftrip" size="10" />
</div>
</div>
<input name="submit" type="submit" onclick="MM_callJS('savedata()')" value="Submit" />
</form>
It all works fine, but I'd now like to add a button that opens the following php page, 'blobupload.php'. If I've understood this correctly from the research that I've done, I need to use javascript to open the page, using the 'submit' action from the main form.
What I don't understand is how to do this when the 'submit' action is already taken for the saving of the information on the main form.
Could someone perhaps please show me how to get around this, i.e. using the same 'submit action but for two different purposes.
Just modify your form tag (add the action attribute to file you want to load):
<form name="savemyfindstolocation" id="savemyfindstolocation" method="post" action="blobupload.php">
And you submit input tag:
<input name="submit" type="submit" value="Submit" />
You can use a second javascript function to open new window like this way
<input name="submit" type="submit" onclick="MM_callJS('savedata()');SECOND_JS_FUNCTION()" value="Submit" />
Use php to process the form is one of the way to do it.
<input name="submit" !!!!!!action="process.php" method="POST (or get)!!!!!!!!!! type="submit" onclick="MM_callJS('savedata()')" value="Submit" />
that way the the variable will be passed to the process.php while you can also redirect the page in the process.php
header("Location:URL");