the_infamous_don Posted March 13, 2007 Share Posted March 13, 2007 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 https://forums.phpfreaks.com/topic/42566-hello-please-help-with-this-redirect-problem/ Share on other sites More sharing options...
aebstract Posted March 13, 2007 Share Posted March 13, 2007 header("Cache-control: private"); Try adding that to the VERY top of your page Link to comment https://forums.phpfreaks.com/topic/42566-hello-please-help-with-this-redirect-problem/#findComment-206560 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.