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!
I wrote some php code (I am a beginner at this) and part of it won't work. Access to DB works well, create, update, view of records works but what doesn't work is when I cklick the link where it should pass a variable to itself...and reload itself and to the other thing with the var set. It won't work....do I have to set something on my web server (apache) so it works?
echo("<p><a href='$PHP_SELF?addjoke=1'>Add joke</a></p>");
that is the code that acctually won't work but I send the complete code, maybe the error is somewhere else..
I did read it but I am still puzzled because I don't know where is my error? Because the METHOD=POST never gets called since the
?addjoke=1 doesn't set the var.
if viewtopic.php?t=511 applies to your version of php (<?php phpinfo(); ?> will tell you) $PHP_SELF does not exist anymore. You have to use $_SERVER['PHP_SELF']
anything you pass via GET (like <a href='blablabl.php?addjoke=1'>) you have to fetch via the superglobal array $_GET (e.g. $_GET['addjoke'] )
Anything you POST (like <form action="blablabl.php" METHOD="POST"> ) you have to fetch via the superglobal $_POST (e.g. $_POST['joketext'])
Somewhere between $joketext and $_POST['joketext'] is the superglobal $_REQUEST, it contains (among other things) the elements of $_GET and $_POST. You can access the parameters regardless of wether they have been passed via GET or POST but you cannot tell the methods apart from each other (just like the old $joketext).
you also might want to look into heredocs, and if you're going to make many pages, look into modularity and using includes.
we can give you pointers if you need it, but search php.net for echo and read about the heredocs, and if you're unsure of what modularity is, just ask (or search google)