Jump to content

Why wont this work?


dlouis95

Recommended Posts

In the script provided, at if($email==$email2), it says it is false when I know it's true. I know that the cookie is the same as the email in the database, yet it sill wont work. I have even echoed the two to see myself if they were the same, and they were, yet it still is saying it's false. Anyone know whats up? Thanks! :)

 

if(isset($_COOKIE['dan']))

  {

  $email=$_COOKIE['dan'];

  $host = ...;

    $username = ...;

    $password = ...;

  $db_name = ...;

  $tbl_name = ...;

  mysql_connect("$host", "$username", "$password")or die("cannot connect");

  mysql_select_db("$db_name")or die("cannot select DB");

 

  $user=$_GET['username'];

 

  if(mysql_num_rows(mysql_query("SELECT username FROM $tbl_name WHERE username = '$user'")))

      {

      $sql="SELECT * FROM $tbl_name WHERE username='$user'";

      $result=mysql_query($sql);

      $rows=mysql_fetch_array($result);

      $email2=$rows['email']; 

        if($email == $email2)

            {

              ?><html>...</html><?

                }

            else

            {

            ...

Link to comment
https://forums.phpfreaks.com/topic/203323-why-wont-this-work/
Share on other sites

Check the string length of each item. Maybe there's a space before/after one of the values.

 

BTW, you really shouldn't use any value gotten from the URL without sanitizing it.

 

<?php
$user=mysql_real_escape_string($_GET['username']);
?>

 

Ken

Link to comment
https://forums.phpfreaks.com/topic/203323-why-wont-this-work/#findComment-1065224
Share on other sites

Check the string length of each item. Maybe there's a space before/after one of the values.

 

BTW, you really shouldn't use any value gotten from the URL without sanitizing it.

 

<?php
$user=mysql_real_escape_string($_GET['username']);
?>

 

Ken

 

Thanks man! Turns out my problem was nothing(space before $email)! Thanks for telling me to sanitize the url value. I haven't gotten to that yet, but have done it for forum entry's.

Link to comment
https://forums.phpfreaks.com/topic/203323-why-wont-this-work/#findComment-1065227
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.