Page 1 of 1

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

Posted: Wed Oct 13, 2010 6:56 pm
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"];
?>

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

Posted: Wed Oct 13, 2010 7:20 pm
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.

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

Posted: Wed Oct 13, 2010 10:43 pm
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.

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

Posted: Thu Oct 14, 2010 4:24 pm
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...

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

Posted: Thu Oct 14, 2010 4:31 pm
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

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

Posted: Thu Oct 14, 2010 6:49 pm
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!

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

Posted: Thu Oct 14, 2010 11:05 pm
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?