[PHP] Forms and PHP_SELF
Hi, I have a very simple form that searches a MySQL database and I want to be able to have the search appear on the same page as the search. The part that confuses me is how I run the code for the search. Currently I have it in a function and at the top of the script I have an IF statement that checks to see if the submit button has been pressed, if it has I go to the function. This is not working, and I'm not even sure this is the right way to go about it. I'm probably doing this wrong and would appreciate it if someone could set me straight. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] FW: Forms and PHP_SELF
I just figured it out, so I guess I was on the right track - I just forgot to make the variable name in the form global. -Original Message- From: Beauford.2005 [mailto:[EMAIL PROTECTED] Sent: July 5, 2003 7:43 PM To: PHP Subject: Forms and PHP_SELF Hi, I have a very simple form that searches a MySQL database and I want to be able to have the search appear on the same page as the search. The part that confuses me is how I run the code for the search. Currently I have it in a function and at the top of the script I have an IF statement that checks to see if the submit button has been pressed, if it has I go to the function. This is not working, and I'm not even sure this is the right way to go about it. I'm probably doing this wrong and would appreciate it if someone could set me straight. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] MySQL query problems
Hi, Not sure if the problem here is PHP or MySQL, but here we go. I am trying to do two queries on a database - one after the other, but the second one never seems to get executed. The two queries are identical except for two variables. I have checked my form and they are correct and are being sent to the PHP script the way they should be. The variables are $playerto, $playerfrom, $nameto, $namefrom. The 'TO' query is the one that doesn't work. Here is my code. Any help is appreciated. if ($namefrom != $nameto) { if ($playerfrom != $playerto) { include("2004server.inc"); if($error) { include("trades-input.php"); exit; } $query1 = "select manager.idn, manager.total, roster.idp, position, points from roster join reference join manager where manager.idn=reference.idn and reference.idp=roster.idp and manager.idn like '$namefrom' and roster.idp like '$playerfrom'"; $result1 = mysql_query($query1) or $mysqlerror = mysql_error(); if ($mysqlerror) { $error = "$d_base_error$email_error"; include("trades-input.php"); exit; } $line = mysql_fetch_row($result1); mysql_free_result($result1); $query2 = "select manager.idn, manager.total, roster.idp, position, points from roster join reference join manager where manager.idn=reference.idn and reference.idp=roster.idp and manager.idn like '$nameto' and roster.idp like '$playerto'"; $result2 = mysql_query($query2) or $mysqlerror = mysql_error(); if ($mysqlerror) { $error = "$d_base_error$email_error"; include("trades-inputs.php"); exit; } $row = mysql_fetch_array($result2); mysql_free_result($result2); } } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] MySQL query problems
I tried that, but there is no error to stop the script at this point. The script continues past this point and to the end of the script - there are just no values in the variables for the second query, which obviously gives me the wrong results. -Original Message- From: Marek Kilimajer [mailto:[EMAIL PROTECTED] Sent: July 16, 2003 1:18 PM To: Beauford.2005 Cc: PHP Subject: Re: [PHP] MySQL query problems Change $email_error to $mysqlerror and hopefully some error message will appear. Beauford.2005 wrote: > if ($mysqlerror) { > $error = "$d_base_error$email_error"; > include("trades-input.php"); > exit; > } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Re: MySQL query problems
Not sure what the problem was, but I dug up a similar script I used for something else and modifed it for this project, and voila. I then put the two side by side and I still can't see where the problem is. Thanks for the input. -Original Message- From: Nomadeous [mailto:[EMAIL PROTECTED] Sent: July 16, 2003 5:31 PM To: [EMAIL PROTECTED] Subject: [PHP] Re: MySQL query problems But what's your prob ? When you say the second one seems to never be executed ... Does the line: $row = mysql_fetch_array($result2); launches a Php Error ? And pay attention, because you're using mysql_fetch_array and mysql_fetch_row, be sure that you are not treating the result in the same way ;-) "Beauford.2005" <[EMAIL PROTECTED]> a écrit dans le message de news: [EMAIL PROTECTED] > Hi, > > Not sure if the problem here is PHP or MySQL, but here we go. I am > trying to do two queries on a database - one after the other, but the > second one never seems to get executed. The two queries are identical > except for two variables. I have checked my form and they are correct > and are being sent to the PHP script the way they should be. > > The variables are $playerto, $playerfrom, $nameto, $namefrom. The 'TO' > query is the one that doesn't work. > > Here is my code. Any help is appreciated. > > if ($namefrom != $nameto) { > if ($playerfrom != $playerto) { > > include("2004server.inc"); > if($error) { > include("trades-input.php"); > exit; > } > > $query1 = "select manager.idn, manager.total, > roster.idp, position, points from roster join reference > join manager where manager.idn=reference.idn and > reference.idp=roster.idp and manager.idn like '$namefrom' and > roster.idp like '$playerfrom'"; > > $result1 = mysql_query($query1) or $mysqlerror = mysql_error(); > if ($mysqlerror) { > $error = "$d_base_error$email_error"; > include("trades-input.php"); > exit; > } > > $line = mysql_fetch_row($result1); > > mysql_free_result($result1); > > $query2 = "select manager.idn, manager.total, > roster.idp, position, points from roster join reference > join manager where manager.idn=reference.idn and > reference.idp=roster.idp and manager.idn like '$nameto' and roster.idp > like '$playerto'"; > > $result2 = mysql_query($query2) or $mysqlerror = mysql_error(); > if ($mysqlerror) { > $error = "$d_base_error$email_error"; > include("trades-inputs.php"); > exit; > } > > $row = mysql_fetch_array($result2); > > mysql_free_result($result2); > } > } > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Reading files question
I have a file that has the 130 lines which follows the example below. Barnaby What I need to do is read this file, remove one line, add another line, and then resave it. I have tried the different fget functions etc. to read the file, but all I get is the name part and nothing else. I am assuming it has to do with the <,", or = in the line, so how would I read in the entire line. TIA -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Reading files question
I found the answer. I was looking through the PHP manual and found htmlspecialchars() which did the trick. B -Original Message- From: Beauford.2005 [mailto:[EMAIL PROTECTED] Sent: July 16, 2003 8:50 PM To: PHP Subject: Reading files question I have a file that has the 130 lines which follows the example below. Barnaby What I need to do is read this file, remove one line, add another line, and then resave it. I have tried the different fget functions etc. to read the file, but all I get is the name part and nothing else. I am assuming it has to do with the <,", or = in the line, so how would I read in the entire line. TIA -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Still problem with files
Hi, Sorry for the extra emails, but I thought I had this licked, but now other problem pop up. As I said, I have a file with many lines like Alfredsson in it. I have been able to read the file into an array and display it, but I am trying to do a comparison IF statement and no matter what I try I can't figure out what to compare. To explain better here is my code so far. $filename = "players.inc"; $fd = fopen ($filename, "r"); while (!feof ($fd)) { $buffer = fgets($fd); $list[] = $buffer; } fclose ($fd); for($i = 0; $i < 131; $i++) { if($list[$i] != ? { echo "".htmlspecialchars($list[$i]); } } So using the example above what would I use where the question marks are if I wanted to display everything but this line - Alfredsson. I have tried a variety of ways to do this: i.e $p = "Alfredsson"; for($i = 0; $i < 131; $i++) { if(htmlspecialchars($list[$i]) != $p) { echo "".htmlspecialchars($list[$i]); } } This is just a sample script that I want to get running before I actuaaly put it into use, so any help is appreciated. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Still problem with files
For whatever reason your suggestions still caused me problems, but I did come up with a solution that works. if (preg_match ("/Alfredsson/", $buffer)) Another question though regarding \n. What I'm doing here is reading the file, omitting one entry, adding another, and saving it back to the file. When I add the entry and save it back to the file it appears beside the last entry instead of below it. How do I get it so it is below it. I have tried using a \n but no go. I am probably missing something, but not sure what. This is the first time I've played with files in PHP. i.e. Roy, P Theodore ThibaultWorrel -Original Message- From: Curt Zirzow [mailto:[EMAIL PROTECTED] Sent: July 18, 2003 1:50 AM To: PHP Subject: Re: [PHP] Still problem with files Curt Zirzow <[EMAIL PROTECTED]> wrote: > Beauford.2005 <[EMAIL PROTECTED]> wrote: > > > > i.e > > > > $p = "Alfredsson"; And watch out for case sensitive issues 'Option' != 'option' Curt -- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Still problem with files
Yep, but am I doing it right I don't know. This is the line that will be written to the database (there will be 130 of them). $p = "Player Name"; So where do I put the \r\n. I have tried just \n at the end, but same thing. $p = "Player Name\n"; TIA -Original Message- From: skate [mailto:[EMAIL PROTECTED] Sent: July 18, 2003 11:18 AM To: Beauford.2005; 'Curt Zirzow'; 'PHP' Subject: Re: [PHP] Still problem with files have you tried \r\n ? - Original Message - From: "Beauford.2005" <[EMAIL PROTECTED]> To: "'Curt Zirzow'" <[EMAIL PROTECTED]>; "'PHP'" <[EMAIL PROTECTED]> Sent: Thursday, July 17, 2003 3:40 PM Subject: RE: [PHP] Still problem with files > For whatever reason your suggestions still caused me problems, but I > did come up with a solution that works. > > if (preg_match ("/Alfredsson/", $buffer)) > > Another question though regarding \n. What I'm doing here is reading > the file, omitting one entry, adding another, and saving it back to > the file. When I add the entry and save it back to the file it appears > beside the last entry instead of below it. How do I get it so it is > below it. I have tried using a \n but no go. I am probably missing > something, but not sure what. This is the first time I've played with > files in PHP. > > i.e. > > Roy, P > Theodore > ThibaultWorrel > > -Original Message----- > From: Curt Zirzow [mailto:[EMAIL PROTECTED] > Sent: July 18, 2003 1:50 AM > To: PHP > Subject: Re: [PHP] Still problem with files > > > Curt Zirzow <[EMAIL PROTECTED]> wrote: > > Beauford.2005 <[EMAIL PROTECTED]> wrote: > > > > > > i.e > > > > > > $p = "Alfredsson"; > > And watch out for case sensitive issues > 'Option' != 'option' > > Curt > -- > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] File problems
Hi, I am having a hell of a time with this. Whenever I think it's working, something else screws up. There obviously has to be a better way to do this than I am doing it. To reiterate, I am trying to open a file, remove one entry, add another entry, and resave the file. The way I currently have it works and doesn't work. One time it will work, another time it says it can't write to the file. Can someone may give me an idea of a good way to do this as I am just going around in circles here. TIA. Note. The entries to be added and removed are provided by a form. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Enough is Enough.......
Hi, I apologize for all the emails on this, but I'm truly at a loss here and really need some input as to what I need to do to get this working. I have a FORM with two drop down menus and have the entries saved in two separate .inc files i.e: Alfredsson Arnott Aucoin Audette Etc... Bates Battaglia Berard Bertuzzi Etc The user enters the webpage and chooses a player from list one and list two. This gets submitted to my PHP script which reads in these files and manipulates them accordingly and re-saves them. At the end of the PHP script I include the input file again - include("injury-input.php") - which should now have the updated drop down menus. This seems to work the first time you open up a browser and go to the input page (although I can't really even be sure of that now). If you try to do it again using a different set of players, it doesn't work. I usually end up with two empty files. So it appears it is opening the file the second time ok, but is not writing to it. I have no idea what to do with this. Here is the script: function writeplayer($from_row, $to_row) { include("trade-errors.inc"); $filename = "players.inc"; $fd = fopen ($filename, "r"); $content = ""; while (!feof ($fd)) { $content = fgets($fd); if (preg_match ("/".$to_row['player']."/", $content)) { } else { $list[] = $content; } } fclose ($fd); $num = count($list); $list[$num] = "\r\n".$from_row['player']; $num = count($list); $list = preg_replace('/(<.*?>)(.*)/', '$2$1', $list); sort ($list); $list = preg_replace('/(.*?)(<.*>)/', '$2$1', $list); if (is_writable($filename)) { if (!$fp = fopen($filename, 'w')) { $injury_errors = $playeropens; include("injury-input.php"); exit; } for($i=0; $i < $num; $i++) { if (!fwrite($fp, $list[$i])) { $injury_errors = $playerwrite; include("injury-input.php"); exit; } } fclose($fp); } else { $injury_errors = $notwritable; include("injury-input.php"); exit; } unset($list); unset($content); unset($num); unset($filename); unset($fd); unset($fp); writereserve($from_row, $to_row); $injury_errors = $updated; return($injury_errors); } function writereserve($from_row, $to_row) { include("trade-errors.inc"); $filename = "players-reserve.inc"; $fd = fopen ($filename, "r"); $content = ""; while (!feof ($fd)) { $content = fgets($fd); if (preg_match ("/".$from_row['player']."/", $content)) { } else { $list[] = $content; } } fclose ($fd); $num = count($list); if (is_writable($filename)) { if (!$fp = fopen($filename, 'w')) { $injury_errors = $playeropens; include("injury-input.php"); exit; } for($i=0; $i < $num; $i++) { if (!fwrite($fp, $list[$i])) { $injury_errors = $playerwrite; include("injury-input.php"); exit; } } fclose($fp); } else { $injury_errors = $notwritable; include("injury-input.php"); exit; } $injury_errors = $updated; unset($list); unset($content); unset($num); unset($filename); unset($fd); unset($fp); return($injury_errors); } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Enough is Enough.......
Done. You must have read my mind. I just finished putting the whole thing in MySQL - since I am using it anyway to hold all my other data it was easy to do. Took me about 45 minutes to do this as opposed to a week with the other, and it still didn't work. I'd still be curious to why the other is didn't work though. I know my logic is correct, but maybe what I was trying to do just wasn't feasible. Thanks for the input. -Original Message- From: Curt Zirzow [mailto:[EMAIL PROTECTED] Sent: July 19, 2003 2:33 AM To: PHP Subject: Re: [PHP] Enough is Enough... Beauford.2005 <[EMAIL PROTECTED]> wrote: > Hi, Hello > [...] > > $list = preg_replace('/(<.*?>)(.*)/', '$2$1', $list); > sort ($list); > $list = preg_replace('/(.*?)(<.*>)/', '$2$1', $list); what is list after the first preg and after the second one, that regex doesn't look safe to me. Do you have access to a database? This task would be a whole lot easier to do, plus a whole lot more safer. Curt -- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Still problem with files
These files were already done from last year, so I figured I would just carry on with them. Last year they did not have to be manipulated - so it wasn't a big deal. I have since changed the whole thing and am now using a database (took me a whole 45 minutes), which I was using anyway to hold all my other info. I'd still be curious though as to why the other way did not work. -Original Message- From: Jason Wong [mailto:[EMAIL PROTECTED] Sent: July 19, 2003 1:34 AM To: [EMAIL PROTECTED] Subject: Re: [PHP] Still problem with files On Saturday 19 July 2003 04:58, Beauford.2005 wrote: > Yep, but am I doing it right I don't know. This is the line that will > be written to the database (there will be 130 of them). > > $p = "Player Name"; > > So where do I put the \r\n. I have tried just \n at the end, but same > thing. > > $p = "Player Name\n"; It beats me why you're not storing the info in a DB rather than a file. Anyway here's some psuedo-code: $file = file('file); foreach ($file as $line => $data) { $file[$line] = trim($data); if (!strcmp($what_you_are_looking_for, $file[$line])) { // found, do your replacement stuff } } implode('choose a suitable EOL character(s)', $file); write_out_file(); -- Jason Wong -> Gremlins Associates -> www.gremlins.biz Open Source Software Systems Integrators * Web Design & Hosting * Internet & Intranet Applications Development * -- Search the list archives before you post http://marc.theaimsgroup.com/?l=php-general -- /* GOOD-NIGHT, everybody ... Now I have to go administer FIRST-AID to my pet LEISURE SUIT!! */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Still problem with files
I've kept the code in a temp file so when I get some time I will delve into it further. Certainly more of a pain than I expected. -Original Message- From: Jason Wong [mailto:[EMAIL PROTECTED] Sent: July 20, 2003 4:45 AM To: [EMAIL PROTECTED] Subject: Re: [PHP] Still problem with files On Monday 21 July 2003 00:23, Beauford.2005 wrote: > These files were already done from last year, so I figured I would > just carry on with them. Last year they did not have to be manipulated > - so it wasn't a big deal. I have since changed the whole thing and am > now using a database (took me a whole 45 minutes), which I was using > anyway to hold all my other info. I'd still be curious though as to > why the other way did not work. If it's not obvious from examining the code then you have to get down to some serious debugging. Most importantly you need to: - incorporate error checking into your code, examine the values returned from all functions - var_dump() all your major variables and verify that they are what you expect them to be -- Jason Wong -> Gremlins Associates -> www.gremlins.biz Open Source Software Systems Integrators * Web Design & Hosting * Internet & Intranet Applications Development * -- Search the list archives before you post http://marc.theaimsgroup.com/?l=php-general -- /* What's all this brouhaha? */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Redirection Question
Hi, I am trying to figure out how to redirect a user back to a page but not having much luck. For example: I click on a menu item on my site which goes to a.php. This file includes another file that determines if they are logged in or not. If not, they are sent to login.php using header(:Location: ). How would I automatically redirect them back to a.php after they have logged in successfully. I have tried using HTTP_REFERRER, but it isn't redirecting. Any help is appreciated. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Redirection Question
Nope. What if it's b.php, or c.php. They could come from many pages. I wish it was that easy. -Original Message- From: Chris W. Parker [mailto:[EMAIL PROTECTED] Sent: July 22, 2003 4:02 PM To: Beauford.2005 Subject: RE: [PHP] Redirection Question Beauford.2005 <mailto:[EMAIL PROTECTED]> on Wednesday, July 23, 2003 12:44 PM said: > How would I automatically redirect them back to a.php after they have > logged in successfully. header("Location: a.php"); chris. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Redirection Question (I spoke to soon)
Sorry all, apparently this doesn't work on either Windows or Linux. Again, I thought it was working and once I got farther along I see that it really wasn't. Basically what I get after I login is an empty screen. Here is what I have : This is the script that runs to see if the user is logged in. session_start(); if(!$_SESSION['logged']) { session_register('goto'); $_SESSION['goto'] = "http://"; . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']; $url = "http://www.mysite.org/login/login.php";; header("Location: $url"); } The above works and redirects me to the login page and has the right referring page as shown below. goto|s:59:"http://www.mysite.org/setup/inputs.php";; This is in my login.php script. After I verify the user login is correct, this piece of code is executed. session_start(); session_register('logged'); session_register('user'); $_SESSION['logged'] = "True"; $_SESSION['user'] = $row['user']; $target = "Location: " . $_SESSION['goto']; session_unregister('goto'); header($target); What I get after this is a blank page. The user has been logged in and shows in the session file, but it just isn't redirecting. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Redirection Question
Maybe I didn't explain enough. What if they come from b.php or c.php. How do I automatically log what page they tried to access. So hard coding login.php?next=a.php would only work for one page. TIA -Original Message- From: Curt Zirzow [mailto:[EMAIL PROTECTED] Sent: July 22, 2003 4:16 PM To: PHP Subject: Re: [PHP] Redirection Question * Thus wrote Beauford.2005 ([EMAIL PROTECTED]): > Hi, > > I am trying to figure out how to redirect a user back to a page but > not having much luck. > > For example: I click on a menu item on my site which goes to a.php. > This file includes another file that determines if they are logged in > or not. If not, they are sent to login.php using header(:Location: > ). How would I automatically redirect them back to a.php after > they have logged in successfully. I have tried using HTTP_REFERRER, > but it isn't redirecting. You can use the HTTP_REFERRER, but i wouldn't depend on it, it isn't a required header for the client. what you prolbably should do is when the arn't logged int, you can send them to something like: header('location: login.php?next=a.php'); Then on your login form add a hidden variable: Finally when the user submits this form, and the user logs in successfully you know that you need to redirect them to the a.php. HTH, Curt -- "I used to think I was indecisive, but now I'm not so sure." -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Redirection Question
Thanks to all, I got it working - sort of. It works perfectly on Windows, but will not work on Linux. I am using the same versions of PHP, Apache and MySQL on both. I have asked this before and have been told they are interchangeable, but more times than not I have to make a bunch of changes to get it to work on Linux - and this is just another example. I use Windows to do all the coding and design as it has all the tools. Linux is just a bare bones box with no gui or tools. The php.ini and httpd.conf are the same on both platforms (other than what is needed for the specific platform). This makes it a real pain. Oh well, back to my debugging. -Original Message- From: Curt Zirzow [mailto:[EMAIL PROTECTED] Sent: July 22, 2003 7:04 PM To: PHP Subject: Re: [PHP] Redirection Question * Thus wrote Beauford.2005 ([EMAIL PROTECTED]): > Maybe I didn't explain enough. What if they come from b.php or c.php. > How do I automatically log what page they tried to access. So hard > coding login.php?next=a.php would only work for one page. Use the code that Grant Rutherford posted earlier, its the same concept just a whole lot more flexible than mine. Not to mention a bit more secured. Curt -- "I used to think I was indecisive, but now I'm not so sure." -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Re: Redirection Question (I spoke to soon)
Hi, I found one of my problems and also implemented your suggestions, and still the same thing. It will not redirect. The problem I found is that $_SERVER['SERVER_NAME'] does not include the port number. On my Win PC I am using port 800. So I changed this line to: $_SESSION['goto'] = "http://"; . $_SERVER['SERVER_NAME'] .":800" . $_SERVER['REQUEST_URI']; If I take the output from that and put it into my browser is works just fine, but it will not work in the script. This is the portion of the script in question now after I implemented your changes. session_start(); $_SESSION['logged'] = "True"; $_SESSION['user'] = $row['user']; header("Location: " . $_SESSION['goto']); If I echo $_SESSION['goto'] right after session_start() it shows exactly what it should be. So I am at a loss. Ideas?? -Original Message- From: Ray Hunter [mailto:[EMAIL PROTECTED] Sent: July 22, 2003 10:47 PM To: Beauford.2005 Subject: Re: [PHP] Re: Redirection Question (I spoke to soon) Try doing: session_start(); $_SESSION['logged'] = "True"; $_SESSION['user'] = $row['user']; // you cant do this here. // session_unregister('goto'); header( "Location: ".$_SESSION['goto'] ); That should work. -- BigDog On Wed, 2003-07-23 at 19:35, Beauford.2005 wrote: > Sorry all, apparently this doesn't work on either Windows or Linux. > Again, I thought it was working and once I got farther along I see > that it really wasn't. Basically what I get after I login is an empty > screen. Here is what I have : > > This is the script that runs to see if the user is logged in. > > session_start(); > if(!$_SESSION['logged']) { > > session_register('goto'); > $_SESSION['goto'] = "http://"; . $_SERVER['SERVER_NAME'] . > $_SERVER['REQUEST_URI']; > > $url = "http://www.mysite.org/login/login.php";; > header("Location: $url"); > } > > The above works and redirects me to the login page and has the right > referring page as shown below. > > goto|s:59:"http://www.mysite.org/setup/inputs.php";; > > This is in my login.php script. After I verify the user login is > correct, this piece of code is executed. > > session_start(); > session_register('logged'); > session_register('user'); > > $_SESSION['logged'] = "True"; > $_SESSION['user'] = $row['user']; > > $target = "Location: " . $_SESSION['goto']; > > session_unregister('goto'); > > header($target); > > What I get after this is a blank page. The user has been logged in and > shows in the session file, but it just isn't redirecting. > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Re: Redirection Question (I spoke to soon)
Errors are on and I get nothing, it won't even direct if I hard code header("Location: www.microsoft.com"); -Original Message- From: Jason Wong [mailto:[EMAIL PROTECTED] Sent: July 23, 2003 12:48 PM To: [EMAIL PROTECTED] Subject: Re: [PHP] Re: Redirection Question (I spoke to soon) On Thursday 24 July 2003 11:37, Beauford.2005 wrote: > I found one of my problems and also implemented your suggestions, and > still the same thing. It will not redirect. > > The problem I found is that $_SERVER['SERVER_NAME'] does not include > the port number. On my Win PC I am using port 800. So I changed this > line > to: > > $_SESSION['goto'] = "http://"; . $_SERVER['SERVER_NAME'] .":800" . > $_SERVER['REQUEST_URI']; > > If I take the output from that and put it into my browser is works > just fine, but it will not work in the script. [snip] > header("Location: " . $_SESSION['goto']); > > If I echo $_SESSION['goto'] right after session_start() it shows > exactly what it should be. So I am at a loss. Have you checked your error logs? You should always, ALWAYS have error reporting on full, and check for errors. It could be that you're getting an "headers already sent sent" error. Does it work if you have a single line script: header("Location: whatever_$_SESSION['goto']_is_supposed_to_be"); -- Jason Wong -> Gremlins Associates -> www.gremlins.biz Open Source Software Systems Integrators * Web Design & Hosting * Internet & Intranet Applications Development * -- Search the list archives before you post http://marc.theaimsgroup.com/?l=php-general -- /* But Officer, I stopped for the last one, and it was green! */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] I'm really getting annoyed with PHP
Yes, I'm still screwing around with this stupid redirection thing, and either I'm just a total idiot or there are some serious problems with PHP. I have now tried to do it another way and - yes - you guessed it. It does not work. I mean really, it can not be this hard to redirect a user to another page. If it is, then I must look into using something else as I just can't be wasting days and days on one minor detail that should take 30 seconds to complete. If anyone has some concrete suggestion on how to get this to work It would be greatly appreciated. In the mean time I have given up on it as I am just totally pissed off at it. TIA -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] I'm really getting annoyed with PHP
FYI. I did this login page for another website last month and I used the code from it to do this one. The other one works perfectly. I checked that code again today and there is ABSOLUTELY no differnce. I even used the same variables and session names. The only difference between the two sites is that the one that works is running IIS on Windows 2000 Server. The broken one is on a Linux box running Apache. Both PHP and MySQL are the same versions. Remember also that the Header redirect is working in the redirect.inc page, which is even more confusing. I have really given up on it. It just ain't gonna work - no matter what I do. I thought I finally had it working again, but of course - another f*** up. Can you explain this? Along with my other code I used a little piece of javascript to do the redirect, and lo and behold it worked. But now my paths are all screwed up. I just don't get it. In the example I tried, the page I am redirected to has a form on it. When I click submit it should go to the page specified in the action, which is season_write.php. But for some reason it tries to go to /setup/season_write.php. This is not specified anywhere in any of my code. So where the hell it getting this from. The more I use PHP the more I am becoming convinced I should be using something else. This is just ridiculous. <!-- Begin window.location="<? echo $_SESSION['goto']; ?>"; // End --> -Original Message- From: Ray Hunter [mailto:[EMAIL PROTECTED] Sent: July 23, 2003 5:44 PM To: Beauford.2005 Subject: Re: [PHP] I'm really getting annoyed with PHP Questions: 1. What verion of php are you running? 2. What version of apache are you running? Or other web server? 3. What is your configuration for php? check phpinfo() 4. Is php built from source or a binary (rpm, exe)? 5. What OS are you running on and what version? -- BigDog On Thu, 2003-07-24 at 13:41, Beauford.2005 wrote: > Yes, I'm still screwing around with this stupid redirection thing, and > either I'm just a total idiot or there are some serious problems with > PHP. I have now tried to do it another way and - yes - you guessed it. > It does not work. > > I mean really, it can not be this hard to redirect a user to another > page. If it is, then I must look into using something else as I just > can't be wasting days and days on one minor detail that should take 30 > seconds to complete. > > If anyone has some concrete suggestion on how to get this to work It > would be greatly appreciated. In the mean time I have given up on it > as I am just totally pissed off at it. > > TIA > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Re: Redirection Question (I spoke to soon)
Finally, Thanks to all that tried to help, but I found part of the problem - sort of. In the file that I am trying to redirect to I have a form with the line: It appears this line was corrupt somehow. After I rewrote the line from scratch it solved the problem of my paths being screwed up - why - I have no idea. Maybe it had some weird control characters or something that was screwing things up. However, there is still a problem with the header function - it still will not redirect. I got around this by using a small javascript I found which seems to do the trick. I'd still be curious as to why the header will not work, but at this point I'm ecstatic that it works at all. if(isset($_SESSION['goto'])) { ?> http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] I'm really getting annoyed with PHP
It's obvious though that PHP can not handle it. This is why I am forced to use javascript. I have already spent a week on this and am not going to waste any further time. I have posted all my code and if someone can see a problem I'll look at it, but it just ain't worth the effort at this point. -Original Message- From: Justin French [mailto:[EMAIL PROTECTED] Sent: July 23, 2003 10:52 PM To: Curt Zirzow Cc: PHP Subject: Re: [PHP] I'm really getting annoyed with PHP On Thursday, July 24, 2003, at 12:18 PM, Curt Zirzow wrote: > And in my case I would never see the next page. I have javascript > turned > off. > > Never rely on javascript to do the work, excpecially in small cases > like > this when php can handle it without any issues, such as javascript > being > turned off. To follow on from this, the W3 accessibility guidelines (http://www.w3.org/TR/WCAG10/checkpoint-list.html) state: --- 6.3 Ensure that pages are usable when scripts, applets, or other programmatic objects are turned off or not supported. If this is not possible, provide equivalent information on an alternative accessible page. [Priority 1] For example, ensure that links that trigger scripts work when scripts are turned off or not supported (e.g., do not use "javascript:" as the link target). If it is not possible to make the page usable without scripts, provide a text equivalent with the NOSCRIPT element, or use a server-side script instead of a client-side script, or provide an alternative accessible page as per checkpoint 11.4. Refer also to guideline 1. --- In short, do as much as you can server side (PHP), and ensure the page doesn't break without JS. Then use JS on the client side IF YOU MUST to enhance the experience for those with it switched on. Yes, it's more work, and yes this is optional (but be aware that SOCOG (Sydney Olympics) were sued for having an inaccessible site, so it's only a matter of time before we have huge class action everywhere :)), and yes you'll reach a greater market share with an accessible page. Sorry for getting OT Justin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Values from forms
Small brain cramp here. I have the following form and having problems retrieving the values from it. // $number gets inputted from another form (this works) input type=text name="team" SIZE="10"> This is teams-write.php: The problem I am having is getting the values inputted in the above form in the for loop below. If I just echo $team1, $team2, etc. they are there, I just can't figure out how to get the values inputted into my database. In the loop below, what would I put in the second values section to get the values of $team1, $team2, etc. for($i=1; $i < $count + 1; $i++) { mysql_query("insert into manager (idn, name) values ('$i','???')"); } TIA -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Values from forms
David, Thanks for the info. The first suggestion doesn't work, and the second may work - but the problem is I need the array to start at '1' - and arrays in general start at 0. Any ideas? TIA -Original Message- From: David Nicholson [mailto:[EMAIL PROTECTED] Sent: August 4, 2003 7:11 PM To: Beauford.2005 Cc: [EMAIL PROTECTED] Subject: Re: [PHP] Values from forms Hello, This is a reply to an e-mail that you wrote on Tue, 5 Aug 2003 at 00:05, lines prefixed by '>' were originally written by you. > $team2, etc. they are there, I just can't figure out how to get the > values inputted into my database. In the loop below, what would I put > the second values section to get the values of $team1, $team2, etc. > for($i=1; $i < $count + 1; $i++) { > mysql_query("insert into manager (idn, name) values > ('$i','???')"); TIA ${'team'.$i} will work but it would lead to tider code if you got your data into the script using an array... http://www.phpmachine.com/ Free PHP error handling script: www.phpmachine.com/error-handler Professional Web Development by David Nicholson http://www.djnicholson.com/ QuizSender.com - How well do your friends actually know you? http://www.quizsender.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Here we go with PATHS - again!!
I hope someone can put this to rest for good, cause this is just bullshit. Every time I try to do something using any thing other than the root directory of my website - I get these stupid path problems. Here is the problem this time. First off I am not using frames (if it matters) and this particular site is on Windows 2000. The website resides in d:\Apache\htdocs\supreme and in this directory I have a .js file for my drop-down menu - there is also another file which I am including using the php include directive called menu.inc. The graphics for the menu are in a directory called images. When I go to the main page of the site everything is great, but as soon as I try to get the menu to work from another directory it can't find the graphics. I have tried d:\Apache\htdocs\supreme\image.gif. I have tried http://www.mysite.com/images/image.gif. I have tried ../file.js (this is to load the menu) I have even tried putting menu.inc in my php include directory. You get the picture - but no matter what I try it just doesn't work. I mean really - is this that hard to figure out. Like this is every time I work on a site I get these path problems. Am I just not getting something here. Other than putting everything in the root directory (which I don't want to do) I have no idea how to solve this. It just gives me a headache. TIA -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Ob_start question
I am getting this error: Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /usr/local/apache/php/includes/2004server.inc:24) in /usr/local/apache/php/includes/restricted.inc on line 5 I have ob_start(); and ob_end_flush(); at the beginning and end of restricted.inc. Like the following. Could someone explain why I am still getting the above error. 2004server.inc is just the mysql server info TIA http://www.mysite.net/login/login.php";; header("Location: $url"); } ob_end_flush(); ?> -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Ob_start question
This is line 5.. $email_error = "If the problem persists email mailto:[EMAIL PROTECTED]>Webmaster"; but I believe the error message refers to line 5 of restricted.in, not 2004server.inc. This is line 5 of restricted.inc session_start(); -Original Message- From: Ford, Mike [LSS] [mailto:[EMAIL PROTECTED] Sent: September 3, 2003 5:20 AM To: 'Beauford.2005'; PHP Subject: RE: [PHP] Ob_start question On 03 September 2003 03:11, Beauford.2005 contributed these pearls of wisdom: > I am getting this error: > > Warning: session_start() [function.session-start]: Cannot send session > cache limiter - headers already sent (output started at > /usr/local/apache/php/includes/2004server.inc:24) in > /usr/local/apache/php/includes/restricted.inc on line 5 > > I have ob_start(); and ob_end_flush(); at the beginning and end of > restricted.inc. Like the following. Could someone explain why > I am still > getting the above error. 2004server.inc is just the mysql > server info ... but, according to the error message, output is started in 2004server.inc, nonetheless -- on line 5, to be precise. What is on line 5 of 2004server.inc? Cheers! Mike - Mike Ford, Electronic Information Services Adviser, Learning Support Services, Learning & Information Services, JG125, James Graham Building, Leeds Metropolitan University, Beckett Park, LEEDS, LS6 3QS, United Kingdom Email: [EMAIL PROTECTED] Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Ob_start question
Yep, that's it. I thought I had this as it was working at one time, but obviously some spaces got added. Thanks. -Original Message- From: Curt Zirzow [mailto:[EMAIL PROTECTED] Sent: September 3, 2003 11:13 AM To: PHP Subject: Re: [PHP] Ob_start question * Thus wrote Beauford.2005 ([EMAIL PROTECTED]): > I am getting this error: > > Warning: session_start() [function.session-start]: Cannot send session > cache limiter - headers already sent (output started at > /usr/local/apache/php/includes/2004server.inc:24) in > /usr/local/apache/php/includes/restricted.inc on line 5 As the error says it has to do with line 24 of 2004server.inc. and most likely looks like this: ?> EOF or ?> EOF Curt -- "I used to think I was indecisive, but now I'm not so sure." -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php