[Scottish] php and my sql

Ismail Murat Dilek scottish at mailman.lug.org.uk
Wed Feb 12 12:58:03 2003


--------------070600040809040605060603
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit

Hi
Siilly me. Removing redirect header to out side for loop solved the problem.
Murat

Graeme Chambers wrote:

>Hi,
>
>The For loop on first execution sends the redirect header based on first
>test 9i.e. first email address returned from database).
>
>Suggest you include email address from form into SELECT query and decide
>what to do on basis of number of records returned.
>
>HTH
>
>Graeme
>
>On Tue, 2003-02-11 at 12:22, Ismail Murat Dilek wrote:
>  
>
>>Hi,
>>I ve created a mysql database. Basically user fills  the form then  hits 
>>submit button and  all data posted to mysql database.This part works fine.
>>Next time user return the page enters their email address and hits 
>>submit button. my php script
>>check if email address exist in our database if exist takes user to 
>>download page, if not exist takes them to registration page.
>>Some strange reason this comparasing is not working properly. it works 
>>for some email addresses,
>>e.g. my email address olive@zoom.co.uk is registered in mysql database 
>>so script should take to download page but it is taking me registration 
>>page instead
>>any ideas
>><?
>>//Author: Ismail Murat Dilek
>>
>>require("conn.php");
>>/// ========================================================
>>// following part read values of entered details and prepares them for 
>>mysql data input format
>>
>>$email = $HTTP_POST_VARS["email"];
>>///========================================================
>>
>>
>>$query ="Select email from details"; // selects email field from details 
>>table
>>$result = mysql_query($query); //executes sql select query
>>$num_result = mysql_num_rows($result);
>>/* searches database for email, if email dosent exist writes details to
>>database,then redirects user to download page
>>*/
>>for ($i=0; $i<$num_result; $i++)
>>{
>>    $row= mysql_fetch_array($result);
>>    $eml = stripslashes($row[email]);
>>    $email = trim($email);
>>    $eml = trim($eml);
>>    $eq = strcmp($email,$eml);
>>    if ($eq != 0)
>>    {
>>    header("Location:register.php");
>>   
>>    }
>>    else
>>    {
>>    header("Location:download.php");
>>    }
>>   
>>   
>>   
>>}//end for
>>
>>?>
>>
>>    
>>
>
>
>
>_______________________________________________
>Scottish mailing list
>Scottish@mailman.lug.org.uk
>http://mailman.lug.org.uk/mailman/listinfo/scottish
>
>
>  
>


--------------070600040809040605060603
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1">
  <title></title>
</head>
<body>
Hi<br>
Siilly me. Removing redirect header to out side for loop solved the problem.<br>
Murat<br>
<br>
Graeme Chambers wrote:<br>
<blockquote type="cite"
 cite="mid1044969027.5746.85.camel@xena.graeme-chambers.co.uk">
  <pre wrap="">Hi,

The For loop on first execution sends the redirect header based on first
test 9i.e. first email address returned from database).

Suggest you include email address from form into SELECT query and decide
what to do on basis of number of records returned.

HTH

Graeme

On Tue, 2003-02-11 at 12:22, Ismail Murat Dilek wrote:
  </pre>
  <blockquote type="cite">
    <pre wrap="">Hi,
I ve created a mysql database. Basically user fills  the form then  hits 
submit button and  all data posted to mysql database.This part works fine.
Next time user return the page enters their email address and hits 
submit button. my php script
check if email address exist in our database if exist takes user to 
download page, if not exist takes them to registration page.
Some strange reason this comparasing is not working properly. it works 
for some email addresses,
e.g. my email address <a class="moz-txt-link-abbreviated" href="mailto:olive@zoom.co.uk">olive@zoom.co.uk</a> is registered in mysql database 
so script should take to download page but it is taking me registration 
page instead
any ideas
&lt;?
//Author: Ismail Murat Dilek

require("conn.php");
/// ========================================================
// following part read values of entered details and prepares them for 
mysql data input format

$email = $HTTP_POST_VARS["email"];
///========================================================


$query ="Select email from details"; // selects email field from details 
table
$result = mysql_query($query); //executes sql select query
$num_result = mysql_num_rows($result);
/* searches database for email, if email dosent exist writes details to
database,then redirects user to download page
*/
for ($i=0; $i&lt;$num_result; $i++)
{
    $row= mysql_fetch_array($result);
    $eml = stripslashes($row[email]);
    $email = trim($email);
    $eml = trim($eml);
    $eq = strcmp($email,$eml);
    if ($eq != 0)
    {
    header("Location:register.php");
   
    }
    else
    {
    header("Location:download.php");
    }
   
   
   
}//end for

?&gt;

    </pre>
  </blockquote>
  <pre wrap=""><!---->


_______________________________________________
Scottish mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Scottish@mailman.lug.org.uk">Scottish@mailman.lug.org.uk</a>
<a class="moz-txt-link-freetext" href="http://mailman.lug.org.uk/mailman/listinfo/scottish">http://mailman.lug.org.uk/mailman/listinfo/scottish</a>


  </pre>
</blockquote>
<br>
</body>
</html>

--------------070600040809040605060603--