Passing form variables in PHP

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

malcolmboston
DevNet Resident
Posts: 1826
Joined: Tue Nov 18, 2003 1:09 pm
Location: Middlesbrough, UK

Passing form variables in PHP

Post by malcolmboston »

ok, not sure how to do this

i was following a tutorial earlier and completed it easily, the tutorial did exactl what i wanted to do, it would pass a piece of text from a form to the next page, unfortunately this means the post action is taken by page1.php or whatever you tell it to pass to

now the problem i am having (i use dreamweaver) is that the action is taken over by the login behaviour!

Is there any (easy) way to get them both running simultaneously?

also is it possible to rename a sessionID? instead of having 53746523745324 because that would work pretty much the same (at least the user would think so anyhow)

Eagerly Awaiting Your Help :lol:
malcolmboston
DevNet Resident
Posts: 1826
Joined: Tue Nov 18, 2003 1:09 pm
Location: Middlesbrough, UK

Post by malcolmboston »

no-one? :cry:
microthick
Forum Regular
Posts: 543
Joined: Wed Sep 24, 2003 2:15 pm
Location: Vancouver, BC

Post by microthick »

I could probably help you, but I don't understand what you mean when you say this:

now the problem i am having (i use dreamweaver) is that the action is taken over by the login behaviour!

Could you provide code please.
malcolmboston
DevNet Resident
Posts: 1826
Joined: Tue Nov 18, 2003 1:09 pm
Location: Middlesbrough, UK

Post by malcolmboston »

ok well im at university at the moment so dont have access to my code

ill try to explain this to the best of my ability

ok when you pass a form variable you need to use the form attribulte action-"pageyouwanttogoto.php" right?

well with mine that action is already being used for the login server behaviour that is on that form (the form is a login form and i want to pass the username to the next page so it would say Hello $variable welcome back) hope you know what i mean now, basically the action is currently something like =mm_rsUser or something to do with the code for my log-in, sorry for the crap explanation im pretty new to PHP

is there anyway of passing it to the next (logged in) page?
microthick
Forum Regular
Posts: 543
Joined: Wed Sep 24, 2003 2:15 pm
Location: Vancouver, BC

Post by microthick »

Ok,

I googled for MM_rsUser and the results that came up were VBScript scripts that I'm not familiar with. (Although it might also be just a plain Javascript function that Dreamweaver inserted as Dreamweaver functions always begin with MM_ as well.)

I'd have to see the function's code to give you a helpful solution.

Best bet would be to store the user's name in a session variable, or if that's not possible, when MM_rsUser eventually redirects you to the next web page, add the username as a url variable so that the following page can $_GET it.
malcolmboston
DevNet Resident
Posts: 1826
Joined: Tue Nov 18, 2003 1:09 pm
Location: Middlesbrough, UK

Post by malcolmboston »

its probably not MM_ruser i think thats ASP and my heads in bits over this so im probably confusing the 2

i just dont understand, every tutorial i have seen about this say that you have to specify a URL in the target, well if i edit the current URL the login stops working :x

and i suppose i can provide the code tomorrow, if you dont mind siftinf through approx 200 lines of pure php
d3ad1ysp0rk
Forum Donator
Posts: 1661
Joined: Mon Oct 20, 2003 8:31 pm
Location: Maine, USA

Post by d3ad1ysp0rk »

well with mine that action is already being used for the login server behaviour that is on that form (the form is a login form and i want to pass the username to the next page so it would say Hello $variable welcome back) hope you know what i mean now, basically the action is currently something like =mm_rsUser or something to do with the code for my log-in, sorry for the crap explanation im pretty new to PHP
Why don't you just change your action to the page you want to go to (members.php for example), and then on members.php put your login script...?
malcolmboston
DevNet Resident
Posts: 1826
Joined: Tue Nov 18, 2003 1:09 pm
Location: Middlesbrough, UK

Post by malcolmboston »

oh and i almost forgot

is it possible to rename the session id to the name that was put into the username text field?

this would be the easier solution, just been 'googling' as you guys say, and couldnt find anything about renaming session ID's

thanks
malcolmboston
DevNet Resident
Posts: 1826
Joined: Tue Nov 18, 2003 1:09 pm
Location: Middlesbrough, UK

Post by malcolmboston »

in reply to LILpunk

how exactly do you mean?

i mean basically (from what i understand) that would require 2 forms (which i suppose isnt necessary and a bit tacky) one would ask for your name (for the variable to display) then the action for that would be login.php then login script would be on that page?

there really is no other way?

im really sorry for all my questions im just confused when it comes to sessions and cookies (and yes i have RTFM i only been learning PHP a week)
microthick
Forum Regular
Posts: 543
Joined: Wed Sep 24, 2003 2:15 pm
Location: Vancouver, BC

Post by microthick »

malcolmboston wrote:oh and i almost forgot

is it possible to rename the session id to the name that was put into the username text field?

this would be the easier solution, just been 'googling' as you guys say, and couldnt find anything about renaming session ID's

thanks
Even if you could, I don't believe it would be advisable. You can always add other session variables to hold things like usernames, etc., but you should leave sessionid's as-is.
malcolmboston
DevNet Resident
Posts: 1826
Joined: Tue Nov 18, 2003 1:09 pm
Location: Middlesbrough, UK

Post by malcolmboston »

well i didnt think of that, if someone intercepts it
<<<<screwed with a capital S

ok thanks anyway

im gonna have to have a look at my code and work out why it is calling a action and see if i can move it out of the action and see if it still works

Thanks for helping me out anyway
sorry bout the sh!tty explanation :?

and lol another question
does anyone know where i can find a good tutorial on writing out my own cookies?
microthick
Forum Regular
Posts: 543
Joined: Wed Sep 24, 2003 2:15 pm
Location: Vancouver, BC

Post by microthick »

http://www.hotscripts.com/PHP/Tips_and_ ... index.html

Bunch of tutorials covering cookies and sessions.
User avatar
Saethyr
Forum Contributor
Posts: 182
Joined: Thu Sep 25, 2003 9:21 am
Location: Wichita, Kansas USA
Contact:

Post by Saethyr »

This is something that may work for your purpose, took me awhile to figure this one out, but I think it will work out

Code: Select all

<html>
<head>
<script>
function goNow(thissite)&#123;
 if (thissite != 'false')&#123;window.location.replace("http://www.msn.com")&#125;
 else &#123;window.location.replace("http://www.yahoo.com")&#125;
&#125;
</script>
</head>
<body>
MSN <input type="button" name="path" id="1"  value="MSN" onclick="site='true';goNow(site)"> <br>
Yahoo <input type="button" name="path" id="2"  value="Yahoo" onclick="site='false';goNow(site)"> 

</html>
inor.y
Forum Newbie
Posts: 6
Joined: Fri Nov 21, 2003 5:42 am
Location: Philippines
Contact:

Login Validation

Post by inor.y »

Malcolmboston,

I'm not an expert in PHP but made 2 sites in PHP, http://www.cabefuhats.com and http://www.sampaca.com. I use Dreamweaver MX to develop PHP web sites. I dont like session ids and cookies to validate logins. I use database behaviors in Dreamweaver to check the login is authenticated. In the form, use action="result.php" method="post", in the result.php, under recordset create a user database and under filter select username and URL parameter. Goto advance and create another column for the password as a passed parameter. An sql is created by matching the database with username and password.
User avatar
m3mn0n
PHP Evangelist
Posts: 3548
Joined: Tue Aug 13, 2002 3:35 pm
Location: Calgary, Canada

Post by m3mn0n »

Using just SQL to validate people is a big security risk. For example; if you don't want a particular person to access a page anymore, or if someone guesses the page name for the admin area, what can you do but deal with the consequences of their actions?

Cookies and sessions may be a tricky subject to some, but with the right documentation, tutorials, and practice, I'm sure any obsticals you have will be overcome.

For your particular problem, try this: http://www.php.net/manual/en/function.session-name.php

And also; try this for your form:

Code: Select all

<form name="theform" action="yournextpage.php" onSubmit="mm_rsUser()">
Tell me how it works.
Post Reply