Home Get a variable from another page in php
Reply: 0

Get a variable from another page in php

user1681 Published in August 15, 2018, 9:02 am

I wanted to show the variable username into another page. These are the codes I've used. This is the first page where the username is inserted.

include('login.php'); // Includes Login Script

<div id="login" align="center">
<form action="" method="post">
<label>Username :</label>
<input id="name" name="username" placeholder="username" type="text"><br>
<label>Password :</label>
<input id="password" name="password" placeholder="**********" type="password"><br><br>
<input name="submit" type="submit" value=" Login ">
<span><?php echo $error; ?></span>

Then in this page I wanted to show the username that was inserted

<?php include 'database.php'; ?>
<?php session_start(); ?>
function visualizza($file) {
$f = fopen($file, "r"); // apro il file in lettura
return fread($f, filesize($file));
<div class="container">
<h2> Quiz Completato!</h2>
<p> Congratulations <?php 
$username = $_POST['username']; 
echo $username;

! You completed the test</p>
<p>Final Score:<?php echo $_SESSION['score']; ?> </p>

But it tells me Notice: Undefined index: username in C:\xampp\htdocs\quizzer\final.php on line 29 How can I solve it please?

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.367541 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO