MeMory LEAk99
MeMory LEAk99

Reputation: 305

Why does my Form return raw php code?

When I submit my form; the resultant page seems to output just raw php code rather than actually executing. the funny thing is, if I just run my code and hard code the $_get array values it works a charm I'm running this on a virtual server (Xampp) if that helps.

  *The related get code *

    $search = $_GET['searcharg'];

The form:

<form action="search.php" method="get">

Search:<input type="text" name="searcharg" /><br />
<input type="submit" value="Submit" />

</form> 

Any help would be appreciated.

Upvotes: 1

Views: 1055

Answers (1)

Jim
Jim

Reputation: 18853

Give you only posted one line, a few basic items.

First up are you using the opening and closing php tags?

<?php
$search = $_GET['searcharg'];
echo $search;
?>

If not, they are needed.


Next make sure you are using http://localhost to access the file and that you are not accessing it using the file:///etcetcetc version (as catfish hinted to). As it has to be ran through the Apache server in order to be handled properly.


If you are, then the issue will most likely lay within Apache not setup properly to handle the .php extension, but xampp should handle that for you. So try the above option and see how that goes. If it is the problem that apache is not recognizing the .php extension, you can add this to your httpd.conf and then restart apache and it should kick it into gear:

AddType application/x-httpd-php .php

Upvotes: 2

Related Questions