Hey all
How can i capture the username, which is being input in a textbox, and pass it to another page?

Login.php
Example,
username: admin

Welcome.php
it should display,
Welcome, admin

How can i achieve this?

Using dtreamweaver with PHP language

Thanks

Recommended Answers

All 3 Replies

you pass it via the $_GET method or the $_POST method.

you pass it via the $_GET method or the $_POST method.

Could you guide me on how to do that?
Im a beginner in php

Ok, you need to look at a few tutorials (there's millions on the net) about user logins and sessions. In a nutshell: form.html This contains the textbox.

<form action="submit.php" method="GET"> <!--or "POST"-->
  <input type="text" name="username" />
</form>

submit.php Set the session variable

<?php
session_start(); //so you can use the session variable
&username = $_GET['username']; //or $_POST depending on form method
echo "Hello $username. I have learnt your name!";
SESSION['username']=$username;
?>
<a href="/page.php">Return</a>

page.php //Content page

<?php
start_session();
if isset($_SESSION['username']){
  echo "Hey $_SESSION['username'], I remembered your name!";
}
?>
...rest of page content

Now please do some research so you understand that code and how your using it.

[code untested]

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.