PHP密码和重定向脚本...... [英] PHP Password And Redirect Script...

查看:57
本文介绍了PHP密码和重定向脚本......的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好。我的网站上有一个使用3个文件的投票系统。第一个文件是 vote.php 并且有投票表格。此文件将信息传递给 confirmation.php ,上面有感谢信息。此文件将信息传递给 vote.txt ,该信息存储了我以后记录的信息。我对你描述的很有效,但是有一个问题。我希望用户必须先使用 voteli.php 上的登录表单登录。我有登录脚本,但它们甚至都不安全。我想要它,所以如果他们变得聪明并直接进入 vote.php 它会将他们踢回 voteli.php ,除非变通 $ login 是真正。我还希望登录脚本将用户名通过所有页面传递为varaible $ user 。然后我会回应页面中的变量,以便它有一个问候消息。我还将在结果页面中使用此名称来取消同一用户的任何双倍投票。我将使用我对php的小知识提供我的源代码,我希望你提出一些修正。

vote.php:

[PHP]<?php

$ login = $ _GET [''login''];

$ user = $ _GET [''用户名'']


if(!$ login)

{

window.location =(''voteli .htm'');

}


其他

{

echo(''你好,''用户''!'');

}

?> [/ PHP]上面的代码就是我用来反弹用户的代码登录页面如果他们还没有登录。它还会在投票页面的顶部打印问候消息。


[HTML]

<? php echo(''投票为:''$ user''。'')?>

< form name =" poll"行动= QUOT; confirmation.php" method =" get">

Lorem ipsum坐在dolor amet?

< select name =" q1">

< ; option value =" q1a"> Lorem< / option>

< option value =" q1b"> Ipsum< / option>

< option value =" q1c"> Dolor< / option>

< option value =" q1d"> Amet< / option>

< / select>

< / form> [/ HTML]

上面的代码是简化的投票表格。

确认。 php

[HTML]<?php

$ q1 = $ _GET [''q1''];

//请参阅下面的注释,了解用户名问题。


$ filename =" vote.txt" ;;

$ content1 =" $ v1 \ n" ;;

$ fp = fopen($ filename," a");

$ fw = fwrite($ fp,$ content1);

fclose($ fp);


?> [/ HTML]上面的代码写入文本文件。我需要一种方法来获取从 vote.php 传递给 confirmation.php 的用户名,这样我就可以在感谢信息中显示该名称。


[HTML]感谢您投票,<?php echo($ user); ?>!你的投票将被重视。 < br />

<! - 注销链接会很好 - > 点击这里注销。[/ HTML]

Hello peoples. I have a voting system on my web site that uses 3 files. The first file is vote.php and has the vote form on it. This file passes the information to confirmation.php which has a thank you message on it. This file passes the information to vote.txt, which stores the information for me to tally up later. What i described to you works great, but theres one problem. I want users to have to log in first, using a login form on voteli.php. I have login scripts, but theyre not even close to secure. I want it so if they get smart and go directly to vote.php it will kick them back to voteli.php unless varaible $login is true. I would also like the login script to pass the username through all the pages as varaible $user. Then i wil echo the varaible in the page so it has a greeting message. I will also use this name in the results page to cancel out any double votes by the same user. I will provide the source codes i made using my small knowledge of php, and i will hope that you suggest some fixes.

vote.php:
[PHP]<?php
$login = $_GET[''login''];
$user = $_GET[''username'']

if(!$login)
{
window.location=(''voteli.htm'');
}

else
{
echo(''Hello, ''$user''!'');
}
?>[/PHP]The code above is the one i wrote to bounce the users back to the login page if they have not logged in. It also prints the hello message at the top of the vote page.

[HTML]
<?php echo(''Voting as: ''$user''.'') ?>
<form name="poll" action="confirmation.php" method="get">
Lorem ipsum sit dolor amet?
<select name="q1">
<option value="q1a">Lorem</option>
<option value="q1b">Ipsum</option>
<option value="q1c">Dolor</option>
<option value="q1d">Amet</option>
</select>
</form>[/HTML]
The code above is the simplified vote form.

confirmation.php
[HTML]<?php
$q1 = $_GET[''q1''];
//See notes below for username problem.

$filename = "vote.txt";
$content1 = "$v1\n";
$fp = fopen($filename, "a");
$fw = fwrite( $fp, $content1 );
fclose( $fp );

?>[/HTML]Tha code above writes to the text file. I need a way to get the username passed from vote.php to confirmation.php so i can display the name in the thanks message.

[HTML]Thank you for voting, <?php echo($user); ?>! Your vote will count. <br />
<!-- A logout link would be nice -->Click Here to log out.[/HTML]

推荐答案

login 是真的。我还希望登录脚本将用户名通过所有页面传递为变量
login is true. I would also like the login script to pass the username through all the pages as varaible


user 。然后我会回应页面中的变量,以便它有一个问候消息。我还将在结果页面中使用此名称来取消同一用户的任何双倍投票。我将使用我对php的小知识提供我的源代码,我希望你提出一些修正。

vote.php:

[PHP]<?php
user. Then i wil echo the varaible in the page so it has a greeting message. I will also use this name in the results page to cancel out any double votes by the same user. I will provide the source codes i made using my small knowledge of php, and i will hope that you suggest some fixes.

vote.php:
[PHP]<?php


login =


这篇关于PHP密码和重定向脚本......的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