Jump to content

[SOLVED] trouble passing inputed data from one page to another


cluce

Recommended Posts

I have one page called home.html with the following code:

 

<A HREF="http://localhost/welcome.php"> Hi, I'm Kevin! </A>

 

<FORM ACTION="http://localhost/welcome.php" METHOD=post>

First Name: <INPUT TYPE=TEXT NAME="firstname"><BR>

Last Name: <INPUT TYPE=TEXT NAME="lastname">

<INPUT TYPE=SUBMIT VALUE="GO"></FORM>

 

and the other page is called welcome.php and has the following code:

 

<HTML>

<HEAD>

<TITLE>Today's Date</TITLE>

</HEAD>

<BODY>

<p>welcome to my site</p>

 

<P>Today's Date (according to this Web server) is

 

<?php  echo( "Welcome to our Web site,$firstname $lastname!" );

 

?>

</BODY>

</HTML>

 

everything loads fine but the firstname and lastname entered is not showing. I am puzzled. I cant see where the error is.

 

can someone please help?

 

thanks in advance

 

Link to comment
Share on other sites

#1. Never use localhost, use the whole site name or relitave path to the file...

 

#2. The variables are passed using the $_POST[] method, so in your case you can access your 2 variables like this...

 

<?php  echo( "Welcome to our Web site,$_POST[firstname] $_POST[lastname]!" ); ?>

Link to comment
Share on other sites

whats outdated about his html? he is just using the basic tags...html...head...body...along with basic inputs....nothing outdated about it.?

 

slandered html is becoming out of date. There are almost no rules. As a result, different browsers will display html different in some cases...

 

XHTML is becoming the new standard.

http://www.w3schools.com/xhtml/xhtml_intro.asp

 

More info:

http://www.w3.org/TR/xhtml1/

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.