I'm using TinyMCE text editor on my website and I have problem with gettingtext from the TinyMCE and then insert to the db. I'm propably blind, but a don't see what wrong. Working with PDO.
Header, activate the editor
<script src="//cdn.tinymce.com/4/tinymce.min.js"></script>
<script>tinymce.init({ selector:'textarea' });</script>
Forms
<?php include "InsertArticles.php"; ?>
<div id="editor">
<form method="post">
<textarea name="Obsah"></textarea>
</form>
</div>
<div id="inputaddnadpis">
<form method="post">
Nadpis: <input type="text" name="Nadpis">
</form>
</div>
<form method="post">
<input type="submit" name="Article" id="InsertArticles" value="Add article">
<input type="submit" name="Tip" id="InsertTips" value="Add tip">
</form>
Insert
<?php
include_once "db.php";
global $db;
if (!empty($_POST["Article"])) {
$sqlVlozeni = "INSERT INTO WEB_ARTICLE (Nazev, Clanek) VALUES (:nazev, :clanek)";
$sqlProvedeni = $db->prepare($sqlVlozeni);
$stav = $sqlProvedeni->execute(array(":nazev" => $_POST["Nadpis"], ":clanek" => $_POST["Obsah"]));
}
?>
Submitting the third form will not submit values from the first two forms.
In general, only the inputs inside a particular form will be submitted with that form.
Consider using only one <form> element around all of your inputs.
<form method="post">
<div id="editor">
<textarea name="Obsah"></textarea>
</div>
<div id="inputaddnadpis">
Nadpis: <input type="text" name="Nadpis">
</div>
<input type="submit" name="Article" id="InsertArticles" value="Add article">
<input type="submit" name="Tip" id="InsertTips" value="Add tip">
</form>
Related
I'll make this short and quick. :)
I'm trying to implement a button on my website, which redirects me to a URL I specify + what the user is looking for.
I have this little piece of code here:
<html>
<div class="search">
<form role="search" method="get" id="search">
<div>
<input type="text" value="" name="tag_search" id="tag_search" />
<input type="button" value="Cerca" onclick="window.location.href='https://mywebsite.com/'" />
</div>
</form>
</div>
</html>
that is almost working.
The only thing is that if the User inputs "Hello" in the Search Box, it will always search for the following URL once you press the "Submit" button: https://mywebsite.com/
How can I append what the User has written into the Search Box, so that the Button will redirect me to: https://mywebsite.com/Hello ?
Thank you all!
Add the value of the input to the link
<html>
<div class="search">
<form role="search" method="get" id="search">
<div>
<input type="text" value="" name="tag_search" id="tag_search" />
<input type="button" value="Cerca"
onclick="window.location.href='https://mywebsite.com/' +
document.getElementById('tag_search').value" />
</div>
</form>
</div>
</html>
Add the following Javascript to help
<script>
function goToSearch() {
window.location.href= 'https://mywebsite.com/' + encodeURI(document.getElementById("tag_search").value)
}
</script>
Then your HTML should look like this
<html>
<div class="search">
<form role="search" method="get" id="search">
<div>
<input type="text" value="" name="tag_search" id="tag_search" />
<input type="button" value="Cerca" onclick="goToSearch()" />
</div>
</form>
</div>
</html>
I have an HTML input and button:
<form action="validate.php" method="post">
<!-- THE CODE INSERT -->
<div id="code">
<form>
<label></label>
<input id="input" name="InputText" type="text"/>
</form>
</div>
<!-- THE BUTTON ITSELF -->
<input type="button" id="button" name="myButton"><b>Search Archive</b>
</form>
in my validate.php file I have this switch statement:
<?php
switch ($_POST["InputText"])
{
case "someval":
http_header("someaddress.com");
die();
break;
}
?>
the problem is that when I click the button it doesn't do anything. I did this with JS and it worked but it should be noted that I'm really new to web development so if anyone can explain to me what I did wrong and specifically why that would be great. Thanks!
You have a form inside of a form, that won't work. Also, you need to include an <input type="submit" value="submit" /> before you close your form. This is what submits the information from the form to your action="file.php".
A form would typically look like this:
file.html
<form action="validate.php" method="POST">
<input type="text" name="username" placeholder="Enter your username" />
<input type="submit" name="submit" value="Submit" />
</form>
Then you'd do something like this:
validate.php
<?php
echo "Your username is" . $_POST['username'];
The $_POST['username'] is the data gathered from the name="username" input from the HTML. If you write die($_POST); you'll get all the data that is sent through the form.
When you are using type='button' you have to perform the submit by yourself.
So, you can do that using javascript or change to type='submit'.
Example:
<input type="button" id="button" name="myButton"><b>Search Archive</b>
To
<input type="submit" id="button" name="myButton" value="Search Archive" />
you can try this
<form action="/validate.php" method="post">
<!-- THE CODE INSERT -->
<div id="code">
<label></label>
<input id="input" name="InputText" type="text"/>
</div>
<!-- THE BUTTON ITSELF -->
<button type="submit" id="button" name="myButton">Search Archive</button>
</form>
in the div id ="code" you used form tag that's why its not work...delete it will work and button type must be submit
<?php
echo $_POST['textvalue'];
echo $_post['radiovalue'];
?>
<div id="hidethis">
<form method="POST" action="">
<label>Tekst Value</label>
<input type="text" name="textvalue">
<label>Radio Value</label>
<input type="radio" name="radiovalue" value="autogivevalue">
<input type="submit" id="submit" name="submit" value="submit">
</div>
http://jsfiddle.net/Bjk89/2/ here is it with the jQuery.
What i try to do is to hide the <div id="hidethis"> when it's clicking submit.
I know i can make another page where i can recieve the values without the <form> section, but i want to put both in one page, make the <div id="hidethis"> hidden after submit.
So i'll be able to get echo $_POST['textvalue']; and echo $_post['radiovalue']; as results
RESULT MUST BE LIKE
A Text // This is the value you input into Tekst Value
autogivevalue // This is the value from the radio button
----- INVISIBLE -----
<form is hidden because we set it in jQuery so>
</form>
Try this. No need to use jQuery here.
<?php
if($_POST) {
echo $_POST['textvalue'];
echo $_post['radiovalue'];
} else {
?>
<form method="POST" action="">
<label>Tekst Value</label>
<input type="text" name="textvalue">
<label>Radio Value</label>
<input type="radio" name="radiovalue" value="autogivevalue">
<input type="submit" id="submit" name="submit" value="submit">
</form>
<?php
}
?>
Try adding '#' in your jquery code. Your version does not have # next to submit. Also your form is missing a closing tag here and in your JSFiddle code.
Try this:
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script>
$(document).ready(function () {
$('#submit').click(function () {
$('form').submit();
$('#hidethis').hide();
});
});
</script>
<form method='post' id="hidethis" name='form'>
<input type="text" name="textvalue">
<input type="radio" name="radiovalue" value="1">
<input type="button" id="submit" name="submit" value="submit">
</form>
Problem: How to make an HTML Form call different php pages from the action based on what button is pushed?
The code below is the solution I have now, but I figure there must be a better way to do this then creating multiple forms on the page?
<html>
<body>
<form name="entry_form" action="entry_update_script.php" method="post" enctype="multipart/form-data">
<input type="hidden" name="entry_id" value="">
<input type="hidden" name="entry_item_id" value="">
Truck/Railcar/Barge#:<input type="text" name="pro_number" value=""><br>
BOL #:<input type="text" name="bol" value=""><br>
<input type="submit" name="entry_submit" value="Add New Entry!">
</form>
<form name="entry_form_add" action="entry_view.php" method="post" enctype="multipart/form-data">
<input type="hidden" name="entry_id" value="">
<input type="submit" name="submit" value="Add New Item!">
</form>
</body>
</html>
<html>
<body>
<script type="text/javascript">
function submitAction(act) {
document.sample.action = act;
document.sample.submit();
}
</script>
<form name ="sample" action="default.php">
<input type="button" value = "blah1" onClick="submitAction('phpPage1.php')">
<input type="button" value = "blah2" onClick="submitAction('phpPage2.php')">
</form>
</body>
</html>
you might choose the page to go from a dispatcher, it's an extensible and robust solution:
your form
<form action="dispatcher.php" method="POST">
<input type="radio" name="myOption" value="register" />
<input type="radio" name="myOption" value="login" />
</form>
dispatcher.php
$actions = array ('register', 'login');
// validate possible actions
if (in_array($_POST['myOption']), $actions)) {
include ($_POST['myOption'] . '.php');
}
Hi having a problem with this code even if i clicked on cancel it will still proceed to use the action of my form even though the CANCEL button is not part of the form, Would appreciate any help.
Here is the code.
<form method="post" action="input_enroll.php" >
<div id="overlay1">
<div>
<h1> Enter Educational Level Entry</h1>
<input type="text" name="level" >
<input type="submit" value="Proceed To Enroll" '>
</form>
<input type="submit" value="Cancel" onclick='overlay()'>
</div>
</div>
EDIT: Any suggestions what would be a better idea? I'm thinking putting the cancel outside the div.
You are having form started, then divs started, then form closed..start form after divs..
as your markup is not correct, browsers will change it as thier parser suggest,
In chrome </form> tag is postponed after </div>s..
<div id="overlay1">
<div>
<form method="post" action="input_enroll.php" >
<h1> Enter Educational Level Entry</h1>
<input type="text" name="level" />
<input type="submit" value="Proceed To Enroll" />
</form>
<input type="submit" value="Cancel" onclick='overlay()' />
</div>
</div>