Closed Thread Icon

Topic awaiting preservation: php header problem... (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=12959" title="Pages that link to Topic awaiting preservation: php header problem... (Page 1 of 1)" rel="nofollow" >Topic awaiting preservation: php header problem... <span class="small">(Page 1 of 1)</span>\

 
shalvi
Nervous Wreck (II) Inmate

From:
Insane since: Oct 2003

posted posted 10-30-2003 04:12

what I want to do is to ridirect the same registration page after checking the database that if the E-mail address is already provided by someonelse as E-mail address is the unique identifier...but following code everytime redirects the page..no matter that email address exists or doesn't.....any help pls.
and aslo is there any way to show some message in the page "that email address is already taken try with different one"? how to do that?

code
------------------------------------------------------------------------------------------------
<?php
$dbh=mysql_connect ("localhost", "root", "pass") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("tuitionbd");

if (!$dbh) {
echo( "<P>Unable to connect to the " .
"database server at this time.</P>" );
exit();
}
// Select the jokes database
if (! @mysql_select_db("tuitionbd") ) {
echo( "<P>Unable to locate the TUITIONBD " .
"database at this time.</P>" );
exit();
}
$result=mysql_query("SELECT email FROM tutor WHERE email='$email'");
//here $email is a FORM value put by the user
if ($result)//here i want to redirect the the page if corresponding email address found
//in the database
{
header("Location: http://www.tuitionbd.com/register.php");
exit();
}
mysql_close($dbh);
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
//here all html portion......

butcher
Paranoid (IV) Inmate

From: New Jersey, USA
Insane since: Oct 2000

posted posted 10-30-2003 04:17

I think instead of doing:

$result=mysql_query("SELECT email FROM tutor WHERE email='$email'");
if ($result) {

You should maybe try something like:

$result=mysql_query("SELECT email FROM tutor WHERE email='$email'");
if (mysql_num_rows($result) > 0){

Give it a shot and see what happens.

-Butcher-

Tyberius Prime
Paranoid (IV) Mad Scientist with Finglongers

From: Germany
Insane since: Sep 2001

posted posted 10-30-2003 12:00

yeah, even if mysql returs 0 rows, it's return value is a resourceID (don't worry), that will never be false.
except of course your query's syntactically wrong. then it'll return false.

shalvi
Nervous Wreck (II) Inmate

From:
Insane since: Oct 2003

posted posted 10-31-2003 07:23

thanx dude....it's working fine...

« BackwardsOnwards »

Show Forum Drop Down Menu