Jump to content

Hello. Please help with this redirect problem


the_infamous_don

Recommended Posts

Hello. I am new to php so I am not an expert. I need help with my code. It gives me the header error when I try to use the old header(location:www.etc.com) code. I would like to redirect to a different page for each function defined. I have left the header code in line 91, which does not work and returns the error. Please help.

 

<?php

  extract($_POST);

  setcookie("uname",$username,time()+1200);

  setcookie("pword",$password,time()+1200);

?>

 

 

      <?php

        if (!$username||!$password)

        {

            //No data entered

            fieldsblank();

            die();

        }

        else

        {

            $location = "ftemysql";$accountname = "ku12881";

            $pword = "carstairs";$database = "ku12881";

            $conn=mysql_connect("$location","$accountname","$pword");

            mysql_select_db($database,$conn);

            mysql_query("CREATE TABLE usertable (username VARCHAR(10),password VARCHAR(10))");

 

            if (isset($newuser))

            {

              //New User

              $query="SELECT * FROM usertable WHERE username='$username'";

              $result=mysql_query($query);

              $entry=mysql_fetch_array($result);

              if ($entry)

              {

                  usernametaken($username);

                  mysql_close($conn);

                  die();               

              }

              $query="INSERT INTO usertable (username,password) VALUES ('$username','$password')";

              mysql_query($query);

              useradded($username);

              mysql_close($conn);

              die();

            }

            else

            {

              //Existing User

              $query="SELECT * FROM usertable WHERE username='$username'";

              $result=mysql_query($query);

              $entry=mysql_fetch_array($result);

              if (!$entry)

              {

                  nosuchuser($username);

                  mysql_close($conn);

                  die();

              }

              else

              {

                  if ($entry[password]!=$password)

                  {

                    userreject($username);

                    mysql_close($conn);

                    die();

                  }

              }

            } ?>           

           

                   

 

            <?php mysql_close($conn);

        }

 

        function fieldsblank()

        {

            print("<title>Access Denied</title>

                  </head><body><p>Information incomplete.</p></body></html>");

        }

 

        function usernametaken($name)

        {

            print("<title>User Name Taken</title></head>

                  <body><p>Sorry, the name $name has already been taken.</p></body></html>");

        }

 

        function useradded($name)

        {

            print("<title>New User</title></head>

                  <body><p>You have now been added to the user list.</p>

                  <p>Return to the previous page and log in.</p></body></html>");

        }

 

        function nosuchuser($name)

        {

     

header( 'Location: http://www.me.com/phone.html' ) ;

 

           

        }

 

        function userreject($name)

        {

            print("<title>Reject</title></head>

                  <body><p>Password supplied does not correspond

                  to that of user $name.</p></body></html>");

        }

      ?>

 

 

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.