variable passing help!!
Moderator: General Moderators
-
just a member
- Forum Newbie
- Posts: 5
- Joined: Tue Aug 08, 2006 6:58 am
variable passing help!!
Hi,
i have an html page lets say page.html which contain a form with input field called username and i have two php pages lets say page1.php and page2.php. now the problem is that i need to use the variable username in page1.php and page2.php but how i can do that i know i should use a $_session but i don't know how sorry about my question but i just start learning php and i need it in my project so if any body can help me with a siple example i will be very thankfull
kind regards
i have an html page lets say page.html which contain a form with input field called username and i have two php pages lets say page1.php and page2.php. now the problem is that i need to use the variable username in page1.php and page2.php but how i can do that i know i should use a $_session but i don't know how sorry about my question but i just start learning php and i need it in my project so if any body can help me with a siple example i will be very thankfull
kind regards
- php3ch0
- Forum Contributor
- Posts: 212
- Joined: Sun Nov 13, 2005 7:35 am
- Location: Folkestone, Kent, UK
HINT:
Code: Select all
session_start();
$_SESSION['username']= ...-
just a member
- Forum Newbie
- Posts: 5
- Joined: Tue Aug 08, 2006 6:58 am
Pimptastic | Please use
and i have logged_in.php and there i don't have any proplem the problem is in personal_information.php where i need to use the variable username to specify the retrieving from the database, i use postgresql !
i'm so confused about using $_SESSION i meen i should put session_start(); in every page or what ??
kind regards
Pimptastic | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
thank you for response,
yes i have code
the html page called log_in.html and it contain form with username fieldCode: Select all
<?php session_start();
$_SESSION['username']='username';
?>
<form method="POST" action="log_in.php" name="myform" onSubmit="return validateform( this.form )" >
<input name="username" size="20" style="border: 1px inset #000000" dir="ltr" maxlength="8">i'm so confused about using $_SESSION i meen i should put session_start(); in every page or what ??
kind regards
Pimptastic | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]- php3ch0
- Forum Contributor
- Posts: 212
- Joined: Sun Nov 13, 2005 7:35 am
- Location: Folkestone, Kent, UK
Code: Select all
$_SESSION['username']=$_POST['username'];-
just a member
- Forum Newbie
- Posts: 5
- Joined: Tue Aug 08, 2006 6:58 am
Pimptastic | Please use
and thin at personal_information.php i should start the code with
am i right!? if so how i can use the value of username in the SQL query?? should i use it as 'username' or '$username' or what??!
sorry again for my silly questions.
kind regards
Pimptastic | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
hi again,
sorry for many question but i realy need to understand this.
now in log_in.html i should code withCode: Select all
<?php session_start();
$_SESSION['username']='$username';
?>Code: Select all
<?php session_start();
$_SESSION['username']=$_POST['username'];sorry again for my silly questions.
kind regards
Pimptastic | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]-
just a member
- Forum Newbie
- Posts: 5
- Joined: Tue Aug 08, 2006 6:58 am
thank u very much ,
but i;m very disappointed because it didn't work the query didn't give me any results i don't know what is the problem but when i try the code with a specific username it give me the results i want so, i think the proplem with passing the variable from the html form!!!???
kind regards
but i;m very disappointed because it didn't work the query didn't give me any results i don't know what is the problem but when i try the code with a specific username it give me the results i want so, i think the proplem with passing the variable from the html form!!!???
kind regards
-
just a member
- Forum Newbie
- Posts: 5
- Joined: Tue Aug 08, 2006 6:58 am
Code: Select all
<?php session_start();
$_SESSION['username']='$username';
?>it needs to be like this
Code: Select all
<?php session_start();
$_SESSION['username']=$username;
?>Code: Select all
<?php session_start();
$_SESSION['username']=$_POST['username'];
?>