We hope you enjoy your visit.

You're currently viewing our forum as a guest. This means you are limited to certain areas of the board and there are some features you can't use. If you join our community, you'll be able to access member-only sections, and use many member-only features such as customizing your profile, sending personal messages, and voting in polls. Registration is simple, fast, and completely free.


Join our community!


If you're already a member please log in to your account to access all of our features:

Username:   Password:
Add Reply
  • Pages:
  • 1
  • 2
Php site.com?site
Topic Started: May 5 2005, 10:24 PM (1,085 Views)
Das
Member Avatar
Smells of rich mahogany
[ *  *  *  *  *  *  * ]
Seth
May 5, 2005 10:15 PM
That creates the variable $_GET['showtopic'] == 137803.

IPB then says, get the topic with ID 137803 from the database. Plug it into the templates.

I think I understand teh smart Sethy. All these posts exsist on the database, and $_Get[] retrevies the infromation from the database and displays it on this page in the form of posts? *Das hopes he is right for once.
Offline Profile Quote Post Goto Top
 
Rory
i;m a mess
[ *  *  *  *  *  *  * ]
not quite. Let me break it down for you.

When you have a url like so:

http://examplesite.com/index.php?page=rawr&id=5

you are actually creating two variables.

however, to access these variables, you have to use the Super Variable $_GET[].

$page = $_GET['page'];

This would assign 'rawr' to the variable $page.

Then, somewhere else in your php code, you could use that variable to do something.

There are other super variables, like $_POST[] and $_COOKIE[]. $_POST[] is used when sending data from forms, but not shown in the url (if you were submitting a password you would use the form method Post not Get, so people can't see your password).

I hope that kind of makes sense.

$_GET[] is a way of accessing the variable sent in the url as index.php?page=rawr

It is not used to actually retrieve the data from anywhere else. you would have to then do something using that variable.
Offline Profile Quote Post Goto Top
 
Das
Member Avatar
Smells of rich mahogany
[ *  *  *  *  *  *  * ]
O I think I get it now. Thank you muchly. You talk in nice small words that are easy to understand.
Offline Profile Quote Post Goto Top
 
kingy
1 in 10 people understands binary, the other 1 doesn't
[ *  *  *  *  *  * ]
just while we are on this subject...is $_Get necessery all of the time? i have used ?page=1 format things and just used

if ($page==1)

for ages, and it hasn't caused problems, so is the global neccessery or should i use it?
Offline Profile Quote Post Goto Top
 
Rory
i;m a mess
[ *  *  *  *  *  *  * ]
You should most definitly get into the practice of using the super variables.

Using just $page means that register_globals is turned on, and this could lead to security problems.

You should put all values from query strings into variables from the superglobal variables.
Offline Profile Quote Post Goto Top
 
Seth
Member Avatar
I has a pony
[ *  *  *  *  *  *  *  *  * ]
Yep. What if I knew your admin passwordcheck variable name? So you check if ($login == TRUE) { show_admin_tools(); } and I call http://youradmin.com/?login=TRUE

:ph34r:
Offline Profile Quote Post Goto Top
 
Das
Member Avatar
Smells of rich mahogany
[ *  *  *  *  *  *  * ]
Would it be a bad thing to have all the login done through individial files? Like:
http://www.yourname.com/login.php //Form where name and password are entered
http://www.yourname.com/loginincheck.php // Check the password and username vars
http://www.yourmane.com/setcookie.php //Set appropritate cookie for user

It looks a little tacky, but is that suseptable to attacks? Can you creat a cookie for another site, and fool thoose types of things.
Offline Profile Quote Post Goto Top
 
Rory
i;m a mess
[ *  *  *  *  *  *  * ]
It is best to do it all in one.

Just have a form on a page, and have:

if ($_POST['submit']) {
// do verification
// if verify's do cookie setting
} else {
// display the form for filling out
}

if that makes sense?
Offline Profile Quote Post Goto Top
 
Das
Member Avatar
Smells of rich mahogany
[ *  *  *  *  *  *  * ]
Rory
May 6, 2005 02:21 PM
It is best to do it all in one.

Just have a form on a page, and have:

if ($_POST['submit']) {
// do verification
// if verify's do cookie setting
} else {
// display the form for filling out
}

if that makes sense?

Err you mean something like...

if ($_POST['username'] == $username && $_POST['password'] == $password ) {
// Put cookie
} else {
echo "You are very forgetful or trying to hack"
}

Can you have the form and "$_POST['username']" on the same page?
Offline Profile Quote Post Goto Top
 
Seth
Member Avatar
I has a pony
[ *  *  *  *  *  *  *  *  * ]
Yes, if you make the form submit to itself.
Offline Profile Quote Post Goto Top
 
Das
Member Avatar
Smells of rich mahogany
[ *  *  *  *  *  *  * ]
Would it still be able to process the info on the same page?

EX:
Quote:
 

<html>
<body>
<form action="login.php" method="post"> //login.php would be this page
Username: <input type="text" name="username" size="15">
Pass: <input type="password" name="password" size="15">
<input type="submit" value="Log In">
</form>

<?
$name=Bob
$pass=Bob
if ($_POST['username'] == $username && $_POST['password'] == $password ) {
// Put cookie
} else {
echo "You are very forgetful or trying to hack"
}
?>
</body>
</html>


Would that actually work and set the cookie if things were right?

[ot]Can you make the password for replace the password text with ****?
Offline Profile Quote Post Goto Top
 
JoeC
Euch! IE tastes horrible!
[ *  *  *  *  * ]
Would that not break / let them in if you entered:

Code:
 
' or 1 == 1 '


in the password box? Just a little injection.
Offline Profile Quote Post Goto Top
 
Das
Member Avatar
Smells of rich mahogany
[ *  *  *  *  *  *  * ]
Joezif
May 6, 2005 02:56 PM
Would that not break / let them in if you entered:

Code:
 
' or 1 == 1 '


in the password box? Just a little injection.

What? Try again.
Offline Profile Quote Post Goto Top
 
Rory
i;m a mess
[ *  *  *  *  *  *  * ]
Das Ein. To have the form and processing on one page, you have to do it how i said.

You make the form submit to the same page, and have the submit button called 'submit'. (Make sure the form's method is 'post' if you are submitting passwords)

Then you check whether $_POST['submit'] has been set. If not, you display the html for the form, otherwise you process the information sent.

so you would have this:
Code:
 

if ($_POST['submit']) {
    $name= "Bob";
    $pass= "Bob";
    if (($_POST['username'] == $username) && ($_POST['password'] == $password) ) {
           // Put cookie
    } else {
           echo "You are very forgetful or trying to hack";
    }
} else {
     echo "<form action='login.php' method='post'>\nUsername: <input type='text' name='username' size='15'>\n Pass: <input type='password' name='password' size='15'>\n<input type='submit' name='submit' value='Log In'>\n</form>";
}


That should be what you want...

Also, that should replace any text written in the password field with ****'s so you can't see it. (but the text is actually the same)
Offline Profile Quote Post Goto Top
 
Das
Member Avatar
Smells of rich mahogany
[ *  *  *  *  *  *  * ]
Rory you must have forgot to close a tag in your example because it displays
Quote:
 
if ($_POST['submit']) { $name=Bob $pass=Bob if ($_POST['username'] == $username && $_POST['password'] == $password ) { // Put cookie } else { echo "You are very forgetful or trying to hack" } } else { echo "
//login.php would be this page Username: Pass:
"; }
Offline Profile Quote Post Goto Top
 
1 user reading this topic (1 Guest and 0 Anonymous)
Go to Next Page
« Previous Topic · Technology Chat · Next Topic »
Add Reply
  • Pages:
  • 1
  • 2