Copy link to clipboard
Copied
Hello all,
I'm new to the forum and to web design and Dreamweaver, please go a little easy on me!
I'm currently in the process of making a fantasy football website in Dreamweaver and phpmyadmin. When a user visits the site and wants to enter the competition they click register which brings up the register page. There they can fill out the form containing details username, password etc. When they click the register button at the bottom of the form their details are put into the users table in the database and they are passed onto the next page where they are asked to pick their team. The team details are kept in a seperate table in the database.
What i'm trying to do is pass the username that is created in the register form to the pick team page as a parameter.
Currently the code for my button is as follows:
<input type="submit" value="Insert record" />
and the sql for after insert goto is currently?
$insertGoTo = "pickteam.php";
In another section of the site i have passed a parameter with a link as follows:
<a href="editgoalkeeper.php?gkid_gk=<?php echo $row_rs_viewgks['gkid_gk'];?>">
but i'm not sure how to pass a parameter using a submit button, can anyone help me please?
You need to use PHP sessions, and store the username as a session variable.
Begin the page that registers the user with session_start();. You can then save the username to a session variable:
session_start();
if (isset ($_POST['username'])) {
$_SESSION['username'] = $_POST['username'];
}
Thereafter, $_SESSION['username'] will be available on any page that begins with session_start();.
Copy link to clipboard
Copied
You pass a parameter by putting the value you want to pass into a form field.
Copy link to clipboard
Copied
Please pardon my ignorance, i'm still very new to web development and Dreamweaver.
Please could you give me an example of how i would go about coding the above?
Copy link to clipboard
Copied
I don't do php so I'm not sure if the reference to the dynamic data is correct, but it would be something like:
<form action="editgoalkeeper.php" method="get">
<input name="GoalKeeperID" type="text" value= <?php echo $row_rs_viewgks['gkid_gk'];?>>
<input name="submit" type="submit">
</form>
Copy link to clipboard
Copied
pb1uk wrote:
but i'm not sure how to pass a parameter using a submit button, can anyone help me please?
You can't pass a parameter using a submit button. If the value is not something that the user inserts into the form, you need to pass the value as a hidden field.
<input type="hidden" name="some_value" id="some_value"
value="This will be passed with the form when submitted" />
Copy link to clipboard
Copied
Hi,
Sorry i don't think i've explained it well.
The user is filling out a form to register as a user. Part of the form requires them to enter their username. After completing the form the users details are enterred into the database and they go onto the next page requiring the user to pick their team. This page is like another insert record form as it will insert a record into the teams table of the database.
What i need to do is have the value the user enterred into the username field in the register form passed to the pick team page. This is because a users details and their teams details are held in different tables. So the username is a foreign key in the team table.
Hope that makes sense
Copy link to clipboard
Copied
You need to use PHP sessions, and store the username as a session variable.
Begin the page that registers the user with session_start();. You can then save the username to a session variable:
session_start();
if (isset ($_POST['username'])) {
$_SESSION['username'] = $_POST['username'];
}
Thereafter, $_SESSION['username'] will be available on any page that begins with session_start();.
Copy link to clipboard
Copied
Thanks David.
If i were to do that approach would i need to put that code at the top of every page on the site, or just when a user logs in.
As the register page is only a simple record form insertion wizard page would adding this code mean a user is actually logged in. At the moment after registering the user has to go back to the main page and login and the register page doesn't log them in, if that makes sense
Copy link to clipboard
Copied
See the following page in the FAQ: http://forums.adobe.com/thread/417437.
When someone logs in, the username is automatically stored in $_SESSION['MM_Username'].
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more