This is html code for my checkbox and button
<form>
<input type="checkbox" id="DNA" name="DNA" value="checkox_value">
<button type="button" name="submit" onClick="search()" id="sim_btn" class="btn btn-primary">Start Simulation</button>
</form>
I want to check if checkbox is checked and if yes write the input to my file.
I tried using the isset function but it doesn't work any other suggestions?
if(isset($_POST["DNA"])) {
$input3 = "signal(f).";
fwrite($handleStoryFile, $input3 . PHP_EOL);
}
<!DOCTYPE html>
<html>
<body>
<form action="#" method="post">
<input type="checkbox" id="DNA" name="DNA" value="checkox_value">
<button type="submit" name="submit" id="sim_btn" class="btn btn-primary">Start Simulation</button>
</form>
<?php
if(isset($_POST["DNA"])) {
echo 'test';
}
?>
</body>
</html>
Related
The code commands in this script don't run and show up in the html page.
<script type="text/php">
<?php
$_SESSION['userUID'] = "uidUsers";
if(isset($_SESSION['userUID']))
{
echo '<form action="/loginsystemtut/includes/logout.inc.php" method="post">
<button type="submit" name="logout-submit">Logout</button>
</form>';
} elseif(!isset($_SESSION['userUID'])) {
echo '<form action="/loginsystemtut/includes/login.inc.php" method="post">
<button type="submit" name="login-submit">Login</button>
</form>';
}
?>
</div>
</script>
I am trying to get login button to show when the user is logged in and the logout button to show when the user is logged out.
Remove the script tags & replace your code with the example below.
<?php
$_SESSION['userUID'] = "uidUsers";
if (isset($_SESSION['userUID'])) :?>
<form action="/loginsystemtut/includes/logout.inc.php" method="post">
<button type="submit" name="logout-submit">Logout</button>
</form>
<?php else : ?>
<form action="/loginsystemtut/includes/login.inc.php" method="post">
<button type="submit" name="login-submit"> Login</button>
</form>
<?php endif ?>
Here are the codes.
Form
<form method="POST" action="" id="search">
<div class="col-lg-4 center"><a class="btn btn-success" type="submit" name="publish" id="publish" alt="Publish"> Publish</a></div>
<div class="col-lg-4 center"><a class="btn btn-success" type="submit" name="edit" id="edit" alt="Edit"> Edit </a></div>
<div class="col-lg-4 center"><a class="btn btn-success" type="submit" name="draft" id="draft" alt="Save as Draft"> Save as Draft</a></div>
</form>
Post
<?php
if ($_POST['publish'] == 'publish'){
echo '<script>alert("Publish"); </script>';
}
if ($_POST['edit'] == 'publish'){
echo '<script>alert("edit"); </script>';
}
if ($_POST['draft'] == 'publish'){
echo 'draft';
}
?>
If I click on any button nothing happens. I am not getting anything nor any error. Nothing appears in firebug as well.
You wanted to submit to the same page. Try giving the page name in your action
<form method="POST" action="yourpage.php" id="search">
Try with this:
<?php
if (isset($_POST['publish'])) {
echo '<script>alert("Publish"); </script>';
}
if (isset($_POST['edit'])) {
echo '<script>alert("edit"); </script>';
}
if (isset($_POST['draft'])) {
echo 'draft';
}
?>
use button instead of links
like
<input type="submit" ..... />
like this
<input type="submit" class="btn btn-success" name="publish" id="publish" alt="Publish" value="Publish" />
You will get data then
and try to on error reporting in php.ini file
You need to add a submit n
Button. <input type=submit name="submit"> also, specify action attribute in form tag to your Php script.
<?php
if (isset($_POST['submit'])){
echo '<script>alert("Publish"); </script>';
}
?>
<form method="POST" action="" id="search">
<input name="submit" type="submit" />
</form>
First thing you can not use type="submit" as attribute in your anchor tag.
Second if you wants to submit button using input type as submit then use the following code:
<?php
if(isset($_POST))
{
if (isset($_POST['publish'])){
echo '<script>alert("Publish"); </script>';
}
if (isset($_POST['edit'])){
echo '<script>alert("edit"); </script>';
}
if (isset($_POST['draft'])){
echo '<script>alert("Draft"); </script>';
}
}
?>
<form method="POST" action="<?php echo $_SERVER['PHP_SELF']; ?>" id="search">
<div class="col-lg-4 center"><input class="btn btn-success" type="submit" name="publish" id="publish" value="Publish"> </input></div>
<div class="col-lg-4 center"><input class="btn btn-success" type="submit" name="edit" id="edit" value="Edit"> </input></div>
<div class="col-lg-4 center"><input class="btn btn-success" type="submit" name="draft" id="draft" value="Draft"> </input></div>
</form>
Third, In case if you really wants to use only anchor for submit then you have to use help of javascript function submit() and use the
onclick="document.getElementById('search').submit();
in your anchor tag.
So, i'm new here as well new to html, i'm reading some sites(for some hours now) and as far as i can tell my code should work, but it dosen't...
I just want to click a button and recieve it's name as echo. But when I click noting happen.
Any good soul to help out? :P
<head>
<title>Index</title>
</head>
<body>
<div>
<input type="submit" name="insert" value="insert" >
<input type="submit" name="select" value="select" >
</div>
<?php
if (isset( $_GET['insert'])) {
echo "insert";
}
if ( isset( $_GET['select'] ) ) {
echo "select";
}
?>
</body>
submit button works with form because only form can be submit so u can try with :
<form method="get" name="frm">
<input type="submit" name="select" value="select" >
</form>
please insert your div into a form like
<head>
<title>Index</title>
</head>
<body>
<form method="get" action="">
<div>
<input type="submit" name="insert" value="insert" >
<input type="submit" name="select" value="select" >
</div>
</form>
<?php
if (isset( $_GET['insert'])) {
echo "insert";
}
if ( isset( $_GET['select'] ) ) {
echo "select";
}
?>
</body>
Just add form tags like this
<form>
<input type="submit" name="insert" value="insert" >
<input type="submit" name="select" value="select" >
</form>
you can write the form tag or use below code on top right of the page
if(isset($_POST['insert'])){
...
}
if(isset($_POST['select'])){
...
}
Check This
<html>
<head>
<title>Index</title>
</head>
<body>
<div>
<form method="GET" action="#">
<input type="submit" name="insert" value="insert" >
<input type="submit" name="select" value="select" >
</from>
</div>
</body>
</html>
<?php
if (isset( $_GET['insert'])) {
echo "insert";
}
if ( isset( $_GET['select'] ) ) {
echo "select";
}
?>
Please first Define method in form.
<form method="GET" action="#">
<input type="submit" name="insert" value="insert" >
<input type="submit" name="select" value="select" >
</form>
Hi i need help because this is not working:
I just wanted to open websites with buttons but in a search box.....
<html>
<body>
<form>
<input type=button onClick=window.open("action.php","demo","width=550,height=300,left=150,top=200,toolbar=0,status=0,"); value="Öffne">
</form>
<form method="post" action="action.php">Suche: <input name="suche" type="text"><br>
<input type="submit" value="OK">
</form>
</body>
</html>
<php
$user = $_POST['suche'];
$seite = 'www.google.de/#q=';
$ziel=$seite.$user;
<form>
<input type=button onclick="location.href='https://www.google.de/#q=<?php echo $seite; ?>'" value='Website'>
<input type=button onClick="self.close();" value="Close this window">
</form>
You have more quotes missing on html tag attr and also php closing tags try
<html>
<body>
<form>
<input type="button" onClick='window.open("action.php","demo","width=550,height=300,left=150,top=200,toolbar=0,status=0,");' value="Öffne">
</form>
<form method="post" action="action.php">Suche: <input name="suche" type="text"><br>
<input type="submit" value="OK">
</form>
</body>
</html>
<?php
$user = $_POST['suche'];
$seite = 'www.google.de/#q=';
$ziel=$seite.$user;
?>
<form>
<input type="button" onclick="location.href='https://www.google.de/#q=<?php echo $seite; ?>'" value='Website'>
<input type="button" onClick="self.close();" value="Close this window">
</form>
Now I have a last question, I want to put both files index.html and action.php in one file. So if I go on Index.html i just have to enter my value for 'suche' and klick on submit button ('ok') to save the value of 'name' into '$input' and then klick on one of the buttons google,proxer,.... to search on that websites.
(maybe if it is possible I can merge the submit btton ('OK') and the buttons (google,proxer,...) to make it cleaner)
For example the link for google + $input would be: $seite_google.$input;
My code now looks like:
For index.php:
<?php
$input = $_POST['suche'];
$seite_google = 'https://www.google.de/#q=';
$seite_myanimelist = 'http://myanimelist.net/anime.php?q=';
$seite_anisearch = 'http://de.anisearch.com/anime/index/?char=all&text=';
$seite_proxer = 'http://proxer.me/search?name=';
?>
<form>
<input type="button" onclick="location.href='<?php echo $seite_google.$input; ?>'" value='Google Suche'>
<input type="button" onclick="location.href='<?php echo $seite_myanimelist.$input; ?>'" value='MyAnimeList'>
<input type="button" onclick="location.href='<?php echo $seite_anisearch.$input; ?>&q=true'" value='AniSearch'>
<input type="button" onclick="location.href='<?php echo $seite_proxer.$input; ?>&sprache=alle&typ=all&genre=&nogenre=&sort=name&length=&length-limit=down#search'" value='Proxer'>
</form>
<html>
<body>
<form method="post" action="">Suche: <input name="suche" type="text"><br>
<input type="submit" value="OK" name="submit">
</form>
</body>
</html>
<?php
if(isset($_POST['submit'])){
header('Location: http://www.rate.ee');
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>
</title>
</head>
<body>
<input type="submit" name="submit" id="submit" class="button" value="Submit"/>
</body>
</html>
This is my code. Very simple, isn't it. But it doesn't work and I don't get it.. I always thought that PHP only executes when I load the page, but the other page where I use same code works very well without JS..
You need to wrap your button in a <form> tag:
<form action="" method="post">
<input type="submit" name="submit" id="submit" class="button" value="Submit"/>
</form>
You need a form surrounding the input.
<body>
<form action="welcome.php" method="post">
<input type="submit" name="submit" id="submit" class="button" value="Submit"/>
</form>
</body>
</html>
You have no form tag and even if you did it would need the method="post" attribute.
<form method="post" action="<?php echo $_SERVER[PHP_SELF]?>">
<input type="submit" name="submit" id="submit" class="button" value="Submit"/>
</form>