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>");

        }

      ?>

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.