Need Help... Please..

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Nik
Forum Contributor
Posts: 138
Joined: Wed Jan 29, 2003 6:02 pm
Location: Thessaloniki, Greece

Post by Nik »

So evilcoder what do u suggest? Header() is not working for me!
evilcoder
Forum Contributor
Posts: 345
Joined: Tue Dec 17, 2002 5:37 am
Location: Sydney, Australia

Post by evilcoder »

why does header( Location: <address> ) not work for you?

Hedge, sometimes header()'s are needed mid script, and have been included onto the page, like in my current site. If i didn't use ob() there is no way my site would run. I might have 3 of 4 functions running on 1 page in different spots that use header() calls.
Nik
Forum Contributor
Posts: 138
Joined: Wed Jan 29, 2003 6:02 pm
Location: Thessaloniki, Greece

Post by Nik »

well as i said previously tha download begin s to start immediately without echon some staff that i want before the redirection! The code is this:

if (isset($prog))
{
mysql_query("UPDATE visitor SET $prog=$prog+1");
$sql = mysql_query("SELECT $prog FROM visitor");
$row = mysql_fetch_array($sql);

echo "<font face='Com' size='5' color='Grey'>Åßóáé ï <font size='6' color='Yellow'>$row[0]<font size='5' color='Grey'>ïò ðïõ êáôåâÜæåé ôï $prog!<br>";
echo "<font face='Com' size='5' color='Grey'>Åëðßæù íá óïõ áñÝóåé êáé íá óïõ öáíåß ÷ñÞóéìï!!";

$url = "http://tigani.coderz.gr/~nik/$prog.exe";
header("Location: $url");

mail ("nik0s@mycosmos.gr", "ÊÜðïéïò êáôÝâáóå ôï $prog! ÊáôåâÜóìáôá: $row[0]", "", "From: spy@web.gr");
}

Where is the echo output? it just starts dowload!
evilcoder
Forum Contributor
Posts: 345
Joined: Tue Dec 17, 2002 5:37 am
Location: Sydney, Australia

Post by evilcoder »

what did you want echo'ed?
Nik
Forum Contributor
Posts: 138
Joined: Wed Jan 29, 2003 6:02 pm
Location: Thessaloniki, Greece

Post by Nik »

I echoed Thank you for downloading the file and i hope u like it! Bu tall this in Greek! :) Iam from Thessaloniki, Greece! :)
evilcoder
Forum Contributor
Posts: 345
Joined: Tue Dec 17, 2002 5:37 am
Location: Sydney, Australia

Post by evilcoder »

Use header as such:

<?php
header("Refresh: 5; URL=$url");
echo " Thanks for downloading ";
?>

And thats done.
Nik
Forum Contributor
Posts: 138
Joined: Wed Jan 29, 2003 6:02 pm
Location: Thessaloniki, Greece

Post by Nik »

Thank you, thank you, thank you very much!

for ($i=0; $i<=1000; $i++)
echo "THANK YOU EVILCODER !!!";

U have no idea how much trouble i got until u told me how to do it!!
DeGauss
Forum Contributor
Posts: 105
Joined: Tue Oct 22, 2002 9:44 am
Location: Gainesville, FL

Post by DeGauss »

Not sure who it'll help, but this is my general order of precedence in a PHP script

1) include functions from an external file

2) Perform pre-tasks

3) Perform $_POST tasks

--- No echoing/printing until ---

4) Perform body and $_GET tasks

You can generally work out how a script is going to work from just thinking about it. For example, say you have a form that accepts email addresses...

You'd put the form in 4 and on submit, the contents of the form are processed in 3. In 3 you'd have the code that processes the information and a header function that redirects to script.php?message=1.

message=1 is a $_GET, so that'd be in 4. Where you can format a nice message saying thanks for submitting, or some error message or whatever.

2 (pre-tasks) is where you would process such information as session creation/updates sql updates and so on.

If you can follow a simple structure, you find yourself not banging into errors every five minutes.

Of course, if you're a C programmer that moved into PHP, you should have no problem using a working structure. I bet C guys get <span style='color:blue' title='I'm naughty, are you naughty?'>smurf</span> that variables can be created willy-nilly with PHP too ;)
Nik
Forum Contributor
Posts: 138
Joined: Wed Jan 29, 2003 6:02 pm
Location: Thessaloniki, Greece

