Simple script issue?

for some reason I cannot get any form to work correctly on my website, I even went to w3school and copied a simple test form to see if it works, and it does not, here it is:

welcome.php:

<?
Welcome <?php echo $_GET["fname"]; ?>!<br />
You are <?php echo $_GET["age"]; ?> years old.
?>

form:

<form action="welcome.php" method="get">
Name: <input type="text" name="fname" />
Age: <input type="text" name="age" />
<input type="submit" />
</form>

I'm not sure if it matters or not, but I tried with and without brackets, and still I get a blank page, in explorer I get a 500 Error, most likely causes is maintenance or Programming Error", but I had the same issue last night so I doubt its maintenance, and everything else works.

Answers


Remove the beginning <? and ending ?> from your welcome.php.


Your form uses get and you're reading from $_POST.

Either change html to

<form action="welcome.php" method="post">

or change the php to

Welcome <?php echo $_GET["fname"]; ?>!<br />
You are <?php echo $_GET["age"]; ?> years old.

Also, make sure the value is present using the isset

Welcome <?php echo isset($_GET["fname"]) ? $_GET["fname"] : "Guest"; ?>!<br />

When you use $_POST["fname"] you should also specify post as method in your form

welcome.php:

<?
Welcome <?php echo $_POST["fname"]; ?>!<br />
You are <?php echo $_POST["age"]; ?> years old.
?>

form:

<form action="welcome.php" method="post">
Name: <input type="text" name="fname" />
Age: <input type="text" name="age" />
<input type="submit" />
</form>

Need Your Help

How to perform sequential file write in separate thread

iphone c objective-c multithreading callback

I am given some data in a callback function to write to disk sequentially, about 4KB every 0.02 seconds. If I fwrite() from the thread the callback function is in, I get some lag in other parts of ...

Run VBA function with a button

excel vba excel-vba macros

I defined a VBA function that returns a filesize. Now I want to invoke it with a button that's calling a different macro. My expectation is that after running the macro it'll invoke my function at...