|
《小今Final project》忘了密码,填写Email后,系统会send密码去Email的Code,有问题
[复制链接]
|
|
楼主 |
发表于 12-8-2006 05:43 PM
|
显示全部楼层
回复 #20 goatstudio 的帖子
我通常用if的.如果要validate POST 或 GET ,要用isset 对吗?刚才就是没用isset就出现error了.用了就可以了.谢谢.... |
|
|
|
|
|
|
|
发表于 12-8-2006 07:13 PM
|
显示全部楼层
原帖由 goatstudio 于 12-8-2006 04:19 PM 发表
你应该先用 isset 来检查任何一个 $_POST 和 $_GET, 因为当你的网页第一次 load 的时候, 可能根本没有这些 parameters.
知道了
但是小今的那个error在我的电脑是没有的
不知道是不是setting的问题
还是version的关系???
还是要用到isset呢? |
|
|
|
|
|
|
|
发表于 12-8-2006 11:08 PM
|
显示全部楼层
原帖由 小今 于 12-8-2006 05:43 PM 发表
我通常用if的.如果要validate POST 或 GET ,要用isset 对吗?刚才就是没用isset就出现error了.用了就可以了.谢谢....
对... isset 是用来看变量是否存在. 但 if 和 isset 通常是用在一起的. |
|
|
|
|
|
|
|
发表于 12-8-2006 11:10 PM
|
显示全部楼层
原帖由 红发 于 12-8-2006 07:13 PM 发表
知道了
但是小今的那个error在我的电脑是没有的
不知道是不是setting的问题
还是version的关系???
还是要用到isset呢?
要看你怎么呼叫这个 php, 还有看你的 code 怎么写.
另外, 前几个 version (4.x) 的 php 没有也不需要 isset... 我忘了什么 version. |
|
|
|
|
|
|
|
楼主 |
发表于 12-8-2006 11:46 PM
|
显示全部楼层
回复 #24 goatstudio 的帖子
谢谢大大的帮忙.Thank you.
[ 本帖最后由 小今 于 14-8-2006 03:46 PM 编辑 ] |
|
|
|
|
|
|
|
楼主 |
发表于 14-8-2006 04:06 PM
|
显示全部楼层
请帮帮忙check下以下的error.Display 不到database里的 comment..
为什么show不出comment after key in username 和 select 了movie?
<HTML>
<BODY>
<TABLE BORDER=0 CELLPADDING=10 WIDTH=100%>
<TR>
<TD BGCOLOR="#FOF8FF" ALIGN=CENTER VALIGN=TOP WIDTH=17%>
</TD>
<TD BGCOLOR="#FFFFFF" ALIGN=LEFT VALIGN=TOP WIDTH=83%>
<H3>Comment edit</H3>
<FORM METHOD="POST" ACTION="comment_edit.php?action=load">
<P><b>Username:</b><br>
<INPUT TYPE=TEXT NAME="user_name" SIZE=20 VALUE=""></P>
<B>Select movie:</B><br />
<SELECT NAME ="movie">
<OPTION VALUE="">Choose....</OPTION>
<OPTION VALUE="Superman return">Superman return</OPTION>
<OPTION VALUE="Pirate of the carribean 2">Pirate of the carribean 2</OPTION>
<OPTION VALUE="Lady in the water">Lady in the water</OPTION>
</SELECT><BR>
<TEXTAREA NAME="comment" COLS=50 ROWS=10>$comment</TEXTAREA>
<BR></P>
<INPUT TYPE="SUBMIT" NAME="submit" VALUE="Submit"></P>
</FORM>
</TD></TR></TABLE>
</BODY>
</HTML>
<?php
$action = isset($_GET["action"])?$_GET["action"]:"";
if ($action == 'load') {
extract($_POST);
include("dbfinfo.inc.php");
mysql_connect("localhost",$username,$password);
@mysql_select_db($database) or die (" Unable to select database");
$comment = isset($_GET["comment"])?$_GET["comment"]:"";
$query = "SELECT comment
FROM mycomment
WHERE user_name = '$user_name'
AND movie = '$movie'";
$result = mysql_query($query);
if (mysql_num_rows($result)!= 1){
echo "No entry match that date";
}
else {
$user_name = $_POST['user_name'];
$movie = $_POST['movie'];
$new_date = date('Ymd');
$query = "UPDATE mycomment
SET comment = '$comment', date = '$new_date'
WHERE movie = '$movie'
AND user_name = '$user_name'";
$result = mysql_query($query);
if (mysql_affected_rows() == 1) {
echo '<P>Your comment has been updated.<P>';
}
else {
echo '<P>Something went wrong.</P>';
}
}
}
?>
Mysql 里的table是mycomment,attribute是date,user_name,comment 和movie.
谢谢... |
|
|
|
|
|
|
|
发表于 14-8-2006 04:42 PM
|
显示全部楼层
问题在这里。
$user_name = $_POST['user_name'];
$movie = $_POST['movie'];
$new_date = date('Ymd'); |
|
|
|
|
|
|
|
楼主 |
发表于 15-8-2006 12:14 AM
|
显示全部楼层
|
|
|
|
|
|
|
发表于 15-8-2006 12:24 AM
|
显示全部楼层
$comment = isset($_GET["comment"])?$_GET["comment"]:"";
$query = "SELECT comment
FROM mycomment
WHERE user_name = '$user_name' <----------
AND movie = '$movie'"; <---------------
$result = mysql_query($query);
if (mysql_num_rows($result)!= 1){
echo "No entry match that date";
}
else {
$user_name = $_POST['user_name']; <------------
$movie = $_POST['movie']; <-------------------
$new_date = date('Ymd');
来迟了。。。。。。。 |
|
|
|
|
|
|
|
楼主 |
发表于 15-8-2006 01:40 AM
|
显示全部楼层
|
|
|
|
|
|
|
发表于 15-8-2006 09:23 AM
|
显示全部楼层
原帖由 小今 于 15-8-2006 01:40 AM 发表
应该是GET吗,对吗??谢谢
可以RUN了?????? |
|
|
|
|
|
|
|
楼主 |
发表于 15-8-2006 08:59 PM
|
显示全部楼层
原帖由 红发 于 15-8-2006 09:23 AM 发表
可以RUN了??????
可以直接帮我改正吗?我写不懂正确的CODE,
谢谢你啦,红大 |
|
|
|
|
|
|
|
发表于 15-8-2006 11:42 PM
|
显示全部楼层
原帖由 小今 于 15-8-2006 08:59 PM 发表
可以直接帮我改正吗?我写不懂正确的CODE,
谢谢你啦,红大
其实错误已近很明显的了
$user_name = $_POST['user_name'];
$movie = $_POST['movie'];
$new_date = date('Ymd');
这个来迟了。。。。。
$comment = isset($_GET["comment"])?$_GET["comment"]:"";
$query = "SELECT comment
FROM mycomment
WHERE user_name = '$user_name' <----------
AND movie = '$movie'"; <---------------
$result = mysql_query($query);
if (mysql_num_rows($result)!= 1){
echo "No entry match that date";
}
else {
这两个太早来了。。。。
所以$user_name 和 $movie的value是空的
如果你不信的话可以这样
$comment = isset($_GET["comment"])?$_GET["comment"]:"";
$query = "SELECT comment
FROM mycomment
WHERE user_name = '$user_name'
AND movie = '$movie'";
$result = mysql_query($query);
echo $user_name; <--------
echo $movie; <----------
if (mysql_num_rows($result)!= 1){
echo "No entry match that date";
}
else {
else { |
|
|
|
|
|
|
|
楼主 |
发表于 16-8-2006 02:22 PM
|
显示全部楼层
回复 #33 红发 的帖子
是这样吗?谢谢指教...
<HTML>
<BODY>
<TABLE BORDER=0 CELLPADDING=10 WIDTH=100%>
<TR>
<TD BGCOLOR="#FOF8FF" ALIGN=CENTER VALIGN=TOP WIDTH=17%>
</TD>
<TD BGCOLOR="#FFFFFF" ALIGN=LEFT VALIGN=TOP WIDTH=83%>
<H3>Comment edit</H3>
<FORM METHOD="POST" ACTION="comment_edit.php?action=load">
<P><b>Username:</b><br>
<INPUT TYPE=TEXT NAME="user_name" SIZE=20 VALUE=""></P>
<B>Select movie:</B><br />
<SELECT NAME ="movie">
<OPTION VALUE="">Choose....</OPTION>
<OPTION VALUE="Superman return">Superman return</OPTION>
<OPTION VALUE="Pirate of the carribean 2">Pirate of the carribean 2</OPTION>
<OPTION VALUE="Lady in the water">Lady in the water</OPTION>
</SELECT><BR>
<TEXTAREA NAME="comment" COLS=50 ROWS=10>$comment</TEXTAREA>
<BR></P>
<INPUT TYPE="SUBMIT" NAME="submit" VALUE="Submit"></P>
</FORM>
</TD></TR></TABLE>
</BODY>
</HTML>
<?php
$action = isset($_GET["action"])?$_GET["action"]:"";
if ($action == 'load') {
extract($_POST);
include("dbfinfo.inc.php");
mysql_connect("localhost",$username,$password);
@mysql_select_db($database) or die (" Unable to select database");
$user_name = $_POST['user_name'];
$movie = $_POST['movie'];
$new_date = date('Ymd');
$comment = isset($_GET["comment"])?$_GET["comment"]:"";
$query = "SELECT comment
FROM mycomment
WHERE user_name = '$user_name'
AND movie = '$movie'";
$result = mysql_query($query);
if (mysql_num_rows($result)!= 1){
echo "No entry match that date";
}
else {
$query = "UPDATE mycomment
SET comment = '$comment', date = '$new_date'
WHERE movie = '$movie'
AND user_name = '$user_name'";
$result = mysql_query($query);
if (mysql_affected_rows() == 1) {
echo '<P>Your comment has been updated.<P>';
}
else {
echo '<P>Something went wrong.</P>';
}
}
}
?> |
|
|
|
|
|
|
|
发表于 16-8-2006 11:50 PM
|
显示全部楼层
回复 #34 小今 的帖子
其实不用问我怎样的,
只要出来的result是你要的就可以了。
有问题在问吧。 |
|
|
|
|
|
|
|
楼主 |
发表于 5-9-2006 09:00 PM
|
显示全部楼层
忘了密码,填写Email后,系统会send密码去Email的Code,
有问题
forgot_password.php
<html>
<body>
<BODY>
<TABLE BORDER=0 CELLPADDING=10 WIDTH=100% >
<TR>
<TD BGCOLOR="#FOF8FF" ALIGN=center VALIGN=top WIDTH=17%>
</TD>
<TD BGCOLOR="#FFFFFF" ALIGN=left VALIGN=top WIDTH=100%>
<strong>Enter your email : </strong>
<form name="form1" method="post" action="send_password_ac.php">
<input name="email_to" type="text" id="mail_to" size="25">
<input type="submit" name="Submit" value="Submit">
</form>
</td>
</tr>
</table>
</body>
</html>
send_password_ac.php
<?php
include("dbfinfo.inc.php");
mysql_connect("localhost",$username,$password);
@mysql_select_db($database) or die (" Unable to select database");
// value sent from form
$email_to=$_POST['email_to'];
// retrieve password from table where e-mail = $email_to(mark@phpeasystep.com)
$sql="SELECT password1 FROM user WHERE email='$email_to'";
$result=mysql_query($sql);
// if found this e-mail address, row must be 1 row
// keep value in variable name "$count"
$count=mysql_num_rows($result);
// compare if $count =1 row
if($count==1){
$rows=mysql_fetch_array($result);
// keep password in $your_password
$your_password=$rows['password1'];
// ---------------- SEND MAIL FORM ----------------
// send e-mail to ...
$to='email_to';
// Your subject
$subject="Your password here";
// From
$header="from: your name <your email>";
// Your message
$messages= "Your password for login to our website \r\n";
$messages.="Your password is $your_password \r\n";
$messages.="more message... \r\n";
// send email
$sentmail = mail($to,$subject,$messages,$header);
}
// else if $count not equal 1
else {
echo "Not found your email in our database";
}
// if your email succesfully sent
if($sentmail){
echo "Your Password Has Been Sent To Your Email Address.";
}
else {
echo "Cannot send password to your e-mail address";
}
?>
以下是我的问题....
我应该再php.ini的SMTP换什么??
[mail function]
; For Win32 only.
SMTP = localhost
localhost 要换去什么????
谢谢帮忙
Warning: mail(): Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in c:\program files\easyphp1-8\www\cinema\send_password_ac.php on line 45
Cannot send password to your e-mail address |
|
|
|
|
|
|
|
发表于 6-9-2006 12:46 AM
|
显示全部楼层
localhost should change to smtp server ip address. example mail.xxxx.com.my, smtp.time.net.my, and etc. you must had your smtp ip address in order to send mail. |
|
|
|
|
|
|
|
楼主 |
发表于 6-9-2006 10:32 AM
|
显示全部楼层
回复 #37 8years 的帖子
要自己create的吗?是不是在Microsoft Outlook Express create smtp ip address 呢?谢谢............ |
|
|
|
|
|
|
|
发表于 6-9-2006 09:35 PM
|
显示全部楼层
yes, is something that you set at outlook to send out mail |
|
|
|
|
|
|
|
楼主 |
发表于 6-9-2006 11:56 PM
|
显示全部楼层
回复 #39 8years 的帖子
我已经在Microsoft Outlook 那儿set 了 account (localhost).Incoming mail(POP3)和Outgoing mail(SMTP) set 了 localhost.在php.ini 的 SMTP remain localhost ,sendmail_from = me@localhost.But seemed problem can't solve.Or should I set another account(pop.streamyx.com) and my Incoming mail(POP3) as pop.streamyx.com and Outgoing mail(SMTP) as smtp.streamyx.com 在 Microsoft Outlook ,在php.ini 的 SMTP changed to smtp.streamyx.com ,sendmail_from = mywei00@streamyx.com.The pop.streamyx.com 的account is set as default.I have two mail account now i have been try this two but problem still the same......
Warning: mail(): Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in c:\program files\easyphp1-8\www\cinema\send_password_ac.php on line 45
Cannot send password to your e-mail address |
|
|
|
|
|
|
| |
本周最热论坛帖子
|