Jump to content


sharing variables between scripts

  • Please log in to reply
2 replies to this topic

#1 nevx

  • New Members
  • Pip
  • Newbie
  • 4 posts

Posted 15 March 2006 - 04:35 AM

I need some help on this one
i have 3 pages , one is a simple html page user.html where
<form action='processform.php' method="post">
Please type your name herebr>
<input type=text name="username"><br><br>
<input type=submit value="submit"><br><br>

<p>Welcome <nbsp;><?php echo($_POST['username']);?>!</P>

<a target="_new" href="name.php" >Show Name</a>


<p>Applicant : <?php echo($_POST['username']);?></p>


why can't i see the variable in name.php any help appreciated
i'm using WAMP5 Version 1.6.1

#2 klinmy

  • Members
  • PipPipPip
  • Advanced Member
  • 33 posts

Posted 15 March 2006 - 04:54 AM


#3 keeB

  • Staff Alumni
  • Advanced Member
  • 1,078 posts
  • LocationCalifornia

Posted 15 March 2006 - 07:23 AM

Well.. the short answer is because you're not POST'ing any data from "processform.php" to name.php.

Let's modify those 2 files really quick..


$uname = $_POST['username'];

<p>Welcome <nbsp;><?php echo($uname);?>!</P>

<a target="_new" href="name.php?name=<?php echo($uname); ?>" >Show Name</a>



$uname = $_GET['name'];

<p>Applicant : <?php echo($uname);?></p>
So let's look at the changes..

In the first file.. we have data POSTed from the previous page, and we take that data and add it to the URL of the link we're making. Data added to the URL after the .php? mark are referred to by the $_GET[]; array..

I hope this makes sense.. if you are confused about any part, please don't hesitate to ask. :)

Come visit my site to see my latest projects

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users