Simple HTML / PHP posting Problem -- I've tried everything!

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
zeusra
Forum Newbie
Posts: 6
Joined: Tue Sep 07, 2010 11:55 pm
Location: WA

Simple HTML / PHP posting Problem -- I've tried everything!

Post by zeusra »

Hey guys,

I've been stuck on trying to get this super simple HTML form to $_POST and echo back in my php output file :banghead: . Any solutions would be greatly appreciated!

HTML---------------------------------------------------------------------------------------------------------------

Code: Select all

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

<head>
	<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
	<meta name="author" content="drewman" />

	<title>Untitled 16</title>
</head>
<body>
<form action="sendform.php" method="POST"> 

<p> First name:</p> <input type="text" name= "firstname" /></p>
<p>Last name:</p> <input type="text" name= "lastname" /></p>
<input type="submit" value="send" />

</form>
</body>
</html>

PHP Output---------------------------------------------------------------------------------------------------------------
<?php

 echo $_POST["firstname"];
 echo $_POST["lastname"];
?>
Last edited by Benjamin on Thu Oct 14, 2010 10:41 pm, edited 1 time in total.
Reason: Added [syntax=php] tags.
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Re: Simple HTML / PHP posting Problem -- I've tried everythi

Post by califdon »

I don't see anything wrong there. Are you sure that PHP is running? What are you getting, a blank page? Echo some fixed string, too, like:
echo "This is plain text.";

If that doesn't show up, and assuming that your php file really is named sendform.php and is in the same directory, it would seem like PHP isn't installed or configured correctly on your server.
cusackd
Forum Newbie
Posts: 5
Joined: Fri Apr 18, 2008 4:01 am

Re: Simple HTML / PHP posting Problem -- I've tried everythi

Post by cusackd »

Change your form method to "GET" and see what the variables your form is sending in the address bar of your browser, i find that to be the quickest way out of them problems.
zeusra
Forum Newbie
Posts: 6
Joined: Tue Sep 07, 2010 11:55 pm
Location: WA

Re: Simple HTML / PHP posting Problem -- I've tried everythi

Post by zeusra »

Ok thanks for your help. I've got a better idea now :idea: as to what the problem is;

I'm using phpDesigner 7 to launch my PHP scripts into my browser. The script should be running from localhost not the C: drive address... because of this the scripts aren't functioning properly.

I've confirmed again that the phpDesigner 7 localhost is set to right directory folder where my PHP files reside.

Any ideas as to what could be causing the address bar mixup between my C: drive and localhost?

PS. I have gotten the PHP file to "launch" properly from phpDesigner 7 into the browser. However the issue still remains for other PHP files. Those files are being loaded from...
Attachments
screenshot.png
screenshot.png (56.63 KiB) Viewed 205 times
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Re: Simple HTML / PHP posting Problem -- I've tried everythi

Post by John Cartwright »

Run it through the localhost button.

Image

Or do what 99% of people do, load it normally through your favorite browser :D
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Re: Simple HTML / PHP posting Problem -- I've tried everythi

Post by califdon »

Yes, you would be well advised never to use the built-in browser for a script file. That's OK for plain HTML, but if you look at the 2 URL lines that you highlighted, you will see that one is using file:/// protocol, which means it is NOT using any web server! "Localhost" is not a property of your editing suite, it is the address of your local WEB SERVER. Since PHP is only parsed by a web server, it cannot be interpreted using the file:/// protocol, only http:// protocol. Simply use a regular browser pointed to your localhost web server to check out anything that requires PHP!
zeusra
Forum Newbie
Posts: 6
Joined: Tue Sep 07, 2010 11:55 pm
Location: WA

Re: Simple HTML / PHP posting Problem -- I've tried everythi

Post by zeusra »

Thank you for your info. Isn't the Localhost button inside phpDesigner 7 a link to launch the file from my localhost webserver? If so, shouldn't be loading the files from the localhost address and not the C: drive?
Post Reply