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.---------------------------------------------------------------<
$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!";
}
?>
---------------------------------------------------------------<
Any ideas?
Regards,
Luc
解决方案
access_code =
_GET[''access_code''];
if (
access_code) {
echo db_connect();