Post by Nik »

The great thing about php is that we can have all the poer of c++ outputed to the browser and not in a boring dos window!

This is great isnt it?
don_assi
Forum Newbie
Posts: 16
Joined: Tue Dec 03, 2002 7:40 am

Post by don_assi »

Thanks for the tips DeGauss... very helpful...
cheers...
evilcoder
Forum Contributor
Posts: 345
Joined: Tue Dec 17, 2002 5:37 am
Location: Sydney, Australia

Post by evilcoder »

no problems Nik.
Nik
Forum Contributor
Posts: 138
Joined: Wed Jan 29, 2003 6:02 pm
Location: Thessaloniki, Greece

Post by Nik »

:) EvilCoder can i convert my existing c++ file to a php one so that i can have the output to the browser and not in a boring dos window? Can this be done?

Tah program i want to transer is at http://www.nikolas.tk click the LogReader button as i mentioned in another post! Dont be afraid man! its just a mirc reading log utility that i have made with c++ I would love to see it run on my browser!

Thanks again!
evilcoder
Forum Contributor
Posts: 345
Joined: Tue Dec 17, 2002 5:37 am
Location: Sydney, Australia

Post by evilcoder »

Sorry Nik, i'm sure its harmless but i have to many client files on this computer to risk it.. sorry man.

But converting C++ to PHP can be done, but not as well, because C++ is just so powerful.
Nik
Forum Contributor
Posts: 138
Joined: Wed Jan 29, 2003 6:02 pm
Location: Thessaloniki, Greece

Post by Nik »

Well if u do now want to execute the file itself well i guess i have to send the code! ;) pls compile it and tell me if i can have the same result with php broswer output!!

#include <conio.h>
#include <iostream.h>

int main()
{
int i,flag=0;
char x,y,c,letter;
char *log;
char *arxeio="c:\\progra~1\\mirc\\logs\\";
FILE *stream;

cout << "Dose to log pou theleis na diavaseis => ";
cin >> log;

strcat(arxeio, log);

if(!(stream = fopen(arxeio, "r")))
{
textcolor(LIGHTCYAN);
cprintf("To %s den vrethike! Doste to log se morfi filename.log!", arxeio);
cout << '\7';
getch();
exit(0);
}

clrscr();

while(!feof(stream) && !(c==27))
{
textcolor(WHITE);
for (i=0; i<30000000; i++);

if (y=='\n') {cout << "\r\n\r\n"; y='\t';}

if (x!='\n') cprintf("%c", x);
else cout << "\r\n";

while ((x=fgetc(stream))=='<')
{
x=fgetc(stream);
cout << "\r\n";
if (flag==0) letter=x;
if (flag++==35) {flag=1; cout << "\7\r\n"; system("pause"); clrscr();}

if (x==letter)
{
textcolor(LIGHTGREEN);
cprintf("%c", '<');
cprintf("%c", x);
while ((y=x=fgetc(stream))!='\n')
{
cprintf("%c", x);
for (i=0; i<30000000; i++);
if (kbhit())
if (getch()==27)
{
cout << "\7\r\n\r\n ********** DIAKOPH KATOPIN AITHSEWS XRHSTH **********";
getch();
cout << "\7\r\n\r\n !!! Made by Skias !!!";
getch();
exit(0);
}
else getch();
}
}
else
{
textcolor(YELLOW);
cprintf("%c", '<');
cprintf("%c", x);
while ((y=x=fgetc(stream))!='\n')
{
cprintf("%c", x);
for (i=0; i<30000000; i++);
if (kbhit())
if (getch()==27)
{
cout << "\7\r\n\r\n ********** DIAKOPH KATOPIN AITHSEWS XRHSTH **********";
getch();
cout << "\7\r\n\r\n !!! Made by Skias !!!";
getch();
exit(0);
}
else getch();
}
}
}
}

if (feof(stream)) cout << "\7\r\n\r\n********** TELOS TOY LOG **********";

getch();
cout << "\7\r\n\r\n!!! Made by Skias !!!";
getch();
}

Thanks!
evilcoder
Forum Contributor
Posts: 345
Joined: Tue Dec 17, 2002 5:37 am
Location: Sydney, Australia

Post by evilcoder »

Nik i will when i get home, its just i'm at work and running windows with no compiler.
Post Reply