html button to display php script results [duplicate]
This question already has an answer here:
php form - on submit stay on same page
8 answers
I have this script in a separate file as my index.php.
I want to have a button that if pressed shows the results from my PHP script in the index.php, but when I use
<form action="../inc/script.php" method="post">
<input type="submit" value="Scan">
</form>
it just goes to the script.php page. how can I change it so it stays on index.php and print_r the array from the script on the index.php page?
php html
marked as duplicate by Funk Forty Niner
StackExchange.ready(function()
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();
);
);
);
Nov 14 '18 at 19:57
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
|
show 1 more comment
This question already has an answer here:
php form - on submit stay on same page
8 answers
I have this script in a separate file as my index.php.
I want to have a button that if pressed shows the results from my PHP script in the index.php, but when I use
<form action="../inc/script.php" method="post">
<input type="submit" value="Scan">
</form>
it just goes to the script.php page. how can I change it so it stays on index.php and print_r the array from the script on the index.php page?
php html
marked as duplicate by Funk Forty Niner
StackExchange.ready(function()
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();
);
);
);
Nov 14 '18 at 19:57
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
1
Read about AJAX
– SeReGa
Nov 14 '18 at 18:55
the word ismethod
and notmethode
.
– Funk Forty Niner
Nov 14 '18 at 18:55
@FunkFortyNiner Not everybody speaks English as a first language.
– IMSoP
Nov 14 '18 at 18:58
1
@IMSoP I know, but syntax is English-based, n'est-ce pas?
– Funk Forty Niner
Nov 14 '18 at 18:58
@FunkFortyNiner Ah, I see your point; your comment still seems blunt though, since it's not actually the answer to the question (which is the classic confusion over server vs client code). It could have been something like "By the way, you have a mistake in your HTML, it should bemethod=
notmethode=
"
– IMSoP
Nov 14 '18 at 19:01
|
show 1 more comment
This question already has an answer here:
php form - on submit stay on same page
8 answers
I have this script in a separate file as my index.php.
I want to have a button that if pressed shows the results from my PHP script in the index.php, but when I use
<form action="../inc/script.php" method="post">
<input type="submit" value="Scan">
</form>
it just goes to the script.php page. how can I change it so it stays on index.php and print_r the array from the script on the index.php page?
php html
This question already has an answer here:
php form - on submit stay on same page
8 answers
I have this script in a separate file as my index.php.
I want to have a button that if pressed shows the results from my PHP script in the index.php, but when I use
<form action="../inc/script.php" method="post">
<input type="submit" value="Scan">
</form>
it just goes to the script.php page. how can I change it so it stays on index.php and print_r the array from the script on the index.php page?
This question already has an answer here:
php form - on submit stay on same page
8 answers
php html
php html
edited Nov 14 '18 at 19:11
harmstyler
1,1481020
1,1481020
asked Nov 14 '18 at 18:49
collin 038collin 038
33
33
marked as duplicate by Funk Forty Niner
StackExchange.ready(function()
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();
);
);
);
Nov 14 '18 at 19:57
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
marked as duplicate by Funk Forty Niner
StackExchange.ready(function()
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();
);
);
);
Nov 14 '18 at 19:57
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
1
Read about AJAX
– SeReGa
Nov 14 '18 at 18:55
the word ismethod
and notmethode
.
– Funk Forty Niner
Nov 14 '18 at 18:55
@FunkFortyNiner Not everybody speaks English as a first language.
– IMSoP
Nov 14 '18 at 18:58
1
@IMSoP I know, but syntax is English-based, n'est-ce pas?
– Funk Forty Niner
Nov 14 '18 at 18:58
@FunkFortyNiner Ah, I see your point; your comment still seems blunt though, since it's not actually the answer to the question (which is the classic confusion over server vs client code). It could have been something like "By the way, you have a mistake in your HTML, it should bemethod=
notmethode=
"
– IMSoP
Nov 14 '18 at 19:01
|
show 1 more comment
1
Read about AJAX
– SeReGa
Nov 14 '18 at 18:55
the word ismethod
and notmethode
.
– Funk Forty Niner
Nov 14 '18 at 18:55
@FunkFortyNiner Not everybody speaks English as a first language.
– IMSoP
Nov 14 '18 at 18:58
1
@IMSoP I know, but syntax is English-based, n'est-ce pas?
– Funk Forty Niner
Nov 14 '18 at 18:58
@FunkFortyNiner Ah, I see your point; your comment still seems blunt though, since it's not actually the answer to the question (which is the classic confusion over server vs client code). It could have been something like "By the way, you have a mistake in your HTML, it should bemethod=
notmethode=
"
– IMSoP
Nov 14 '18 at 19:01
1
1
Read about AJAX
– SeReGa
Nov 14 '18 at 18:55
Read about AJAX
– SeReGa
Nov 14 '18 at 18:55
the word is
method
and not methode
.– Funk Forty Niner
Nov 14 '18 at 18:55
the word is
method
and not methode
.– Funk Forty Niner
Nov 14 '18 at 18:55
@FunkFortyNiner Not everybody speaks English as a first language.
– IMSoP
Nov 14 '18 at 18:58
@FunkFortyNiner Not everybody speaks English as a first language.
– IMSoP
Nov 14 '18 at 18:58
1
1
@IMSoP I know, but syntax is English-based, n'est-ce pas?
– Funk Forty Niner
Nov 14 '18 at 18:58
@IMSoP I know, but syntax is English-based, n'est-ce pas?
– Funk Forty Niner
Nov 14 '18 at 18:58
@FunkFortyNiner Ah, I see your point; your comment still seems blunt though, since it's not actually the answer to the question (which is the classic confusion over server vs client code). It could have been something like "By the way, you have a mistake in your HTML, it should be
method=
not methode=
"– IMSoP
Nov 14 '18 at 19:01
@FunkFortyNiner Ah, I see your point; your comment still seems blunt though, since it's not actually the answer to the question (which is the classic confusion over server vs client code). It could have been something like "By the way, you have a mistake in your HTML, it should be
method=
not methode=
"– IMSoP
Nov 14 '18 at 19:01
|
show 1 more comment
2 Answers
2
active
oldest
votes
The form action tells the browser to post the form results to that page. If you want to stay on the current page you'll need to remove the action. Then, you'll have to check the post and include the results within the current page.
<form method="post">
<input type="submit" name="Scan" value="Scan">
</form>
<?php
if (isset($_POST['Scan']))
include '../inc/script.php';
?>
thanks this worked perfectly 😃
– collin 038
Nov 14 '18 at 19:14
add a comment |
One way to solve this problem is through using JavaScript, and specifically jQuery
in my example.
What you would do is set up a POST
request to the PHP document, that would return the print_r
result. You also won't need a form in this instance, more than a button.
HTML:
<button type="button" id="scan"></button>
AND
<div id="returned-data"></div>
so you have a place to put the data when you get it back.
JS/jQuery:
$(document).ready(function()
$('#scan').click(function()
$.post('../inc/script.php').done(function(data)
$('#returned-data').html(data);
);
);
);
PHP (../inc/script.php):
<?php
//do something with your data, and finish with:
print_r($data);
?>
add a comment |
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
The form action tells the browser to post the form results to that page. If you want to stay on the current page you'll need to remove the action. Then, you'll have to check the post and include the results within the current page.
<form method="post">
<input type="submit" name="Scan" value="Scan">
</form>
<?php
if (isset($_POST['Scan']))
include '../inc/script.php';
?>
thanks this worked perfectly 😃
– collin 038
Nov 14 '18 at 19:14
add a comment |
The form action tells the browser to post the form results to that page. If you want to stay on the current page you'll need to remove the action. Then, you'll have to check the post and include the results within the current page.
<form method="post">
<input type="submit" name="Scan" value="Scan">
</form>
<?php
if (isset($_POST['Scan']))
include '../inc/script.php';
?>
thanks this worked perfectly 😃
– collin 038
Nov 14 '18 at 19:14
add a comment |
The form action tells the browser to post the form results to that page. If you want to stay on the current page you'll need to remove the action. Then, you'll have to check the post and include the results within the current page.
<form method="post">
<input type="submit" name="Scan" value="Scan">
</form>
<?php
if (isset($_POST['Scan']))
include '../inc/script.php';
?>
The form action tells the browser to post the form results to that page. If you want to stay on the current page you'll need to remove the action. Then, you'll have to check the post and include the results within the current page.
<form method="post">
<input type="submit" name="Scan" value="Scan">
</form>
<?php
if (isset($_POST['Scan']))
include '../inc/script.php';
?>
answered Nov 14 '18 at 19:09
harmstylerharmstyler
1,1481020
1,1481020
thanks this worked perfectly 😃
– collin 038
Nov 14 '18 at 19:14
add a comment |
thanks this worked perfectly 😃
– collin 038
Nov 14 '18 at 19:14
thanks this worked perfectly 😃
– collin 038
Nov 14 '18 at 19:14
thanks this worked perfectly 😃
– collin 038
Nov 14 '18 at 19:14
add a comment |
One way to solve this problem is through using JavaScript, and specifically jQuery
in my example.
What you would do is set up a POST
request to the PHP document, that would return the print_r
result. You also won't need a form in this instance, more than a button.
HTML:
<button type="button" id="scan"></button>
AND
<div id="returned-data"></div>
so you have a place to put the data when you get it back.
JS/jQuery:
$(document).ready(function()
$('#scan').click(function()
$.post('../inc/script.php').done(function(data)
$('#returned-data').html(data);
);
);
);
PHP (../inc/script.php):
<?php
//do something with your data, and finish with:
print_r($data);
?>
add a comment |
One way to solve this problem is through using JavaScript, and specifically jQuery
in my example.
What you would do is set up a POST
request to the PHP document, that would return the print_r
result. You also won't need a form in this instance, more than a button.
HTML:
<button type="button" id="scan"></button>
AND
<div id="returned-data"></div>
so you have a place to put the data when you get it back.
JS/jQuery:
$(document).ready(function()
$('#scan').click(function()
$.post('../inc/script.php').done(function(data)
$('#returned-data').html(data);
);
);
);
PHP (../inc/script.php):
<?php
//do something with your data, and finish with:
print_r($data);
?>
add a comment |
One way to solve this problem is through using JavaScript, and specifically jQuery
in my example.
What you would do is set up a POST
request to the PHP document, that would return the print_r
result. You also won't need a form in this instance, more than a button.
HTML:
<button type="button" id="scan"></button>
AND
<div id="returned-data"></div>
so you have a place to put the data when you get it back.
JS/jQuery:
$(document).ready(function()
$('#scan').click(function()
$.post('../inc/script.php').done(function(data)
$('#returned-data').html(data);
);
);
);
PHP (../inc/script.php):
<?php
//do something with your data, and finish with:
print_r($data);
?>
One way to solve this problem is through using JavaScript, and specifically jQuery
in my example.
What you would do is set up a POST
request to the PHP document, that would return the print_r
result. You also won't need a form in this instance, more than a button.
HTML:
<button type="button" id="scan"></button>
AND
<div id="returned-data"></div>
so you have a place to put the data when you get it back.
JS/jQuery:
$(document).ready(function()
$('#scan').click(function()
$.post('../inc/script.php').done(function(data)
$('#returned-data').html(data);
);
);
);
PHP (../inc/script.php):
<?php
//do something with your data, and finish with:
print_r($data);
?>
answered Nov 14 '18 at 18:58
RyanRyan
3169
3169
add a comment |
add a comment |
1
Read about AJAX
– SeReGa
Nov 14 '18 at 18:55
the word is
method
and notmethode
.– Funk Forty Niner
Nov 14 '18 at 18:55
@FunkFortyNiner Not everybody speaks English as a first language.
– IMSoP
Nov 14 '18 at 18:58
1
@IMSoP I know, but syntax is English-based, n'est-ce pas?
– Funk Forty Niner
Nov 14 '18 at 18:58
@FunkFortyNiner Ah, I see your point; your comment still seems blunt though, since it's not actually the answer to the question (which is the classic confusion over server vs client code). It could have been something like "By the way, you have a mistake in your HTML, it should be
method=
notmethode=
"– IMSoP
Nov 14 '18 at 19:01