Page 1 of 3
Can I see an example of something..
Posted: Fri Feb 13, 2004 1:59 am
by seeker2921
I've seen alot of sites that use a qurey string like this:
index.php?user=username&pass=password&page=edit.php
I would like to see a simple example of how to do this?
Posted: Fri Feb 13, 2004 2:14 am
by dethron
What is your point? What do you want to see?
index.php?user=$user&pass=$pass&page=$page
$user, $pass, $page are all values posted using a form.
Sorry, I can't understand what example that you want to see.
Posted: Fri Feb 13, 2004 2:17 am
by seeker2921
I just don't understand how to do that.. Everytime I have tried in the past it doesn't work..
Posted: Fri Feb 13, 2004 2:24 am
by dethron
Following will be automatically send the variables to the file itself...
Code: Select all
<form action="<?=$PHP_SELF;?>" method="post">
<input type="text" name="pass" size="10">
<input type="text" name="name" size="10">
<input type="hidden" name="file" size="10" value="edit.php">
<input type="submit" value="SEND">
</form>
And end of file, you have a link, like that
Code: Select all
<a href="<?=$PHP_SELF;?>?name<?=$name;?>&pass<?=$pass;?>&file<?=$file;?>">proceed</a>
And this link leads you a page like you want to see

Hope, this will help.
Posted: Fri Feb 13, 2004 2:28 am
by seeker2921
Can it be used with functions?
Posted: Fri Feb 13, 2004 2:29 am
by dethron
Yes of course, what do you want to do?
If you specify what you are trying to accomplish, may be i can help better.
Posted: Fri Feb 13, 2004 2:41 am
by seeker2921
Well, I have a simple blog I'm trying to write.. and I'm making the admin section for it and I want it all to be in one page (admin.php) and have one config file but It isn't working well.. so I'm trying to figuare out what I can do to make it work.. I thought if I knew how to do the whole index.php?user=user&pass=pass ect.. It would help me..
Posted: Fri Feb 13, 2004 3:04 am
by dethron
Code: Select all
<?php
//If I understand right, this will help you.
//We have page named admin.php as follows ;
//==========admin.php===============
echo "<html>";
echo "<body>";
$cm = str_replace("''", "''", $cm);
switch($cm){
case 11:
include('admin1.php');
break;
case 12:
include('admin2.php');
break;
default :
include('adminD.php');
echo "</body>";
echo "</html>";
//And the other filesss
//=========admin1.php=========
echo "<html>";
echo "<body>";
echo "admin properties 1";
echo "</body>";
echo "</html>";
//=========admin2.php=========
echo "<html>";
echo "<body>";
echo "admin properties 2";
echo "</body>";
echo "</html>";
//=========adminD.php=========
echo "<html>";
echo "<body>";
echo "<form action="admin.php" method="post">";
echo "<input type="text" name="cm" size="4">";
echo "<input type="submi\t" value="SEND">";
echo "</form>";
echo "</body>";
echo "</html>";
//-----------------------------------------
//If this will not help, let me know.
//Kind Regards.
?>
Posted: Fri Feb 13, 2004 3:10 am
by seeker2921
Well, Heres what I have so far..
Code: Select all
admin.php
<?
include('/home/oblivion/public_html/admin/inc/config.php');
$strPAGE=$_SERVER['PHP_SELF'];
if(!isset($id)){
echo('<a href=admin.php?id=showadd>Add Entry</a>');
}
elseif($id==showadd){
$date = date ("Y-m-d H:i:s");
echo"<html><body>
<form name='form1' method='post' action='$strPAGE'>
<p class='date'>Date:
<input name='date' type='text' value='$date' maxlength='20'>
</p>
<p class='topic'>Topic :
<input name='topic' type='text' size='90' maxlength='180'>
</p>
<p class='entry'>Entry:</p>
<p>
<textarea name='entry' cols='90' rows='20'></textarea>
</p>
<p>
<input type='submit' name='addentry' value='Submit'>
</p>
</form>
<p> </p></body>
</html>";
}
if(submit=="addentry"){
addentry();
}
function addentry(){
$query = "INSERT INTO $table VALUES ('NULL','$date','$topic','$entry')";
$result = mysql_query($query);
if ($result) {
echo("done");
} else {
echo ("Entry not added. There was a problem somewhere, fix it.");
}
}
?>
config.php
<?
//Include strings
include('/home/oblivion/public_html/admin/inc/strings.php');
//MySQL Connection Var's
define('DB_NAME', 'oblivion_main');
define('DB_HOST', 'localhost');
define('DB_USER', 'oblivion_oblivio');
define('DB_PASS', 'digital1');
$table=("journal");
$url=('http://www.o-blivion.com/site/blog');
?>
Perhaps this will help for what I am looking for
Posted: Fri Feb 13, 2004 4:18 am
by dethron
For debugging purposes, use the following line :
echo $id;
And always remember that
elseif($id=="showadd"){
is better than
elseif($id==showadd){
Until know i can't see any problem.
Use echo $id at the top of the page, and then observe what you posted?
I see right values, and it is working. There shouldn't be any problem.
But let me check again.
Posted: Fri Feb 13, 2004 6:45 am
by twigletmac
dethron wrote:I see right values, and it is working. There shouldn't be any problem.
There will be a problem if
register_globals is OFF.
Please read:
Concerning Passing Variables in PHP 4.2+
Mac
[Edit: had to make a change because another poster changed their name]
Posted: Fri Feb 13, 2004 8:21 am
by jason
Ahh, an oldie, but goodie. =)
Posted: Fri Feb 13, 2004 12:59 pm
by dethron

srry
thnx jason

.... dethron
================================
Like A Ghost In Daylight
On An Overcrowded Street
He Wishes
To Be Something He Is Not.
Lie A Shadow At Midnight
That Originate In Air
He Wishes To Release...
================================
Posted: Fri Feb 13, 2004 1:23 pm
by voodoo9055
Code: Select all
<form method="post" action="index.php?user=<?php echo $user;?>&pass=<?php echo $pass;?>">
Posted: Fri Feb 13, 2004 4:39 pm
by dethron
So what is your point?