URL Variables and forms

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!

Moderator: General Moderators

Post Reply
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

URL Variables and forms

Post by John Cartwright »

I have NO IDEA how to do this. Absolutely none. THe problem is that I use the url to determine which pages are going to be displayed.

My index.php has a set of variable checks which will load my admin.php withen itself if p=4 is in the url. Inside admin.php if a=3 is set this form is loaded up. So the page with the form is at index.php?p=4&a=3

Here is where to problem comes into play. The form action is set to itself (admin.php) How am I supposed to keep those variables set while have the action set to admin.php ( admin.php has checks too for information submitted in the form ) So the form is simply reloaded inside admin.php awhile admin.php is still in index.php while admin.php still does the checks after the form has been processed. :S sorry bit complicated.

If you need more clarification just ask

Ty

Edit - I tried changing the form action to this

Code: Select all

<?php
        echo "</font><form action="index.php?p=4&a=3&"\n".  

?>
but after the form is submitted is goes to index.php and all the form values.. ( not keeping the p=4&a=3& variables
User avatar
dull1554
Forum Regular
Posts: 680
Joined: Sat Nov 22, 2003 11:26 am
Location: 42:21:35.359N, 76:02:20.688W

Post by dull1554 »

i think i know what your getting at,
so in admin. php you have something like this

Code: Select all

if(isset($_GET['a']))
{
if($_GET['a'] == "3")
{
//what you need to do is have this
if(!isset($_POST['submit']))//i'm assuming your form is using POST, if not change it
{
//here is where you put your form code
}
else
{
//here is where you put the code to parse the form
}
}
}

}
else
{
//here is where you have the links to the different admin sections
}
i hopes this helps you, if i misunderstood you just let me know and ill do my best to help you......
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

okay let me just show you

INDEX.PHP ? P=4
index.php loads up admin.php (p=4) in the middle of index.php
ADMIN.PHP ? A=3
admin.php loads up a form inside admin.php

So now you got index.php?p=4&a=3

My admin.php is setup like this

Code: Select all

if a==3 then

show form etc etc

close if statement
then

Code: Select all

if form is submitted set open window admin_confirm.php with all the variables set in there
admin_confirm.php is what adds everything to the database.

Now what is happening is that my action in the form is set to index.php?p=4&a=3&

but it is bringing me to index.php?opponent=df&league=cal&date=df&map=de_dust2&outcome=win&submitrecord=SUBMIT ( notice there is no p=4&a=3 ) in the same window ... but the popup is working perfectly, all i want is to keep in on p=4&a=3
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

up
d3ad1ysp0rk
Forum Donator
Posts: 1661
Joined: Mon Oct 20, 2003 8:31 pm
Location: Maine, USA

Post by d3ad1ysp0rk »

<form action="index.php" method="get">
<input type="hidden" name="p" value="4" />
<input type="hidden" name="a" value="3" />
</form>
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

for some reason the p=3 isnt showing up only a
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

for some reason the first hidden variable was not being picked up so I added a 3rd one with the same values as the first one and it works fine
Post Reply