Can I see an example of something..
Moderator: General Moderators
-
seeker2921
- Forum Contributor
- Posts: 120
- Joined: Sat Mar 22, 2003 7:10 pm
- Location: Wiesbaden Germany
- Contact:
Can I see an example of something..
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?
index.php?user=username&pass=password&page=edit.php
I would like to see a simple example of how to do this?
-
seeker2921
- Forum Contributor
- Posts: 120
- Joined: Sat Mar 22, 2003 7:10 pm
- Location: Wiesbaden Germany
- Contact:
Following will be automatically send the variables to the file itself...
And end of file, you have a link, like that
And this link leads you a page like you want to see
Hope, this will help.
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>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.
-
seeker2921
- Forum Contributor
- Posts: 120
- Joined: Sat Mar 22, 2003 7:10 pm
- Location: Wiesbaden Germany
- Contact:
-
seeker2921
- Forum Contributor
- Posts: 120
- Joined: Sat Mar 22, 2003 7:10 pm
- Location: Wiesbaden Germany
- Contact:
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..
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.
?>
Last edited by dethron on Fri Feb 13, 2004 3:23 am, edited 1 time in total.
-
seeker2921
- Forum Contributor
- Posts: 120
- Joined: Sat Mar 22, 2003 7:10 pm
- Location: Wiesbaden Germany
- Contact:
Well, Heres what I have so far..
Perhaps this will help for what I am looking for
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');
?>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.
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.
- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
There will be a problem if register_globals is OFF.dethron wrote:I see right values, and it is working. There shouldn't be any problem.
Please read:
Concerning Passing Variables in PHP 4.2+
Mac
[Edit: had to make a change because another poster changed their name]
Last edited by twigletmac on Fri Feb 13, 2004 8:34 am, edited 2 times in total.
- voodoo9055
- Forum Commoner
- Posts: 51
- Joined: Sat Apr 26, 2003 3:27 pm
- Location: Montgomery, AL
Code: Select all
<form method="post" action="index.php?user=<?php echo $user;?>&pass=<?php echo $pass;?>">