This is a discussion on "register_globals" within the PHP Forum section. This forum, and the thread "register_globals are both part of the Program Your Website category.
|
|
|
|
|
![]() |
||
register_globals
|
||
| Notices |
![]() |
|
|
LinkBack | Thread Tools |
|
#1
|
|||
|
|||
|
register_globals
First off: I'm a designer, not much of a coder, so please, explain to me if you'd explain it to kids watching sesame street..
I'm creating a website for a client using an old CMS because all the CMS' built today are waaay to bulky. My client just needs his content to be editable. Like I said, I'm not a coder, so I can't create a CMS myself yet.. Here's the deal: I'm using a login-screen for the admin-section, which worked fine on my server, but doesn't on my clients. Now I found out that my test server has the register_globals set "on". The live server has it set to off.. Now, how do I get the following piece of code to work with the globals off?
|
|
|
|
#2
|
|||
|
|||
|
Re: register_globals
you need to convert all of your variables using the POST method.
eg if ($_POST['formpass'] == $pass && $_POST['formlogin'] == $login) { Have a look on using POST vaiables on php.net |
|
#3
|
|||
|
|||
|
Re: register_globals
Also....
I wouldnt use a javascript redirect, instead use a php header at the top of the page (before the html) if ($_POST['formpass'] == $pass && $_POST['formlogin'] == $login) { header("Location: http://www.yourwebsite"); } |
|
#4
|
|||
|
|||
|
Re: register_globals
Maybe I should make it more clear, this is what I would do:
|
|
#5
|
|||
|
|||
|
Re: register_globals
all, as in everywhere, or just in the login.php?
|
|
#6
|
|||
|
|||
|
Re: register_globals
Also you need a way of securing your admin folder. Ideally you want to work with Sessions and header redirects. Javascript is easy to get around security wise
|
|
#7
|
|||
|
|||
|
Re: register_globals
Whenever a variable is meant to be sent from a form (posted), you make it use the POST method. There are other types too like $_REQUEST and $_GET
|
|
#8
|
|||
|
|||
|
Re: register_globals
I get this:
Warning: Cannot modify header information - headers already sent by (output started at /home/delusion/bs4y.allura.nl/login.php:13) in /home/delusion/bs4y.allura.nl/login.php on line 18 When I use your code.. ? |
|
#9
|
|||
|
|||
|
Re: register_globals
This is all the code I have:
|
|
#10
|
|||
|
|||
|
Re: register_globals
ok, thats becuase that code needs to be before any html at all for example
<?php require ("config.php"); if ($_POST['formpass'] == $pass && $_POST['formlogin'] == $login) { header("Location: admin/"); }//end if ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <title>Untitled Document</title> </head> <body> <? if ($e == "1") { echo "<p>Please Login</p>"; } ?> </body> </html> *Also the page will load better this way as the php is worked out before the browser trys to load the page |
|
#11
|
|||
|
|||
|
Re: register_globals
replace my html with all your html
|
|
#12
|
|||
|
|||
|
Re: register_globals
I did.. now this:
Warning: Cannot modify header information - headers already sent by (output started at /home/delusion/bs4y.allura.nl/login.php:2) in /home/delusion/bs4y.allura.nl/login.php on line 5
|
|
#13
|
|||
|
|||
|
Re: register_globals
ok, give me a sec, I will format you code for you
|
|
#14
|
|||
|
|||
|
Re: register_globals
I'll go have some lunch.. brb
|
|
#15
|
|||
|
|||
|
Re: register_globals
<?
session_start(); require ("config.php"); if ($_POST['formpass'] == $pass && $_POST['formlogin'] == $login) { header("Location: admin/"); }//end if ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>Login</title> <link href="/style.css" rel="stylesheet" type="text/css"> </head> <body style="font-family: tahoma;"> <h3>Simple CMS Login</h3> <p><img src='img/security.gif' title='please login'></p> <form action="login.php" method="post" name="frm"> <table cellspacing="4" cellpadding="4" style="border-bottom-width: thin; border-left-width: thin; border-right-width: thin; border-top-width: thin; border-style: dotted; border-color: red;"> <tr> <td colspan="2">Please Login </td> </tr> <tr> <td>username</td> <td><input type="text" name="formlogin" class="cssborder"></td> </tr> <tr> <td>password</td> <td><input type="password" name="formpass" class="cssborder"></td> </tr> </table> <br> <input type="submit" value="login" class="cssborder"> </form> <p><a href="login.php"><small>reload</small></a></p> </body> </html> |
|
#16
|
|||
|
|||
|
Re: register_globals
Also something else you should look into is using external style sheets, it would make projects like this a lot easier to update visually.
|
|
#17
|
|||
|
|||
|
Re: register_globals
Just thought, it should be ok, but only if config.php doesnt echo anything
|
|
#18
|
|||
|
|||
|
Re: register_globals
Quote:
Now. I tried your code, but it doesn't do anything. It takes me back to the login-screen.. |
|
#19
|
|
|