admin管理员组文章数量:1403358
is there a way for me to send a $_POST value to another page without using FORM or SESSION method? because the form method is already being use inside the page itself but i need to send 1 variable to the other page for confirmation.
a simple php or javascript will be great!
this is the value
<input name="sig" id="sig" type="text" value="<?php echo $_POST["sig"]; ?>" />
code that is supposed to catch the code on the next page
<?php
$pass = $_POST['password'];
$password = "service2012"; // Modify Password to suit for access, Max 10 Char.
if ( $pass != $password) {
header("Location: ");
}
?>
is there a way for me to send a $_POST value to another page without using FORM or SESSION method? because the form method is already being use inside the page itself but i need to send 1 variable to the other page for confirmation.
a simple php or javascript will be great!
this is the value
<input name="sig" id="sig" type="text" value="<?php echo $_POST["sig"]; ?>" />
code that is supposed to catch the code on the next page
<?php
$pass = $_POST['password'];
$password = "service2012"; // Modify Password to suit for access, Max 10 Char.
if ( $pass != $password) {
header("Location: https://www.login.html");
}
?>
Share
Improve this question
edited Sep 24, 2012 at 6:03
telexper
asked Sep 24, 2012 at 5:41
telexpertelexper
2,44110 gold badges39 silver badges66 bronze badges
3
- Use AJAX or redesign your application – Alexander Larikov Commented Sep 24, 2012 at 5:43
- redisign is not an option because the value i'm planning to send to the other page is a password to open it otherwise the user will be sent back to the log-in page or get stuck to the current page he is in. – telexper Commented Sep 24, 2012 at 5:44
- isn't that the purpose of a login page? – Mr. 14 Commented Sep 24, 2012 at 5:52
4 Answers
Reset to default 3If you are passing a password to the other page, then it does not make sense using GET
values. All the solutions till now have been GET
values, which anyone can modify. It is usually not safe and creates an XSS vector.
I want to understand why do you want to pass the password to the next page, cause usually, you design your application such that the user enters the password once, and you create a SESSION variable.
You then check this SESSION on each page that requires the user to be logged in. You can use any popular programming language to understand how to create SESSIONS. For PHP :
<?php
session_start();
$_SESSION['page'] = 'SomePage'; // store session data
echo "Page = ". $_SESSION['page']; //retrieve data
?>
You should ideally, create a session and then pass this session variable in place of passing POST
data.
Let me know in case you need further clarification on this.
yes send it via javascript
EDIT:
<script>
function sendval(){
var d=document.getElementById("password").value;
document.location.href='otherpage.php?password='+d;
}
</script>
your otherpage.php
<?php
$pass = $_GET['password'];
$password = "service2012"; // Modify Password to suit for access, Max 10 Char.
if ( $pass != $password) {
header("Location: login.html";);
}
?>
This is rough code,
you can call the function however you feel like.
Also you can use ajax to send the variables.
If you want to send some important data like password than i will highly remand you to use POST method and if you don't want to do so use
<form action="main.php" method="GET">
$pass = $_GET['password'];
$password = "service2012"; // Modify Password to suit for access, Max 10 Char.
if ( $pass != $password) {
header("Location: https://www.login.html");
}//this is insecure method
use a link like
http:/website./main.php?data=1
//data is variable which you want to send
and in main.php
$data=$_GET['data'] ;
you can simply get data using global $_GET
array
create a simple link <a href="main.php?data=1">link</a>
or you can use onclick="main.php?data=1"
You can embed your variable in URL
like this
Edit:
www.server./abc.php?variable=value
;
In abc.php page you will get the value.
本文标签: javascriptsend php value without using form or sessionStack Overflow
版权声明:本文标题:javascript - send php value without using form or session? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744315943a2600263.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论