循环,php和mysql数据 [英] loops, php and mysql data

查看:69
本文介绍了循环,php和mysql数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

祝福所有人。我正在编写一个配置文件创建者脚本,用户在其邮件中获取

a URL邀请;

http://domain.com/profile-create.php...d98jadf098asdf


事情很顺利,除了一个小麻烦,其中某人

可能有解决方案。


如果有人访问个人资料 - create.php没有

access_code脚本生成警告。如果有一个access_code

与MySQL数据库中输入的访问代码相匹配,则他们将

定向到配置文件创建页面。我的问题是;


如果有人使用access_code访问profile-create.php,但是

不匹配数据库中的任何条目我想要生成

警告。


当我尝试使用else语句执行此操作时,每次访问都会产生错误

数据库中列出的代码不是正确的,

所以我最终会得到一个成功的个人资料创建页面,其中有一堆

的错误。


我玩过休息和模式匹配,但没有结果。这是下面的脚本


Greetings all. I am writing a profile creator script where a user gets
a URL invite in their mail in the form of;

http://domain.com/profile-create.php...d98jadf098asdf

Things are working well except for a small annoyance in which someone
might have a solution to.

In the event that someone accesses profile-create.php without an
access_code the script generates a warning. If there is an access_code
that matches the access code entered in the MySQL database then they
are directed to the profile creation page. My problem is;

If someone accesses profile-create.php with an access_code but it
doesn''t match any entries in the database I would like to generate a
warning.

When I try to do this with an else statement it produces an error for
every access code listed in the database which isn''t the correct one,
so I could end up with a successful profile creation page with a bunch
of errors.

I''ve played with break and pattern matching but no results. Here is
the script below.

------------------------ ---------------------------------------<


<?php


$ access_code = $ _GET [''access_code''];


if($ access_code){


echo db_connect();


$ result = mysql_query(''SELECT random_link FROM invites' ');


while($ row = mysql_fetch_array($ result,MYSQL_NUM)){


$ random_link_db = $ row [0];


if($ random_link_db == $ access_code){

echo profile_creator_page();

}


//想在这里插入错误警告


}

}


否则{

echo"错误!"

}

function profile_creator_page(){

echo"一切都很好!" ;;

}


?>

--------- -------------------------------------------------- ----<
---------------------------------------------------------------<
<?php

$access_code = $_GET[''access_code''];

if ($access_code) {

echo db_connect();

$result = mysql_query(''SELECT random_link FROM invites'');

while ($row = mysql_fetch_array($result, MYSQL_NUM)) {

$random_link_db = $row[0];

if ($random_link_db == $access_code) {
echo profile_creator_page();
}

// Would like to insert an error warning here

}
}

else {
echo "Error!"
}
function profile_creator_page() {
echo "All''s well!";
}

?>
---------------------------------------------------------------<




有什么想法吗?


问候,

Luc



Any ideas?

Regards,
Luc

推荐答案

ac cess_code =
access_code =


_GET [''access_code''];


if(
_GET[''access_code''];

if (


access_code){


echo db_connect();

access_code) {

echo db_connect();


这篇关于循环,php和mysql数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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