1

I have a php page which displays certain profile data like Name,Username,Phone,Addres etc which were passed as params in url.Now after saving those details the page is being redirected to an html login page where I need to display the Username value in the text field for the Username.I tried to pass the username from php to html in many ways but in vain.By what means can i pass the username from the php page to html login page and display it in Username text field?

user3363475
  • 21
  • 1
  • 5

6 Answers6

1

if you don't use any PHP Framework then you can save it by session or cookies. Then on login page you can get it and show

1

Use a php Site for login and than use this code at your registerscript (php) (be sure this is the first thing send to the client no echo before this)

header("LOCATION: http://www.something.com?username=walter&secoundusername=white");

In your login page you can access the data with

if(isset($_GET('username'))){
 $username = $_GET('username');
}...

I hope this works for you.

  • You can display the same using like, var UserName = ''; $('#txtUserName').val(UserName); – Emma Aug 19 '14 at 08:43
0

your question is not too clear, however if the html login page is just a static page, i don't see how your request could be achieved.

If instead it's a php generated html page, then you may pass the variable via a hidden input field for example.

LordVee
  • 104
  • 1
  • 13
0

You could use the fputs php function to create a html page

<?php
$fp = fopen("file.html", 'w+');
fputs($fp, "YOUR HTML CODE");
fputs($fp, "YOUR HTML CODE");
fputs($fp, "$variable");
fclose($fp);
?>
<a href='file.html'>Link</a>
duxkater
  • 23
  • 4
0

You can pass username as parameter in URL like

http://yoursite.com/login.html?username=abc

and in login.html use javascript to get the url parameter and assign it to textbox.

 function getParamURL(param) {
    return decodeURIComponent((new RegExp('[?|&]' + param + '=' + '([^&;]+?)(&|#|;|$)').exec(location.search)||[,""])[1].replace(/\+/g, '%20'))||null
   }

var username = getParamURL('username');
document.getElementById("username").value= username;

suppose your textbox id is username then it should assign it to that text box

Maz I
  • 3,664
  • 2
  • 23
  • 38
0

Here is the login page

<?php 

    if($_POST)
    {
        include("Connect.php");

        $Username=$_POST["Username"];
        $Password=$_POST["Password"];

        $Query="select Username from user where username='$Username' and password='$Password' LIMIT 1";

        $Result=mysql_query($Query);

        while($R=mysql_fetch_array($Result))
        {

            header("location:main.html?username='$R[0]'");

        }
    }
?>
<form action="<?=$_SERVER['PHP_SELF'] ?>" method="POST">
<input type="text" name="Username">
<input type="text" name="Password">

<input type="submit"/>



</form>

Here is how you could retrieve the page.The variable needs to be a php page

<html>

<p>Welcome</p> <?php 
$Name=$_GET["username"];
echo $Name;

?>


</html>
Ethic Or Logics
  • 111
  • 1
  • 13